Beamlib  3.0.1
This is the Beam C++ class library.
BRefData.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * BRefData.h Referenced data storage
3  * T.Barnaby, Beam Ltd, 6/10/94
4  * Copyright (c) 2022 All Right Reserved, Beam Ltd, https://www.beam.ltd.uk
5  * For license see LICENSE.txt at the root of the beamlib source tree.
6  *******************************************************************************
7  */
14 #ifndef BREFDATA_H
15 #define BREFDATA_H 1
16 
17 #include <BAtomicCount.h>
18 
20 class BRefData {
21 public:
22  BRefData();
23  BRefData(int len);
24  BRefData(const BRefData& refData);
25  ~BRefData();
26 
27  BRefData* copy();
28  BRefData* addRef();
29  int deleteRef();
30 
31  char* data(){ return (char*)odata; }
32  int len(){ return olen; }
33 
34  BRefData& operator=(const BRefData& refData);
35 
36  void setLen(int len);
37 
38 private:
39 
40  BAtomicCount orefCount;
41  int olen;
42  void* odata;
43 };
44 
45 
46 #endif
BAtomicCount class.
Definition: BAtomicCount.h:50
A pointer to a variable sized data area with reference counting so the data areas can be shared.
Definition: BRefData.h:20
char * data()
Return the raw data pointer.
Definition: BRefData.h:31
BRefData * copy()
Create a copy of this reference for writing, if necessary
Definition: BRefData.cpp:51
int deleteRef()
Decrement the reference counter.
Definition: BRefData.cpp:69
BRefData * addRef()
Increment the reference counter.
Definition: BRefData.cpp:64
BRefData()
Definition: BRefData.cpp:15
int len()
Return the length in bytes.
Definition: BRefData.h:32
void setLen(int len)
Set the length in bytes. Note should only be used if orefCount = 1.
Definition: BRefData.cpp:73
~BRefData()
Definition: BRefData.cpp:44
BRefData & operator=(const BRefData &refData)
Definition: BRefData.cpp:35