Static Public Attributes | List of all members
Celartem::DataTraits< T > Struct Template Reference

#include <cel_datatraits.h>

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

Member Data Documentation

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

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:

  • signed char
  • short
  • int
  • long
  • int64_t (long long)
  • unsigned char
  • unsigned short
  • unsigned int
  • unsigned long
  • uint64_t (unsigned long long)
  • float
  • double
  • Ratinal<int32_t> (for supporting TIFF data)
  • Rational<uint32_t> (for supporting TIFF data)
See Also
SimpleArray, DataArray
template<typename T >
const bool Celartem::DataTraits< T >::isPOD = false

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

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

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

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

Cuminas DjVu SDK 3.0.33103
This document is made with doxygen 1.8.5 at Sun Dec 15 2013 19:38:06.
Cuminas Logo