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

#include <cmnDataFunctions.h>

Public Types

enum  { IS_SPECIALIZED = 0 }
typedef _elementType DataType

Public Member Functions

void CISST_EXPORT Copy (mtsGenericObject &data, const mtsGenericObject &source)
void CISST_EXPORT SerializeBinary (const mtsGenericObject &data, std::ostream &outputStream) CISST_THROW(std void CISST_EXPORT cmnData< mtsGenericObject >::DeSerializeBinary(mtsGenericObject &data, std::istream &inputStream, const cmnDataFormat &localFormat, const cmnDataFormat &remoteFormat) CISST_THROW(std void CISST_EXPORT cmnData< mtsGenericObject >::SerializeText(const mtsGenericObject &data, std::ostream &outputStream, const char delimiter) CISST_THROW(std std::string CISST_EXPORT cmnData< mtsGenericObject >::SerializeDescription(const mtsGenericObject &data, const char delimiter, const std::string &userDescription)
bool CISST_EXPORT ScalarNumberIsFixed (const mtsGenericObject &data)
size_t CISST_EXPORT ScalarNumber (const mtsGenericObject &data)

Static Public Member Functions

static std::string HumanReadable (const DataType &data)
static void Copy (DataType &data, const DataType &source)
static std::string SerializeDescription (const DataType &data, const char delimiter, const std::string &userDescription="")
static size_t SerializeBinary (const DataType &data, char *buffer, size_t bufferSize)
static size_t DeSerializeBinary (DataType &data, const char *buffer, size_t bufferSize, const cmnDataFormat &CMN_UNUSED(localFormat), const cmnDataFormat &CMN_UNUSED(remoteFormat))
static bool ScalarNumberIsFixed (const DataType &data)

Static Public Attributes

static void static SerializeText(const DataType &data, std::ostream &outputStream, const char delimiter=',') CISST_THROW(std void static DeSerializeText(DataType &data, std::istream &inputStream, const char delimiter=',') CISST_THROW(std void static SerializeBinary(const DataType &data, std::ostream &outputStream) CISST_THROW(std void static DeSerializeBinary(DataType &data, std::istream &inputStream, const cmnDataFormat &localFormat, const cmnDataFormat &remoteFormat) CISST_THROW(std size_t SerializeBinaryByteSize (const DataType &data)
static std::string static ScalarDescription(const DataType &data, const size_t index, const std::string &userDescription="") CISST_THROW(std double static Scalar(const DataType &data, const size_t index) CISST_THROW(std size_t ScalarNumber (const DataType &data)

Detailed Description

template<typename _elementType>
class cmnData< _elementType >

cmnDataFunction. Data functions used to handle objects across the cisst libraries. All data function names use the prefix cmnData and the first parameter is the object currently manipulated.

The main principle is to rely on the compiler to find the proper class overload for each object type. void cmnData<int>::HumanReadable(const int & data); void cmnData<std::string>::HumanReadable(const std::string & data); ... This approach allows to manipulate external data types by overloading the required cmnData class.

Error handling is based on standard exceptions using std::runtime_error.

Member Typedef Documentation

◆ DataType

template<typename _elementType>
typedef _elementType cmnData< _elementType >::DataType

Member Enumeration Documentation

◆ anonymous enum

template<typename _elementType>
anonymous enum
Enumerator
IS_SPECIALIZED 

Member Function Documentation

◆ Copy() [1/2]

template<typename _elementType>
void cmnData< _elementType >::Copy ( DataType & data,
const DataType & source )
static

Copy the source to the data object. This allows to define mechanisms that might be more efficient than copy constructors and avoid the ambiguities of the assignment operator. For example, to copy a dynamic vector of simple object, it can be more efficient to use a memcpy than to iterate over each element and assign one by one.

◆ Copy() [2/2]

void CISST_EXPORT cmnData< mtsGenericObject >::Copy ( mtsGenericObject & data,
const mtsGenericObject & source )

◆ DeSerializeBinary()

template<typename _elementType>
size_t cmnData< _elementType >::DeSerializeBinary ( DataType & data,
const char * buffer,
size_t bufferSize,
const cmnDataFormat & CMN_UNUSEDlocalFormat,
const cmnDataFormat & CMN_UNUSEDremoteFormat )
static

◆ HumanReadable()

template<typename _elementType>
std::string cmnData< _elementType >::HumanReadable ( const DataType & data)
static

Returns a human readable string describing a specific instance of an object.

◆ ScalarNumber()

size_t CISST_EXPORT cmnData< mtsGenericObject >::ScalarNumber ( const mtsGenericObject & data)

◆ ScalarNumberIsFixed() [1/2]

template<typename _elementType>
bool cmnData< _elementType >::ScalarNumberIsFixed ( const DataType & data)
static

◆ ScalarNumberIsFixed() [2/2]

bool CISST_EXPORT cmnData< mtsGenericObject >::ScalarNumberIsFixed ( const mtsGenericObject & data)

◆ SerializeBinary() [1/2]

template<typename _elementType>
size_t cmnData< _elementType >::SerializeBinary ( const DataType & data,
char * buffer,
size_t bufferSize )
static

Attempt to serialize the data object using the user provided buffer. The buffer size must be provided by the caller. The function first checks that the buffer is large enough and returns 0 otherwise. The function then serializes (binary format) the data object, modify the parameter bufferSize to reflect how much is left and return the number of bytes used.

◆ SerializeBinary() [2/2]

void CISST_EXPORT cmnData< mtsGenericObject >::SerializeBinary ( const mtsGenericObject & data,
std::ostream & outputStream ) const &

◆ SerializeDescription()

template<typename _elementType>
std::string cmnData< _elementType >::SerializeDescription ( const DataType & data,
const char delimiter,
const std::string & userDescription = "" )
static

Provides a human readble string describing each element of the data object. This description is for all instances of the same "size". For example, if the data object is a dynamic vector of intergers of size 4, the delimiter is a comma and the user description is "V", the returned string would look like "V.size,v[0],v[1],v[2],v[3]".

Member Data Documentation

◆ ScalarNumber

template<typename _elementType>
std::string static ScalarDescription(const DataType &data, const size_t index, const std::string &userDescription="") CISST_THROW(std double static Scalar(const DataType &data, const size_t index) CISST_THROW(std size_t cmnData< _elementType >::ScalarNumber(const DataType &data)
static

◆ SerializeBinaryByteSize

template<typename _elementType>
void static SerializeText(const DataType &data, std::ostream &outputStream, const char delimiter=',') CISST_THROW(std void static DeSerializeText(DataType &data, std::istream &inputStream, const char delimiter=',') CISST_THROW(std void static SerializeBinary(const DataType &data, std::ostream &outputStream) CISST_THROW(std void static DeSerializeBinary(DataType &data, std::istream &inputStream, const cmnDataFormat &localFormat, const cmnDataFormat &remoteFormat) CISST_THROW(std size_t cmnData< _elementType >::SerializeBinaryByteSize(const DataType &data)
static

Serializes each element of the data object in text format, separated by the user provided delimiter. Using the previous example, this method would stream the size followed by the 4 value: "4,11,22,33,44". I/O stream errors can lead to exceptions.

Set the value of the data object by deserializing each element from the input stream. The function will look for the user provided delimiter between the elements to deserialize. Using the previous example, the overloaded function for a dynamic vector will look for the size (4), attempt to resize the data vector to fit 4 elements, skip one delimiter (comma) and then attempt to deserialize 4 comma separated values from the input stream.

Serializes each element of the data object in binary format.

Returns the numbers of bytes required to stored the content of the data object. This function can be used to allocate a char buffer used to perform the serialization.


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