This is the abstract base class for the CustomType template and declares the interface, which you will have to implement, when subclassing CustomType.
For example implementations of these functions please refer to class SampleCustomType in demo_typeSupport.
- See also
- CustomType, CustomTypeFactory
§ cleanup()
This function gets called, when the instance gets destroyed. This is the right place to do all the stuff, that you would normally do in the destructor. In the destructor you should instead just call this function, as instances of this class will be created and destroyed not only by constructors and destructors, but also by factory functions in situations, in which the class and therefor the constructor and destructor of the object instance to create/destroy are unknown.
§ compare()
This function should be implemented to behave like an operator== would behave for the class, for which this function gets implemented.
For example for a wrapperclass around an integer it could just be implemented like this:
bool Foo::compare(const CustomTypeBase& other) const
{
return typeid(*this) == typeid(other) && mInt == ((Foo&)other).mInt;
}
- Parameters
-
other | the object to compare the instance with |
- Returns
- true, if both objects are equal, false otherwise
§ duplicate()
This function shall save a copy of the instance, on which it has been called on, in its return value.
- Parameters
-
pRetVal | the object, to store a copy of the instance in - has to be of the instance type or a subclass of it, otherwise the behavior will be undefined |
§ deserialize()
deserialize |
( |
const nByte * |
pData, |
|
|
short |
length |
|
) |
| |
|
pure virtual |
This function initializes the instance, on which it has been called on, by deserializing the passed nByte-array, which has to be created by a call to serialize() on an instance of the same class before.
Previous data, stored in the instance, gets overwritten.
- Parameters
-
pData | a nByte-array, holding the deserialized payload of an object, which class has to be the same like the one of the instance, on which the function gets called |
length | the length of pData in elements |
§ serialize()
serialize |
( |
nByte * |
pRetVal | ) |
const |
|
pure virtual |
This function serializes the payload of the instance on which it has been called, into the passed nByte-array and returns the length of that array. It is legal to pass a NULL-pointer and in that case this function still calculates the length of the data, which would have been stored in a non-NULL-pointer, but does not store any data. The behavior for providing a too small array is undefined.
- Parameters
-
pRetVal | the nByte-array to store the serialized payload of the instance in. Has to be of at least the needed length |
- Returns
- the length of the data, that has actually been stored in the passed array