Each entity within the interoperable context of SmartCGMS also implements the refcnt::IReferenced
interface. This interface is a custom variant of a standard
IUnknown
interface, which is a basic interface of a COM (Component Object Model). The SmartCGMS architecture follows the COM model and expects the entities to
behave in such way. If the developer develops the component using the C++ language, most of the COM-related functionality can be achieved by a proper inheritance of SDK classes).
SmartCGMS SDK offer the interface definition and partial implementation within the refcnt
namespace:
refcnt::IReferenced
- the base interface, usually known as IUnknown
; defines three methods (and also the following vtable layout):
QueryInterface
- a method used to ask the component, if it supports the requested interfaceAddRef
- increments the object reference countRelease
- decrements the object reference count; if the count reaches zero, the object gets deallocatedrefcnt::CReferenced
- base implementation of an object, which should maintain reference counting (AddRef
and Release
changes the value of
the reference count attribute)
refcnt::CNot_Referenced
- base implementation of an object, which does not participate in a reference-counted context, i.e. something else manages the object lifetimerefcnt::IReferenced
interface, or inherit from either refcnt::CReferenced
or refcnt::CNot_Referenced
SDK implementation.
The following figure depicts the possible class diagram of a custom filter:
Though it is much more convenient to use the intermediate class scgms::CBase_Filter
, also present in SDK:
Throughout the SmartCGMS, reference-counted vectors are often used. A common interface refcnt::IVector_Container
is defined in the SDK. This interface defines a set of methods:
set
- sets the content of this container to a given range (begin
to end
)add
- adds a range of elementsget
- retrieves the range of contained elementspop
- removes and returns exactly one element from the containerremove
- removes one given item from the containermove
- moves the element of the container from source index to destination indexempty
- determines, if the container is emptystd::vector
complies with given requirements. The SmartCGMS SDK offers the generic refcnt::CVector_Container
implementation and its variants.
Each object implementing the refcnt::IReferenced
interface is required to implement the QueryInterface
method. This method is used to declare support for
a GUID-identified interface. If the interface is supported, the QueryInterface
method sets typecasted this pointer to the interface and S_OK
. Otherwise, it returns
E_NOINTERFACE
.
This is often used to support entity inspection interfaces.