class O2G2Ptr(T)
Brief
Auto-release template class
Parameters | |
T |
The class name. The class must be derived from |
Details
The class is designed to release an instance of the specified class automatically, when the scope (for example function) is finished or when containing class is destroyed.
You may use this class instead of pointer to class T to be sure that an instance referenced will be released properly.
Using IAddRef-derived class without O2G2Ptr template [hide]
{ IO2GResponseReaderFactory *factory = mSession->getResponseReaderFactory(); if (factory) { IO2GOrderResponseReader *reader = factory->createOrderResponseReader(response); if (reader == 0) { factory->release(); return; } // use reader ... reader->release(); } factory->release(); }
Using IAddRef-derived class with O2G2Ptr template [hide]
{ O2G2Ptr<IO2GResponseReaderFactory> factory = mSession->getResponseReaderFactory(); if (factory) { O2G2Ptr<IO2GOrderResponseReader> reader = factory->createOrderResponseReader(response); if (reader == 0) return; // use reader ... } }
Public Constructors | |
Parameterized constructor |
|
Copying constructor |
Public Methods | |
Destructor |
|
Detaches the contained object. |
|
Returns true if the pointer contained is null. |
|
Returns true if the pointer contained is equal to the pointer specified. |
|
Member operator. |
|
Returns true if the pointer contained is not null. |
|
Gets the pointer to contained object. |