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:
- See Also
- CEL_DEFINE_DATATRAITS, SimpleArray, DataArray
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