|
AVPKit
|
This class is only useful from C++. More...
#include <RefPointer.h>

Public Member Functions | |
| RefPointer () | |
| Default constructor; sets the managed pointer to 0. | |
| RefPointer (T *ptr) | |
| Construct a RefPointer from a RefCounted object, and take over management of the ref-count this pointer had. More... | |
| RefPointer (const RefPointer &rPtr) | |
| Copy another RefPointer object. More... | |
| RefPointer (RefPointer &rPtr) | |
| Copy and acquire. More... | |
| RefPointer & | operator= (const RefPointer &rPtr) |
| Assignment operator to copy another ref pointer. More... | |
| RefPointer & | operator= (RefPointer &rPtr) |
| Assignment operator to copy another ref pointer. More... | |
| RefPointer & | operator= (T *ptr) |
| Assignment from a RefCounted* where we take over ownership of the refcount. More... | |
| T * | operator-> () const |
| Allow people to def-ref the RefPointer() without RefCounted::acquire() the managed pointer. More... | |
| operator bool () | |
This convenience method allows the use of the following code to determine if the underlying pointer is null or not: RefPointer<Foo> p(someObj); if (p) { // underlying pointer is valid p->DoSomething(); } More... | |
| virtual | ~RefPointer () |
| Always release the ref-count of our underlying pointer. | |
| T * | get () |
| Call RefCounted::acquire() on the managed pointer and return it. More... | |
| T * | value () |
| Return the managed pointer without calling RefCounted::acquire() on it. More... | |
| void | reset (T *ptr=0, bool acquire=false) |
| Reset the managed pointer, calling RefCounted::release() on the previously managed pointer first. More... | |
This class is only useful from C++.
If you pass a RefCounted pointer to a RefPointer it assumes you want it to manage the ref-count associated with the RefCounted pointer.
That means, whenever the RefPointer is destroyed, it will RefCounted::release() the pointer it was asked to manage. It will not call acquire() on the pointer for it's own use, but will RefCounted::acquire() it if someone calls get() for the caller to manage.
This can be a handy way to make sure RefCounted::acquire() is called for you in order to reduce the chance of leaking memory from C++ code.
Definition at line 46 of file RefPointer.h.
|
inline |
Construct a RefPointer from a RefCounted object, and take over management of the ref-count this pointer had.
(i.e. it does not RefCounted::acquire() the pointer, but instead assumes it is now the owner. The person who called this method should not call RefCounted::release() on the passed in pointer once this object is managing it).
| ptr | The pointer to start managing. |
Definition at line 67 of file RefPointer.h.
|
inline |
Copy another RefPointer object.
Since the other RefPointer object will RefCounted::release() its ref-count upon destruction, we RefCounted::acquire() the pointer for ourselves.
| rPtr | The pointer to RefCounted::acquire() a reference from |
Definition at line 80 of file RefPointer.h.
|
inline |
Copy and acquire.
| rPtr | The pointer to RefCounted::acquire() a reference from |
Definition at line 90 of file RefPointer.h.
|
inline |
Call RefCounted::acquire() on the managed pointer and return it.
Definition at line 206 of file RefPointer.h.
Referenced by com::avpkit::core::Container::addNewStream(), com::avpkit::core::VideoPicture::getData(), and com::avpkit::core::MediaDataWrapper::unwrap().
|
inline |
This convenience method allows the use of the following code to determine if the underlying pointer is null or not: RefPointer<Foo> p(someObj); if (p) { // underlying pointer is valid p->DoSomething(); }
Definition at line 173 of file RefPointer.h.
|
inline |
Allow people to def-ref the RefPointer() without RefCounted::acquire() the managed pointer.
To avoid the cost of a run-time check, we DON'T check for nullness of the managed pointer.
Definition at line 153 of file RefPointer.h.
|
inline |
Assignment operator to copy another ref pointer.
We RefCounted::acquire() since the other side will RefCounted::release() it's own ref-count later.
| rPtr | The pointer to assign from |
Definition at line 102 of file RefPointer.h.
References com::avpkit::ferry::RefPointer< T >::reset().
|
inline |
Assignment operator to copy another ref pointer.
We RefCounted::acquire() since the other side will RefCounted::release() it's own ref-count later.
| rPtr | The pointer to assign from |
Definition at line 116 of file RefPointer.h.
References com::avpkit::ferry::RefPointer< T >::reset().
|
inline |
Assignment from a RefCounted* where we take over ownership of the refcount.
This is a pretty handy way of doing: RefPointer<foo> = Obj->getFoo(); Since by convention getFoo() functions should RefCounted::acquire() the returned value for the caller, this ensures you don't accidentally leak a value.
| ptr | The pointer to take over management of |
Definition at line 138 of file RefPointer.h.
References com::avpkit::ferry::RefPointer< T >::reset().
|
inline |
Reset the managed pointer, calling RefCounted::release() on the previously managed pointer first.
| ptr | The new value to manage. |
| acquire | should we also acquire a reference? defaults to no (i.e. we take don't call RefCounted::acquire() to take over). |
Definition at line 237 of file RefPointer.h.
Referenced by com::avpkit::core::StreamCoder::encodeAudio(), com::avpkit::core::VideoPicture::make(), com::avpkit::ferry::RefPointer< T >::operator=(), and com::avpkit::core::VideoPicture::setData().
|
inline |
Return the managed pointer without calling RefCounted::acquire() on it.
This is how you pass values to methods expecting a RefCounted*
void someMethod(RefCounted* arg); RefPointer<RefCounted> b = ....; someMethod(b.value());
Definition at line 226 of file RefPointer.h.
Referenced by com::avpkit::core::Container::addNewStream(), com::avpkit::core::StreamCoder::decodeAudio(), com::avpkit::core::StreamCoder::decodeVideo(), com::avpkit::core::StreamCoder::encodeAudio(), com::avpkit::core::StreamCoder::encodeVideo(), com::avpkit::core::Container::readNextPacket(), com::avpkit::core::Stream::stampOutputPacket(), com::avpkit::core::MediaDataWrapper::unwrap(), com::avpkit::core::MediaDataWrapper::wrap(), and com::avpkit::core::Container::writePacket().