stub_analytics_plugin  1.6
Network Optix Video Analytics SDK
Public Member Functions | List of all members
nxpt::ScopedRef< T > Class Template Reference

#include <plugin_tools.h>

Public Member Functions

 ScopedRef (void *ptr)
 
 ScopedRef (T *ptr=nullptr, bool increaseRef=true)
 
 ScopedRef (ScopedRef< T > &&right)
 
ScopedRef< T > & operator= (ScopedRef< T > &&right)
 
 ScopedRef (const ScopedRef< T > &)=delete
 
ScopedRef< T > & operator= (const ScopedRef< T > &)=delete
 
 operator bool () const
 
T * get ()
 
const T * get () const
 
T * operator-> ()
 
const T * operator-> () const
 
T * release ()
 
void reset (T *ptr=nullptr)
 

Detailed Description

template<class T>
class nxpt::ScopedRef< T >

Automatic scoped pointer class which uses PluginInterface reference counting interface (PluginInterface::addRef() and PluginInterface::releaseRef()) instead of new/delete. Increments object's reference counter (PluginInterface::addRef()) at construction, decrements at destruction (PluginInterface::releaseRef()).

NOTE: The class is reentrant, but not thread-safe.

Parameters
TMust inherit PluginInterface.

Constructor & Destructor Documentation

◆ ScopedRef() [1/2]

template<class T >
nxpt::ScopedRef< T >::ScopedRef ( void *  ptr)
inlineexplicit

Intended to be applied to queryInterface().

◆ ScopedRef() [2/2]

template<class T >
nxpt::ScopedRef< T >::ScopedRef ( T *  ptr = nullptr,
bool  increaseRef = true 
)
inlineexplicit

Calls ptr->addRef() if ptr is not null and increaseRef is true.

Member Function Documentation

◆ get() [1/2]

template<class T >
T* nxpt::ScopedRef< T >::get ( )
inline
Returns
Protected pointer, without releasing it.

◆ get() [2/2]

template<class T >
const T* nxpt::ScopedRef< T >::get ( ) const
inline
Returns
Protected pointer, without releasing it.

◆ release()

template<class T >
T* nxpt::ScopedRef< T >::release ( )
inline

Releases protected pointer without calling nxpl::PluginInterface::releaseRef().

◆ reset()

template<class T >
void nxpt::ScopedRef< T >::reset ( T *  ptr = nullptr)
inline

Calls nxpl::PluginInterface::releaseRef() on protected pointer (if any) and takes the new pointer ptr (calling nxpl::PluginInterface::addRef()).


The documentation for this class was generated from the following file: