Celartem::DataTraits< T > Struct Template Reference

#include <cel_datatraits.h>

List of all members.

Static Public Attributes

static const CopyPolicy copyPolicy = byConstructor
static const StoragePolicy storagePolicy = notToBeStored
static const bool isPOD = false


Detailed Description

template<typename T>
struct Celartem::DataTraits< T >

DataTraits defines the traits of objects. If you have defined some struct/class for your own purpose, and want to use it with SimpleArray or DataArray template, then this struct should be defined for the purpose of determining the mechanisms that is fit to your structure.
If your struct/class does not have DataTraits, the default DataTraits, which uses byConstructor and notToBeStored , is applied to the type.
There is a macro named CEL_DEFINE_DATATRAITS, which eases to define the DataTraits for your structure. With the macro, you can write the DataTraits easily like the following code:

            CEL_DEFINE_DATATRAITS(YourClass, byMemcpy, byCopyMemory);

See also:
CEL_DEFINE_DATATRAITS, SimpleArray, DataArray

Definition at line 76 of file cel_datatraits.h.


Member Data Documentation

template<typename T>
const CopyPolicy Celartem::DataTraits< T >::copyPolicy = byConstructor [static]

copyPolicy determines how to copy the instances of the type; this should be one of the CopyPolicy enumeration.
In general, the values of int, long, ... types are easily copied using std::memcpy since they are simple enough. The types of int, long, double are called 'POD' (Plain Old Data) and if SimpleArray holds the array consist of such types, it should be copied by std::memcpy instead of copy constructors because the graceful C++ oriented copy sequence has very large overhead and it would impact the performance of your code. In such case, copyPolicy should be set to byMemcpy . In the other case, the instances should not be copied using std::memcpy but by copy-constructor, copyPolicy should be byConstructor . The special case, when your structure does not permit use of copy-constructor, you can set copyPolicy to noCopy and you can use SimpleArray with such classes/structs. This scheme is introduced because there're demands of arraying Synchronization objects such as Mutex, Semaphore and Event. The Mutex, Semaphore, Event classes provided in this library have their own DataTraits, which set copyPolicy to noCopy. Although the SimpleArray holds any of such objects can be created normally, they could not be resized since the resize method may require the copy of the instances.
The following types are copied using byMemcpy by default:

See also:
SimpleArray, DataArray

Definition at line 121 of file cel_datatraits.h.

template<typename T>
const StoragePolicy Celartem::DataTraits< T >::storagePolicy = notToBeStored [static]

storagePolicy determines how to store the data into the storage. ; this should be one of the StoragePolicy enumeration.
The default is notToBeStored. This does not allow serialization/deserialization of the instances of the type.
For POD types, the default is bySwapCopyBytes.

See also:
SimpleArray, DataArray

Definition at line 133 of file cel_datatraits.h.

template<typename T>
const bool Celartem::DataTraits< T >::isPOD = false [static]

isPOD determines whether this type is Plain-Old-Types; POD or not.
The default is false.

Definition at line 140 of file cel_datatraits.h.


The documentation for this struct was generated from the following file:
This document is automatically generated using doxygen 1.5.4 at Fri Jun 27 18:23:16 2008.