ERC CISST - cisst software

mtsGenericObjectProxyBase< _elementType > Class Template Reference

#include <mtsGenericObjectProxy.h>

Inheritance diagram for mtsGenericObjectProxyBase< _elementType >:

Inheritance graph
[legend]
Collaboration diagram for mtsGenericObjectProxyBase< _elementType >:

Collaboration graph
[legend]
List of all members.

Detailed Description

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):

  class UserType {
      ....
  };

  typedef mtsGenericObjectProxy<UserType> UserTypeProxy;
  CMN_DECLARE_SERVICES_INSTANTIATION(UserTypeProxy);

It is also required to instantiate the associated services in the compiled code (.cpp) file with:

  CMN_IMPLEMENT_SERVICES_TEMPLATED(UserTypeProxy);

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.

Definition at line 199 of file mtsGenericObjectProxy.h.

Public Types

Public Member Functions

Static Public Member Functions


Constructor & Destructor Documentation

template<class _elementType>
mtsGenericObjectProxyBase< _elementType >::mtsGenericObjectProxyBase ( void   )  [inline]

Default constructor. The data member is initialized using its default constructor.

Definition at line 223 of file mtsGenericObjectProxy.h.

template<class _elementType>
mtsGenericObjectProxyBase< _elementType >::mtsGenericObjectProxyBase ( const ThisType other  )  [inline]

Copy constructor.

Definition at line 227 of file mtsGenericObjectProxy.h.


Member Function Documentation

template<class _elementType>
virtual const cmnClassServicesBase* mtsGenericObjectProxyBase< _elementType >::Services ( void   )  const [inline, virtual]

Pure virtual method to access the class services. The derived classes should always declare and implement this method using the macros CMN_DECLARE_SERVICES, CMN_DECLARE_SERVICES_INSTANTIATION and CMN_IMPLEMENT_SERVICES. In NO WAY, a user should redefine/overload this method otherwise.

Returns:
A pointer on the class services. This points to the unique instance of cmnClassServiceBase for a given class.
See also:
cmnClassRegister cmnClassServiceBase

Implements cmnGenericObject.

Definition at line 216 of file mtsGenericObjectProxy.h.

References mtsGenericObjectProxyBase< _elementType >::ClassServices().

template<class _elementType>
virtual value_type& mtsGenericObjectProxyBase< _elementType >::GetData ( void   )  [pure virtual]

Return pointer to data

Referenced by mtsGenericObjectProxyBase< _elementType >::Assign(), and mtsGenericTypesImpl< T, >::CastArg().

template<class _elementType>
ThisType& mtsGenericObjectProxyBase< _elementType >::operator= ( const ThisType data  )  [inline]

Conversion assignment.

Definition at line 238 of file mtsGenericObjectProxy.h.

References mtsGenericObjectProxyBase< _elementType >::Assign().


The documentation for this class was generated from the following file:
erc-cisst-devel<at>lists.johnshopkins.edu