MeVisLab Toolbox Reference
mlMemoryBlockHandle.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2008, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_MEMORY_BLOCK_HANDLE_H
14 #define ML_MEMORY_BLOCK_HANDLE_H
15 
16 #ifdef _MSC_VER
17 // Disable all system header warnings.
18 #pragma warning( push,0 )
19 #endif
20 #include <cstddef>
21 #ifdef _MSC_VER
22 #pragma warning( pop )
23 #endif
24 
25 #include "../mlMemoryManagerDllExport.h"
26 
27 
28 class MLMemoryBlock;
30 
31 
38 class MLMEMORYMANAGER_EXPORT MLMemoryBlockHandle
39 {
40 public:
45  MLMemoryBlockHandle(const MLMemoryBlockHandle& memoryBlockHandle);
49  MLMemoryBlockHandle(const MLWeakMemoryBlockHandle& weakMemoryBlockHandle);
50 
54 
58  bool isNull() const;
59 
61  void* data() const;
62 
64  size_t size() const;
65 
68  void clear();
69 
77 
80  MLMemoryBlockHandle& operator=(const MLWeakMemoryBlockHandle& weakMemoryBlockHandle);
81  // End of group ThreadSafe
83 
84 
85 #ifndef DOXYGEN_SHOULD_SKIP_THIS
86 
87 private:
88  void setMemoryBlockFromStrongHandle(const MLMemoryBlockHandle& memoryBlockHandle);
89  void setMemoryBlockFromWeakHandle(const MLWeakMemoryBlockHandle& weakMemoryBlockHandle);
90 
91 private:
92  MLMemoryBlock* _memoryBlock;
93 
94  friend class MLMemoryBlock;
95  friend class MLMemoryManager;
96  friend class MLWeakMemoryBlockHandle;
97 #endif
98 };
99 
100 #endif // MLMEMORYBLOCKHandle_H_INCLUDED
The strong handle of a MLMemoryBlock.
MLMemoryBlockHandle()
Creates a memory block handle that is null.
MLMemoryBlockHandle(const MLWeakMemoryBlockHandle &weakMemoryBlockHandle)
Creates an memory block handle to the memory block of weakMemoryBlockHandle.
~MLMemoryBlockHandle()
If only weak handles to the memory block exist, then the memory block is added to the cache list.
size_t size() const
Returns the size of the data. If this handle is null, then 0 is returned.
bool isNull() const
Returns true if the handle does not reference a valid memory block.
void clear()
Releases the reference to the memory block.
MLMemoryBlockHandle(const MLMemoryBlockHandle &memoryBlockHandle)
Creates an additional memory block handle to the memory block of memoryBlockHandle.
void * data() const
Returns the data of the memory block. If this handle is null, then NULL is returned.
The memory manager.
The weak handle of a MLMemoryBlock.
MLMemoryBlockHandle & operator=(const MLMemoryBlockHandle &memoryBlockHandle)
Creates a memory block handle from the memory block handle.
MLMemoryBlockHandle & operator=(const MLWeakMemoryBlockHandle &weakMemoryBlockHandle)
Creates a memory block handle from the weak memory block handle.