|static const CopyPolicy||copyPolicy = byConstructor|
|static const StoragePolicy||storagePolicy = notToBeStored|
|static const bool||isPOD = false|
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:
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:
isPOD determines whether this type is Plain-Old-Types; POD or not.
The default is
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.