cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Static Public Member Functions | List of all members
mtsGenericObjectProxyBase< _elementType > Class Template Referenceabstract

#include <mtsGenericObjectProxy.h>

Inheritance diagram for mtsGenericObjectProxyBase< _elementType >:
mtsGenericObject cmnGenericObject mtsGenericObjectProxy< _elementType > mtsGenericObjectProxyRef< _elementType >

Public Types

enum  { HAS_DYNAMIC_CREATION = true }
 
enum  { InitialLoD = CMN_LOG_ALLOW_DEFAULT }
 
typedef
mtsGenericObjectProxyBase
< _elementType > 
ThisType
 
typedef mtsGenericObject BaseType
 
typedef mtsGenericObjectProxy
< _elementType > 
DeRefType
 
typedef
mtsGenericObjectProxyRef
< _elementType > 
RefType
 
typedef _elementType value_type
 

Public Member Functions

virtual const
cmnClassServicesBase
Services (void) const
 
 mtsGenericObjectProxyBase (void)
 
 mtsGenericObjectProxyBase (const ThisType &other)
 
 ~mtsGenericObjectProxyBase (void)
 
virtual value_typeGetData (void)=0
 
virtual const value_typeGetData (void) const =0
 
ThisTypeoperator= (const ThisType &data)
 
virtual void Assign (const ThisType &other)
 
- Public Member Functions inherited from mtsGenericObject
 mtsGenericObject (void)
 
 mtsGenericObject (double timestamp, bool automaticTimestamp, bool valid)
 
 mtsGenericObject (const mtsGenericObject &other)
 
virtual ~mtsGenericObject (void)
 
bool SetTimestampIfAutomatic (double timestamp)
 
virtual void ToStream (std::ostream &outputStream) const
 
virtual void ToStreamRaw (std::ostream &outputStream, const char delimiter= ' ', bool headerOnly=false, const std::string &headerPrefix="") const
 
virtual bool FromStreamRaw (std::istream &inputStream, const char delimiter= ' ')
 
virtual void SerializeRaw (std::ostream &outputStream) const
 
virtual void DeSerializeRaw (std::istream &inputStream)
 
size_t ScalarNumber (void) const
 
bool ScalarNumberIsFixed (void) const
 
double Scalar (const size_t index) const throw (std::out_of_range)
 
std::string ScalarDescription (const size_t index, const std::string &userDescription="") const throw (std::out_of_range)
 
- Public Member Functions inherited from cmnGenericObject
virtual ~cmnGenericObject (void)
 
bool ReconstructFrom (const cmnGenericObject &other)
 
std::string ToString (void) const
 
virtual cmnLogger::StreamBufTypeGetLogMultiplexer (void) const
 
virtual double Scalar (const size_t CMN_UNUSED(index)) const throw (std::out_of_range)
 
virtual std::string ScalarDescription (const size_t CMN_UNUSED(index), const std::string &CMN_UNUSED(userDescription)) const
 

Static Public Member Functions

static cmnClassServicesBaseClassServices (void)
 

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;

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
_elementTypeThe actual type for which we want to provide a proxy object.

Member Typedef Documentation

template<class _elementType>
typedef mtsGenericObject mtsGenericObjectProxyBase< _elementType >::BaseType
template<class _elementType>
typedef mtsGenericObjectProxy<_elementType> mtsGenericObjectProxyBase< _elementType >::DeRefType
template<class _elementType>
typedef mtsGenericObjectProxyRef<_elementType> mtsGenericObjectProxyBase< _elementType >::RefType
template<class _elementType>
typedef mtsGenericObjectProxyBase<_elementType> mtsGenericObjectProxyBase< _elementType >::ThisType
template<class _elementType>
typedef _elementType mtsGenericObjectProxyBase< _elementType >::value_type

Member Enumeration Documentation

template<class _elementType>
anonymous enum
Enumerator
HAS_DYNAMIC_CREATION 
template<class _elementType>
anonymous enum
Enumerator
InitialLoD 

Constructor & Destructor Documentation

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

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

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

Copy constructor.

template<class _elementType>
mtsGenericObjectProxyBase< _elementType >::~mtsGenericObjectProxyBase ( void  )
inline

Member Function Documentation

template<class _elementType>
virtual void mtsGenericObjectProxyBase< _elementType >::Assign ( const ThisType other)
inlinevirtual
template<class _elementType>
static cmnClassServicesBase* mtsGenericObjectProxyBase< _elementType >::ClassServices ( void  )
inlinestatic
template<class _elementType>
virtual value_type& mtsGenericObjectProxyBase< _elementType >::GetData ( void  )
pure virtual
template<class _elementType>
virtual const value_type& mtsGenericObjectProxyBase< _elementType >::GetData ( void  ) const
pure virtual
template<class _elementType>
ThisType& mtsGenericObjectProxyBase< _elementType >::operator= ( const ThisType data)
inline

Conversion assignment.

template<class _elementType>
virtual const cmnClassServicesBase* mtsGenericObjectProxyBase< _elementType >::Services ( void  ) const
inlinevirtual

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.


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