CS::CowWrapper< T, MemoryAllocator > Class Template Reference
Copy-on-write wrapper for arbitrary types. More...
#include <csutil/cowwrapper.h>
Public Member Functions | |
| CowWrapper (const T &other) | |
Create a new wrapper and initialize with other. | |
| CowWrapper (const CowWrapper &other) | |
Copy reference to data from other. | |
| T & | operator * () |
| Return a non-const reference to the contained data. | |
| const T & | operator * () const |
| Return a const reference to the contained data. | |
| T * | operator-> () |
| Return a non-const pointer to the contained data. | |
| const T * | operator-> () const |
| Return a const pointer to the contained data. | |
Static Public Attributes | |
| static const size_t | allocSize = sizeof (WrappedData) |
Detailed Description
template<typename T, class MemoryAllocator = Memory::AllocatorMalloc>
class CS::CowWrapper< T, MemoryAllocator >
Copy-on-write wrapper for arbitrary types.
_________________________________________
/ Instances transparently maintain a \
| reference-counted pointer to the actual |
| data; if an instance is copied, merely |
| this pointer is copied. |
| |
| As long as all access to the data is |
| constant, the data is shared between |
| instances. Only if non-const access is |
| requested the data is duplicated. |
| |
\ The wrapper itself acts like a pointer. /
-----------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
- Remarks:
- Contained types must have a proper copy constructor.
Care should be taken that the data is accessed with proper const-ness, since only the then data can be shared. Otherwise, data may be duplicated needlessly.
Definition at line 62 of file cowwrapper.h.
Constructor & Destructor Documentation
| CS::CowWrapper< T, MemoryAllocator >::CowWrapper | ( | const CowWrapper< T, MemoryAllocator > & | other | ) | [inline] |
| CS::CowWrapper< T, MemoryAllocator >::CowWrapper | ( | const T & | other | ) | [inline] |
Member Function Documentation
| T& CS::CowWrapper< T, MemoryAllocator >::operator * | ( | ) | [inline] |
Return a non-const reference to the contained data.
- Remarks:
- This will copy the contained data, so only use when really necessary.
Definition at line 115 of file cowwrapper.h.
| const T& CS::CowWrapper< T, MemoryAllocator >::operator * | ( | ) | const [inline] |
Return a const reference to the contained data.
Definition at line 106 of file cowwrapper.h.
Referenced by CS::CowWrapper< T, MemoryAllocator >::operator->().
| T* CS::CowWrapper< T, MemoryAllocator >::operator-> | ( | ) | [inline] |
Return a non-const pointer to the contained data.
- Remarks:
- This will copy the contained data, so only use when really necessary.
Definition at line 132 of file cowwrapper.h.
References CS::CowWrapper< T, MemoryAllocator >::operator *().
| const T* CS::CowWrapper< T, MemoryAllocator >::operator-> | ( | ) | const [inline] |
Return a const pointer to the contained data.
Definition at line 125 of file cowwrapper.h.
References CS::CowWrapper< T, MemoryAllocator >::operator *().
The documentation for this class was generated from the following file:
- csutil/cowwrapper.h
Generated for Crystal Space by doxygen 1.4.7
