#include <core.hpp>
List of all members.
Detailed Description
template<typename _Tp>
class cv::Ptr< _Tp >
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:
- Note:
- {if MyObjectType is a C++ class with a destructor, you do not need to specialize delete_obj(), since the default implementation calls "delete obj;"}
-
{Another good property of the class is that the operations on the reference counter are atomic, i.e. it is safe to use the class in multi-threaded applications}
Constructor & Destructor Documentation
take ownership of the pointer. The associated reference counter is allocated and set to 1
copy constructor. Copies the members and calls addref()
Member Function Documentation
template<typename _Tp >
void cv::Ptr< _Tp >::addref |
( |
) |
[inline] |
increments the reference counter
template<typename _Tp >
void cv::Ptr< _Tp >::delete_obj |
( |
) |
[inline] |
deletes the object. Override if needed
template<typename _Tp >
bool cv::Ptr< _Tp >::empty |
( |
) |
const [inline] |
returns true iff obj==NULL
template<typename _Tp >
cv::Ptr< _Tp >::operator _Tp * |
( |
) |
[inline] |
template<typename _Tp >
cv::Ptr< _Tp >::operator const _Tp * |
( |
) |
const [inline] |
template<typename _Tp >
_Tp * cv::Ptr< _Tp >::operator-> |
( |
) |
[inline] |
helper operators making "Ptr<T> ptr" use very similar to "T* ptr".
template<typename _Tp >
const _Tp * cv::Ptr< _Tp >::operator-> |
( |
) |
const [inline] |
template<typename _Tp >
Ptr< _Tp > & cv::Ptr< _Tp >::operator= |
( |
const Ptr< _Tp > & |
ptr ) |
[inline] |
copy operator. Calls ptr.addref() and release() before copying the members
template<typename _Tp >
void cv::Ptr< _Tp >::release |
( |
) |
[inline] |
decrements the reference counter. If it reaches 0, delete_obj() is called
Member Data Documentation
The documentation for this class was generated from the following files:
- /usr/obj/OpenCV-2.2.0/OpenCV-2.2.0/modules/core/include/opencv2/core/core.hpp
- /usr/obj/OpenCV-2.2.0/OpenCV-2.2.0/modules/core/include/opencv2/core/operations.hpp