#include <core.hpp>
Public Member Functions | |
Ptr () | |
empty constructor More... | |
Ptr (_Tp *_obj) | |
take ownership of the pointer. The associated reference counter is allocated and set to 1 More... | |
~Ptr () | |
calls release() More... | |
Ptr (const Ptr &ptr) | |
copy constructor. Copies the members and calls addref() More... | |
template<typename _Tp2 > | |
Ptr (const Ptr< _Tp2 > &ptr) | |
Ptr & | operator= (const Ptr &ptr) |
copy operator. Calls ptr.addref() and release() before copying the members More... | |
void | addref () |
increments the reference counter More... | |
void | release () |
decrements the reference counter. If it reaches 0, delete_obj() is called More... | |
void | delete_obj () |
deletes the object. Override if needed More... | |
bool | empty () const |
returns true iff obj==NULL More... | |
template<typename _Tp2 > | |
Ptr< _Tp2 > | ptr () |
cast pointer to another type More... | |
template<typename _Tp2 > | |
const Ptr< _Tp2 > | ptr () const |
_Tp * | operator-> () |
helper operators making "Ptr<T> ptr" use very similar to "T* ptr". More... | |
const _Tp * | operator-> () const |
operator _Tp * () | |
operator const _Tp * () const | |
template<> | |
void | delete_obj () |
template<> | |
void | delete_obj () |
template<> | |
void | delete_obj () |
template<> | |
void | delete_obj () |
template<> | |
void | delete_obj () |
template<> | |
void | delete_obj () |
template<> | |
void | delete_obj () |
template<> | |
void | delete_obj () |
template<> | |
void | delete_obj () |
template<> | |
void | delete_obj () |
template<> | |
void | delete_obj () |
template<> | |
void | delete_obj () |
template<> | |
void | delete_obj () |
template<> | |
void | delete_obj () |
template<> | |
void | delete_obj () |
template<> | |
void | delete_obj () |
template<> | |
void | delete_obj () |
Public Attributes | |
_Tp * | obj |
int * | refcount |
Smart pointer to dynamically allocated objects.
This is template pointer-wrapping class that stores the associated reference counter along with the object pointer. The class is similar to std::smart_ptr<> from the recent addons to the C++ standard, but is shorter to write :) and self-contained (i.e. does add any dependency on the compiler or an external library).
Basically, you can use "Ptr<MyObjectType> ptr" (or faster "const Ptr<MyObjectType>& ptr" for read-only access) everywhere instead of "MyObjectType* ptr", where MyObjectType is some C structure or a C++ class. To make it all work, you need to specialize Ptr<>::delete_obj(), like:
take ownership of the pointer. The associated reference counter is allocated and set to 1
copy constructor. Copies the members and calls addref()
void cv::Ptr< CvVideoWriter >::delete_obj | ( | ) |
void cv::Ptr< CvHaarClassifierCascade >::delete_obj | ( | ) |
void cv::Ptr< IplConvKernel >::delete_obj | ( | ) |
void cv::Ptr< CvStereoBMState >::delete_obj | ( | ) |
void cv::Ptr< CvHistogram >::delete_obj | ( | ) |
deletes the object. Override if needed
void cv::Ptr< CvDTreeSplit >::delete_obj | ( | ) |
void cv::Ptr< CvSparseMat >::delete_obj | ( | ) |
void cv::Ptr< CvMemStorage >::delete_obj | ( | ) |
void cv::Ptr< CvFileStorage >::delete_obj | ( | ) |
|
inline |
returns true iff obj==NULL
|
inline |
|
inline |
|
inline |
helper operators making "Ptr<T> ptr" use very similar to "T* ptr".
|
inline |
copy operator. Calls ptr.addref() and release() before copying the members
cast pointer to another type
|
inline |
decrements the reference counter. If it reaches 0, delete_obj() is called
_Tp* cv::Ptr< _Tp >::obj |