Photon C++ Client API  5.0.7.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 nByte getTypeCode (void) const =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
 
virtual JStringtoString (JString &retStr, bool withTypes=false) const=0
 
JString toString (bool withTypes=false) const
 
- Public Member Functions inherited from Base
virtual ~Base (void)=0
 
- Public Member Functions inherited from LoggingBase< Base >
virtual ~LoggingBase (void)=0
 
- 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 LoggingBase< Base >
static void setListener (const BaseListener *pBaseListener)
 
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

◆ 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

◆ toString() [1/2]

toString
Remarks
The cost of this function depends a lot on implementation details of the implementing subclasses, but for container classes this function can become quite expensive, if the instance contains huge amounts of data, as its cost for many container class implementations increases disproportionately high to the size of the payload.
Parameters
retStrreference to a string, to store the return-value in; the information, which is generated by this function, will be attached at the end of any eventually existing previous content of the string
withTypesset to true, to include type information in the generated string
Returns
a JString representation of the instance and its contents for debugging purposes.

◆ toString() [2/2]

JString toString

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
withTypesset to true, to include type information in the generated string
Returns
a JString representation of the instance and its contents for debugging purposes.
See also
JString