stub_analytics_plugin  1.6
Network Optix Video Analytics SDK
Classes | Public Member Functions | Static Public Member Functions | List of all members
nx::sdk::IRefCountable Class Referenceabstract

#include <i_ref_countable.h>

Inheritance diagram for nx::sdk::IRefCountable:
nx::sdk::Interface< IAction > nx::sdk::Interface< IDataPacket > nx::sdk::Interface< IDeviceAgent > nx::sdk::Interface< IDeviceInfo > nx::sdk::Interface< IEngine > nx::sdk::Interface< IEngineInfo > nx::sdk::Interface< IMediaContext > nx::sdk::Interface< IMetadata > nx::sdk::Interface< IMetadataTypes > nx::sdk::Interface< IPlugin > nx::sdk::Interface< IPluginEvent > nx::sdk::Interface< IString > nx::sdk::Interface< IStringMap > nx::sdk::Interface< IUtilityProvider >

Classes

struct  InterfaceId
 

Public Member Functions

virtual ~IRefCountable ()=default
 
virtual IRefCountablequeryInterface (InterfaceId id)
 
const IRefCountablequeryInterface (InterfaceId id) const
 
template<class Interface >
InterfacequeryInterface ()
 
template<class Interface >
const InterfacequeryInterface () const
 
virtual int addRef () const =0
 
virtual int releaseRef () const =0
 

Static Public Member Functions

static auto interfaceId ()
 

Detailed Description

Base for all interfaces - abstract classes with only pure-virtual non-overloaded functions, so that an object implementing an interface can be passed by pointer between dynamic libraries compiled using potentially different compilers and their standard libraries. Such abstraction is needed to enable plugins. It is somewhat similar to Microsoft Component Object Model (COM).

Interface methods are allowed to use only C-style input and output types (without STL classes), because on each side of a dynamic library different implementations/versions of STL can be used. The only ABI aspect interfaces rely upon - size of pointer (64-bit) and order of methods in VMT (in the order of declaration, base class methods first). Overloaded methods are not allowed because their order in VMS can be different across compilers. Also dynamic_cast can not be used for such objects, because data structures behind the VMT can be different across compilers.

Interfaces may contain type definitions and non-virtual inline utility methods (they will be compiled by each side independently).

Each object implementing an interface should have an internal reference counter, which, when decremented to zero, triggers object deletion.

To provide dynamic-cast-like behavior, and more generally, the ability to yield objects implementing other interfaces (not necessarily the same object as the one being queried), each object must implement queryInterface() that takes an interface identifier (value) and returns a pointer to the object implementing the requested interface.

General rules for passing objects with reference counting:

NOTE: For binary compatibility with old plugins, the VMT layout of this interface (4 entries - destructor, queryInterface(), addRef(), releaseRef()) should not change, as well as the binary prototypes (arguments and return values) of its entries.

Constructor & Destructor Documentation

◆ ~IRefCountable()

virtual nx::sdk::IRefCountable::~IRefCountable ( )
virtualdefault

VMT #0.

Member Function Documentation

◆ addRef()

virtual int nx::sdk::IRefCountable::addRef ( ) const
pure virtual

VMT #2.

Returns
New reference count.

◆ interfaceId()

static auto nx::sdk::IRefCountable::interfaceId ( )
inlinestatic

Each derived interface is expected to implement such static method with its own string.

◆ queryInterface()

virtual IRefCountable* nx::sdk::IRefCountable::queryInterface ( InterfaceId  id)
inlinevirtual

VMT #1.

Returns
Object that requires releaseRef() by the caller when it no longer needs it, or null if the requested interface is not implemented.

◆ releaseRef()

virtual int nx::sdk::IRefCountable::releaseRef ( ) const
pure virtual

VMT #3.

Returns
New reference count, having deleted the object if it reaches zero.

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