template<class _elementType>
class mtsGenericObjectProxyBase< _elementType >
Proxy class used to create a simple mtsGenericObject, i.e. data object with a registered type, dynamic creation, serialization and de-serialization. Note that there are really three classes defined here: mtsGenericObjectProxyBase, mtsGenericObjectProxy, and mtsGenericObjectProxyRef (henceforth called ProxyBase, Proxy, and ProxyRef for brevity). ProxyBase provides a common base class. Proxy contains one data member of the actual type provided as the template parameter. ProxyRef contains a pointer to a data member of the actual type provided as the template parameter.
ProxyRef is used internally by the library to enable arbitrary data types T (not just ones derived from mtsGenericObject) to be added to the State Table. In this case, the StateVector (State Table history) will be an array of Proxy<T> and the StateVectorElements (pointers to working copy) will be of type ProxyRef<T>.
To create an mtsGenericObject from an existing type, one would have to specialize mtsGenericObjectProxy as follows in the header file (it is not necessary to worry about the ProxyBase or ProxyRef – these are handled automatically):
It is also required to instantiate the associated services in the compiled code (.cpp) file with:
- Note
- It is really important to note that this simple way of creating mtsGenericObject derived classes works as is for classes which can be serialized as a memory block, i.e. native types, compact structs, ... For classes which require a more complex way to serialize and deserialize, the user will also have to overload the functions cmnSerializeRaw and cmnDeSerializeRaw.
-
As it is, this class cannot be used in libraries other than cisstCommon if a DLL is to be created. The issue is that the class will be declared as imported in the header file because it is part of cisstCommon. (PK: OBSOLETE COMMENT?)
-
There are some "dirty tricks" in this class now, so that we can have a Proxy class and a ProxyRef class, and enable assignments between them. This provides a bit of polymorphic behavior for the command objects, because the Execute method can be parameterized as a ProxyBase object, and thus can be called with either a Proxy or ProxyRef object. This is used for "read from state" commands. One particularly dirty trick is that the class services are actually defined in the Proxy class, but are "stolen" by the ProxyRef class, via the ProxyBase class.
- See Also
- mtsGenericObject, cmnClassServices, cmnSerializer, cmnDeSerializer
- Parameters
-
_elementType | The actual type for which we want to provide a proxy object. |