Shared pointer interface. More...
#include <utilities/shared_pointer.h>
Inherits nitro::SharedPointerInterface.
Public Member Functions | |
SharedPointer (void) | |
SharedPointer (managed_type *p) | |
SharedPointer (const SharedPointer &p) | |
void | Reset (managed_type *p) |
SharedPointer< managed_type > | operator= (const SharedPointer< managed_type > &p) |
managed_type * | GetData (void) |
virtual void * | GetDataAddress (void) |
managed_type * | operator-> (void) |
managed_type & | operator* (void) |
operator managed_type * (void) | |
virtual | ~SharedPointer () |
Private Member Functions | |
void | Release (void) |
Private Attributes | |
int * | ReferenceCounter |
managed_type * | Data |
nitro::Allocator * | DefaultAllocator |
Shared pointer interface.
Shared pointer class.
Definition at line 66 of file shared_pointer.h.
nitro::SharedPointer< managed_type >::SharedPointer | ( | void | ) |
Default constructor.
Definition at line 277 of file shared_pointer.h.
References nitro::Allocator::AllocateBlock(), nitro::SharedPointer< managed_type >::Data, nitro::SharedPointer< managed_type >::DefaultAllocator, nitro::GetAllocator(), and nitro::SharedPointer< managed_type >::ReferenceCounter.
{ DefaultAllocator = nitro::GetAllocator(); ReferenceCounter = new int; * ReferenceCounter = 1; Data = DefaultAllocator->AllocateBlock(); }
nitro::SharedPointer< managed_type >::SharedPointer | ( | managed_type * | p | ) |
Constructor.
p | - Pointer to store. |
Definition at line 285 of file shared_pointer.h.
References nitro::SharedPointer< managed_type >::Data, nitro::SharedPointer< managed_type >::DefaultAllocator, nitro::GetAllocator(), and nitro::SharedPointer< managed_type >::ReferenceCounter.
{ DefaultAllocator = nitro::GetAllocator(); ReferenceCounter = new int; * ReferenceCounter = 1; Data = p; }
nitro::SharedPointer< managed_type >::SharedPointer | ( | const SharedPointer< managed_type > & | p | ) |
Copy constructor.
p | - Pointer to copy. |
Definition at line 293 of file shared_pointer.h.
References nitro::SharedPointer< managed_type >::Data, nitro::SharedPointer< managed_type >::DefaultAllocator, nitro::GetAllocator(), and nitro::SharedPointer< managed_type >::ReferenceCounter.
{ DefaultAllocator = nitro::GetAllocator(); ReferenceCounter = p.ReferenceCounter; Data = p.Data; ( * ReferenceCounter )++; }
nitro::SharedPointer< managed_type >::~SharedPointer | ( | ) | [virtual] |
Destructor (virtual).
Definition at line 349 of file shared_pointer.h.
References nitro::SharedPointer< managed_type >::Release().
{ Release(); }
managed_type * nitro::SharedPointer< managed_type >::GetData | ( | void | ) |
Getting data to the pointer.
Definition at line 324 of file shared_pointer.h.
References nitro::SharedPointer< managed_type >::Data.
{ return( Data ); }
void * nitro::SharedPointer< managed_type >::GetDataAddress | ( | void | ) | [virtual] |
Getting data to the pointer.
Implements nitro::SharedPointerInterface.
Definition at line 329 of file shared_pointer.h.
References nitro::SharedPointer< managed_type >::Data.
{ return( ( void * )Data ); }
nitro::SharedPointer< managed_type >::operator managed_type * | ( | void | ) |
Cast operator.
Definition at line 344 of file shared_pointer.h.
References nitro::SharedPointer< managed_type >::Data.
{ return( Data ); }
managed_type & nitro::SharedPointer< managed_type >::operator* | ( | void | ) |
Dereferencing operator.
Definition at line 339 of file shared_pointer.h.
References nitro::SharedPointer< managed_type >::Data.
{ return( * Data ); }
managed_type * nitro::SharedPointer< managed_type >::operator-> | ( | void | ) |
Field selector.
Definition at line 334 of file shared_pointer.h.
References nitro::SharedPointer< managed_type >::Data.
{ return( Data ); }
SharedPointer< managed_type > nitro::SharedPointer< managed_type >::operator= | ( | const SharedPointer< managed_type > & | p | ) |
Assign operator.
p | - Pointer to copy. |
Definition at line 310 of file shared_pointer.h.
References nitro::SharedPointer< managed_type >::Data, nitro::SharedPointer< managed_type >::ReferenceCounter, and nitro::SharedPointer< managed_type >::Release().
{ if( this != & p ) { Release(); ReferenceCounter = p.ReferenceCounter; Data = p.Data; ( * ReferenceCounter )++; } return( * this ); }
void nitro::SharedPointer< managed_type >::Release | ( | void | ) | [private] |
Function releases pointer if necessary.
Definition at line 354 of file shared_pointer.h.
References nitro::SharedPointer< managed_type >::Data, nitro::Allocator::DeallocateBlock(), nitro::SharedPointer< managed_type >::DefaultAllocator, and nitro::SharedPointer< managed_type >::ReferenceCounter.
Referenced by nitro::SharedPointer< managed_type >::operator=(), nitro::SharedPointer< managed_type >::Reset(), and nitro::SharedPointer< managed_type >::~SharedPointer().
{ if( * ReferenceCounter == 1 ) { delete ReferenceCounter; ReferenceCounter = 0; //delete Data; DefaultAllocator->DeallocateBlock( Data ); Data = 0; } else { ( * ReferenceCounter )--; } }
void nitro::SharedPointer< managed_type >::Reset | ( | managed_type * | p | ) |
Function initializes pointer.
p | - Pointer. |
Definition at line 301 of file shared_pointer.h.
References nitro::SharedPointer< managed_type >::Data, nitro::SharedPointer< managed_type >::ReferenceCounter, and nitro::SharedPointer< managed_type >::Release().
{ Release(); ReferenceCounter = new int; * ReferenceCounter = 1; Data = p; }
managed_type* nitro::SharedPointer< managed_type >::Data [private] |
Stored data.
Definition at line 249 of file shared_pointer.h.
Referenced by nitro::SharedPointer< managed_type >::GetData(), nitro::SharedPointer< managed_type >::GetDataAddress(), nitro::SharedPointer< managed_type >::operator managed_type *(), nitro::SharedPointer< managed_type >::operator*(), nitro::SharedPointer< managed_type >::operator->(), nitro::SharedPointer< managed_type >::operator=(), nitro::SharedPointer< managed_type >::Release(), nitro::SharedPointer< managed_type >::Reset(), and nitro::SharedPointer< managed_type >::SharedPointer().
nitro::Allocator* nitro::SharedPointer< managed_type >::DefaultAllocator [private] |
Default allocator.
Definition at line 273 of file shared_pointer.h.
Referenced by nitro::SharedPointer< managed_type >::Release(), and nitro::SharedPointer< managed_type >::SharedPointer().
int* nitro::SharedPointer< managed_type >::ReferenceCounter [private] |
Reference counter.
Definition at line 237 of file shared_pointer.h.
Referenced by nitro::SharedPointer< managed_type >::operator=(), nitro::SharedPointer< managed_type >::Release(), nitro::SharedPointer< managed_type >::Reset(), and nitro::SharedPointer< managed_type >::SharedPointer().