cisst-saw
Loading...
Searching...
No Matches
cmnGenericObjectProxy< _elementType > Class Template Reference

#include <cmnGenericObjectProxy.h>

Inheritance diagram for cmnGenericObjectProxy< _elementType >:
cmnGenericObject

Public Types

typedef cmnGenericObjectProxy< _elementType > ThisType
typedef _elementType value_type

Public Member Functions

 cmnGenericObjectProxy (void)
 cmnGenericObjectProxy (const value_type &data)
 ~cmnGenericObjectProxy (void)
ThisTypeoperator= (value_type data)
 operator value_type & (void)
 operator const value_type & (void) const
void SerializeRaw (std::ostream &outputStream) const override
void DeSerializeRaw (std::istream &inputStream) override
void ToStream (std::ostream &outputStream) const override
void ToStreamRaw (std::ostream &outputStream, const char CMN_UNUSED(delimiter)=' ', bool headerOnly=false, const std::string &headerPrefix="") const override
bool FromStreamRaw (std::istream &inputStream, const char CMN_UNUSED(delimiter)=' ') override
Public Member Functions inherited from cmnGenericObject
virtual ~cmnGenericObject (void)
virtual const cmnClassServicesBaseServices (void) const =0
bool ReconstructFrom (const cmnGenericObject &other)
std::string ToString (void) 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 cmnLogger::StreamBufTypeGetLogMultiplexer (void) const
virtual size_t ScalarNumber (void) const
virtual bool ScalarNumberIsFixed (void) const
virtual double Scalar (const size_t CMN_UNUSED(index)) const CISST_THROW(std
virtual std::string ScalarDescription (const size_t CMN_UNUSED(index), const std::string &CMN_UNUSED(userDescription)) const

Public Attributes

value_type Data

Detailed Description

template<class _elementType>
class cmnGenericObjectProxy< _elementType >

Proxy class used to create a simple cmnGenericObject, i.e. data object with a registered type, dynamic creation, serialization and de-serialization. The proxy object contains one data member of the actual type provided as a template parameter.

For example, to create a cmnGenericObject from an existing type, one would have to specialize cmnGenericObjectProxy as follows in the header file:

class UserType {
....
};
typedef cmnGenericObjectProxy<UserType> UserTypeProxy;
Definition cmnGenericObjectProxy.h:72
#define CMN_DECLARE_SERVICES_INSTANTIATION(className)
Definition cmnClassRegisterMacros.h:199

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

#define CMN_IMPLEMENT_SERVICES_TEMPLATED(className)
Definition cmnClassRegisterMacros.h:297
Note
It is really important to note that this simple way of creating cmnGenericObject 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 can not 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.
See also
cmnGenericObject, cmnClassServices, cmnSerializer, cmnDeSerializer
Parameters
_elementTypeThe actual type for which we want to provide a proxy object.

Member Typedef Documentation

◆ ThisType

template<class _elementType>
typedef cmnGenericObjectProxy<_elementType> cmnGenericObjectProxy< _elementType >::ThisType

◆ value_type

template<class _elementType>
typedef _elementType cmnGenericObjectProxy< _elementType >::value_type

Constructor & Destructor Documentation

◆ cmnGenericObjectProxy() [1/2]

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

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

◆ cmnGenericObjectProxy() [2/2]

template<class _elementType>
cmnGenericObjectProxy< _elementType >::cmnGenericObjectProxy ( const value_type & data)
inline

Conversion constructor. This allows to construct the proxy object using an object of the actual type.

◆ ~cmnGenericObjectProxy()

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

Member Function Documentation

◆ DeSerializeRaw()

template<class _elementType>
void cmnGenericObjectProxy< _elementType >::DeSerializeRaw ( std::istream & inputStream)
inlineoverridevirtual

DeSerialization. Relies on the specialization, if any, of cmnDeSerializeRaw.

Reimplemented from cmnGenericObject.

◆ FromStreamRaw()

template<class _elementType>
bool cmnGenericObjectProxy< _elementType >::FromStreamRaw ( std::istream & inputStream,
const char CMN_UNUSEDdelimiter = ' ' )
inlineoverride

From stream raw data.

◆ operator const value_type &()

template<class _elementType>
cmnGenericObjectProxy< _elementType >::operator const value_type & ( void ) const
inline

◆ operator value_type &()

template<class _elementType>
cmnGenericObjectProxy< _elementType >::operator value_type & ( void )
inline

Cast operator. This allows to assign to an object of the actual type without explicitly referencing the public data member "Data".

◆ operator=()

template<class _elementType>
ThisType & cmnGenericObjectProxy< _elementType >::operator= ( value_type data)
inline

Conversion assignment. This allows to assign from an object of the actual type without explicitly referencing the public data member "Data".

◆ SerializeRaw()

template<class _elementType>
void cmnGenericObjectProxy< _elementType >::SerializeRaw ( std::ostream & outputStream) const
inlineoverridevirtual

Serialization. Relies on the specialization, if any, of cmnSerializeRaw.

Reimplemented from cmnGenericObject.

◆ ToStream()

template<class _elementType>
void cmnGenericObjectProxy< _elementType >::ToStream ( std::ostream & outputStream) const
inlineoverridevirtual

To stream method. Uses the default << operator as defined for the actual type.

Reimplemented from cmnGenericObject.

◆ ToStreamRaw()

template<class _elementType>
void cmnGenericObjectProxy< _elementType >::ToStreamRaw ( std::ostream & outputStream,
const char CMN_UNUSEDdelimiter = ' ',
bool headerOnly = false,
const std::string & headerPrefix = "" ) const
inlineoverride

To stream raw data.

Member Data Documentation

◆ Data

template<class _elementType>
value_type cmnGenericObjectProxy< _elementType >::Data

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