Photon C++ Client API  4.1.15.3
Public Member Functions | List of all members
CustomTypeBase Class Referenceabstract
Inheritance diagram for CustomTypeBase:
Inheritance graph
[legend]
Collaboration diagram for CustomTypeBase:
Collaboration graph
[legend]

Public Member Functions

virtual void cleanup (void)=0
 
virtual bool compare (const CustomTypeBase &other) const =0
 
virtual void duplicate (CustomTypeBase *pRetVal) const =0
 
virtual void deserialize (const nByte *pData, short length)=0
 
virtual short serialize (nByte *pRetVal) const =0
 
- Public Member Functions inherited from Base
virtual ~Base (void)
 
- Public Member Functions inherited from ToString
virtual ~ToString (void)
 
virtual JString typeToString (void) const
 
virtual JStringtoString (JString &retStr, bool withTypes=false) const =0
 
JString toString (bool withTypes=false) const
 

Additional Inherited Members

- Static Public Member Functions inherited from Base
static void setListener (const BaseListener *baseListener)
 
static int getDebugOutputLevel (void)
 
static bool setDebugOutputLevel (int debugLevel)
 
static const LogFormatOptionsgetLogFormatOptions (void)
 
static void setLogFormatOptions (const LogFormatOptions &options)
 

Detailed Description

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

Member Function Documentation

§ cleanup()

cleanup ( void  )
pure virtual

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()

compare ( const CustomTypeBase other) const
pure virtual

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
otherthe object to compare the instance with
Returns
true, if both objects are equal, false otherwise

§ duplicate()

duplicate ( CustomTypeBase pRetVal) const
pure virtual

This function shall save a copy of the instance, on which it has been called on, in its return value.

Parameters
pRetValthe 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
pDataa 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
lengththe 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
pRetValthe 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