stub_analytics_plugin
1.6
Network Optix Video Analytics SDK
|
#include <i_ref_countable.h>
Classes | |
struct | InterfaceId |
Public Member Functions | |
virtual | ~IRefCountable ()=default |
virtual IRefCountable * | queryInterface (InterfaceId id) |
const IRefCountable * | queryInterface (InterfaceId id) const |
template<class Interface > | |
Interface * | queryInterface () |
template<class Interface > | |
const Interface * | queryInterface () const |
virtual int | addRef () const =0 |
virtual int | releaseRef () const =0 |
Static Public Member Functions | |
static auto | interfaceId () |
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.
|
virtualdefault |
VMT #0.
|
pure virtual |
VMT #2.
|
inlinestatic |
Each derived interface is expected to implement such static method with its own string.
|
inlinevirtual |
VMT #1.
|
pure virtual |
VMT #3.