GRUTinizer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TSmartBuffer.h
Go to the documentation of this file.
1 #ifndef _TSMARTBUFFER_H_
2 #define _TSMARTBUFFER_H_
3 
4 #ifndef __CINT__
5 #ifndef __ROOTMACRO__
6 # include <mutex>
7 # include <atomic>
8 #endif
9 #endif
10 //class std::mutex;
11 
12 #include "TObject.h"
13 
15 
25 class TSmartBuffer : public TObject {
26 public:
28 
32  TSmartBuffer();
33 
35 
41  TSmartBuffer(char* buffer, size_t size);
42 
44 
48  ~TSmartBuffer();
49 
51  TSmartBuffer(const TSmartBuffer& other);
52 
55 
56 #ifndef __CINT__
57 #ifndef __ROOTMACRO__
58 
59  TSmartBuffer(TSmartBuffer&& other);
60 #endif
61 #endif
62 
63 
64 
66 
71  void Clear();
72 
74 
78  void SetBuffer(char* buffer, size_t size);
79 
81 
86  const char* GetData() const { return fData; }
87 
89 
94  size_t GetSize() const { return fSize; }
95 
97 
109  TSmartBuffer BufferSubset(size_t pos, size_t length = -1) const;
110 
112 
118  void Advance(size_t dist);
119 
121  void Print(Option_t* opt = "") const;
122 
123 
124 private:
126 
129  void swap(TSmartBuffer& other);
130 
132 
137 
139  char* fData;
140 
142  size_t fSize;
143 #ifndef __CINT__
144 #ifndef __ROOTMACRO__
145 
146  std::atomic_int* fReferenceCount;
147 #endif
148 #endif
149 
151 };
152 
153 #endif /* _TSMARTBUFFER_H_ */