#include <CdbCPtr.hh>
Inheritance diagram for CdbCPtr< P, CLOSE_POLICY >:

Public Types | |
| typedef P | element_type |
| This is the type of objects pointed through this smart pointer. | |
| typedef CLOSE_POLICY | close_policy |
| This is the type of the close policy. | |
Public Member Functions | |
| CdbCPtr (P *ptr=0) | |
| The constructor. | |
| CdbCPtr (const CdbCPtr< P, CLOSE_POLICY > &thePtr) | |
| The copy constructor. | |
| ~CdbCPtr () | |
| The destructor. | |
| CdbCPtr & | operator= (const CdbCPtr< P, CLOSE_POLICY > &thePtr) |
| Asignment operator. | |
| CdbCPtr & | operator= (P *ptr) |
| Asignment operator. | |
| P & | operator * () const |
| Dereference operator. | |
| P * | operator-> () const |
| The arrow operator. | |
| bool | operator== (const CdbCPtr< P, CLOSE_POLICY > &thePtr) const |
| The comparision operator. | |
| bool | operator!= (const CdbCPtr< P, CLOSE_POLICY > &thePtr) const |
| The not-equal operator. | |
| bool | operator== (const P *ptr) const |
| The comparision operator. | |
| bool | operator!= (const P *ptr) const |
| The not-equal operator. | |
| bool | isNull () const |
| Explicit check if the pointer does point onto 0. | |
| P * | get () const |
| Return a non-const pointer to the pointed object. | |
| bool | unique () const |
| Check if this smart pointer is the only clients of the held pointer. | |
The is a non-intrusive implementation that allocates an additional int and pointer for every counted object.
The close policy is provided through an additional policy class. The only method we expect from the policy class is:
static void CLOSE_POLICY::close( P* ptr );
It's up to the developer of this class how it will interract with the pointee object in order to "close" its instances.
By default, the "CdbDoNotClosePolicy" policy class will be used.
Definition at line 33 of file CdbCPtr.hh.
|
|||||
|
This is the type of the close policy. The concrete type will be available at the instantiation of the current template class. Definition at line 49 of file CdbCPtr.hh. |
|
|||||
|
This is the type of objects pointed through this smart pointer. The concrete type will be available at the instantiation of the current template class. Definition at line 42 of file CdbCPtr.hh. |
|
||||||||||
|
The constructor. This is the normal and default constructor. It will take the ownership of specified pointer and initialize the internal counter to 1 if a non-null pointer is passed. Definition at line 18 of file CdbCPtr.cc. |
|
||||||||||
|
The copy constructor. This constructor initializes the current instance to share the counter object with the specified pointer. This will also increment by 1 the number of smart pointers pointing onto the poentee, if this is not a 0 pointer. Definition at line 31 of file CdbCPtr.cc. References CdbCPtr< P, CLOSE_POLICY >::_myCounter. |
|
|||||||||
|
The destructor. Decrement the number of clients for the pointee. If we're the last smart pointer then:
Definition at line 25 of file CdbCPtr.cc. |
|
|||||||||
|
Return a non-const pointer to the pointed object. Note, that this does not transfer the ownership over the pointed object. Definition at line 108 of file CdbCPtr.cc. Referenced by CdbTranslatorsDict::add(), main(), CdbRooDb::storeObject(), and CdbRooRoVectorCollection_SmartPointerPolicy< T >::to_plain_pointer(). |
|
|||||||||
|
|||||||||
|
Dereference operator. Return a reference to the pointed object. Here is a trivial example on how to use this operator:
// This is a simple class whose objects will be // pointed through the smart pointer. class A ... { public: void foo( ); }; // Initialize smart pointer to point onto a new object. // Remember, that the smart pointer will take ownership // over this object. CdbCPtr<A,SomePolicy> aPtr( new A( )); // Do something usefull (*Aptr).foo( ); // Definition at line 58 of file CdbCPtr.cc. |
|
||||||||||
|
The not-equal operator.
Definition at line 94 of file CdbCPtr.cc. References CdbCPtr< P, CLOSE_POLICY >::operator==(). |
|
||||||||||
|
The not-equal operator.
Definition at line 80 of file CdbCPtr.cc. References CdbCPtr< P, CLOSE_POLICY >::operator==(). |
|
|||||||||
|
The arrow operator. This operator is meant to provide access to the members of the pointed object in the same way if it were the regular pointer. Here is a trivial example on how to use this operator:
// This is a simple class whose objects will be // pointed through the smart pointer. class A ... { public: void foo( ); }; // Initialize smart pointer to point onto a new object. // Remember, that the smart pointer will take ownership // over this object. CdbCPtr<A,SomePolicy> aPtr( new A( )); // Do something usefull APtr->foo( ); // Definition at line 65 of file CdbCPtr.cc. |
|
||||||||||
|
Asignment operator. Drop the currently hold pointee. And take ownership ower the specified pointee object. Set the total number of its clients to 1. Definition at line 49 of file CdbCPtr.cc. |
|
||||||||||
|
Asignment operator. Drop the currently hold pointee. And borrow the counter object from the right-hand smart pointer object and increment by 1the number of clients for the pointee object (if this is not the 0). Definition at line 38 of file CdbCPtr.cc. References CdbCPtr< P, CLOSE_POLICY >::_myCounter. |
|
||||||||||
|
The comparision operator. This operator will compare a smart pointer with a regular pointer to see if the smart one points to the same object as the regular one. It will also return true if both pointers are pointinig to 0. Note, that the primarily use of this operator is to check if the smart pointer is pointing to 0. The other cases should not be possible because smart pointer must be the only way to point objects. It's also important to note, that because of the restricted syntax of the comparision operator in the class's scope, it's only possible to specify the regular pointer on the righ-hand side of the comparision as it's shown in a code example below. The reverse order can be added later for concrete instantiations of the smart pointer. An example:
// Initialize a smart pointer to a real object of class A. CdbCPtr<A,...> aSomePtr( new A( )); A* ptr = ...; // Compare this pointer with specified pointer. if( aSomePtr == ptr ) { ... }
Definition at line 87 of file CdbCPtr.cc. |
|
||||||||||
|
The comparision operator. This operator will compare two smart pointers if they both point onto the same object. It will also return true if both smart pointers are pointinig to 0. An example:
// Initialize two smart pointers in different ways: the first one // will point to 0, and the second one - to a real object of class A. CdbCPtr<A,...> aNullPtr; CdbCPtr<A,...> aSomePtr( new A( )); // Compare the pointers if( aSomePtr == aNullPtr ) { ... }
Definition at line 72 of file CdbCPtr.cc. References CdbCPtr< P, CLOSE_POLICY >::_myCounter. Referenced by CdbCPtr< P, CLOSE_POLICY >::isNull(), and CdbCPtr< P, CLOSE_POLICY >::operator!=(). |
|
|||||||||
|
Check if this smart pointer is the only clients of the held pointer.
Definition at line 115 of file CdbCPtr.cc. |
1.3-rc3