class PObject

Ultimate parent class for all objects in the class library.

Inheritance:


Public

[more] Run Time Type functions
[more] Comparison functions
[more] I/O functions
[more] Miscellaneous functions

Protected Methods

[more] PObject ()
Constructor for PObject, make protected so cannot ever create one on its own


Documentation

Ultimate parent class for all objects in the class library. This provides functionality provided to all classes, eg run-time types, default comparison operations, simple stream I/O and serialisation support.
o PObject()
Constructor for PObject, make protected so cannot ever create one on its own

o Run Time Type functions

ostatic const char* Class()
Get the name of the class as a C string. This is a static function which returns the type of a specific class. It is primarily used as an argument to the IsClass() or IsDescendant() functions.

When comparing class names, always use the strcmp() function rather than comparing pointers. The pointers are not necessarily the same over compilation units depending on the compiler, platform etc.

The PCLASSINFO macro declares a version of this function for the particular class.

Returns:
pointer to C string literal.

ovirtual const char* GetClass( unsigned ancestor = 0 ) const
Get the current dynamic type of the object instance.

When comparing class names, always use the strcmp() function rather than comparing pointers. The pointers are not necessarily the same over compilation units depending on the compiler, platform etc.

The PCLASSINFO macro declares an override of this function for the particular class. The user need not implement it.

Returns:
pointer to C string literal.
Parameters:
ancestor - Level of ancestor to get the class name for. A value of zero is the instances class name, one is its ancestor, two for the ancestors ancestor etc.

ovirtual BOOL IsClass( const char * clsName ) const
Determine if the dynamic type of the current instance is of the specified class. The class name is usually provided by the Class() static function of the desired class.

The PCLASSINFO macro declares an override of this function for the particular class. The user need not implement it.

Returns:
TRUE if object is of the class.

ovirtual BOOL IsDescendant( const char * clsName ) const
Determine if the dynamic type of the current instance is a descendent of the specified class. The class name is usually provided by the Class() static function of the desired class.

The PCLASSINFO macro declares an override of this function for the particular class. The user need not implement it.

Returns:
TRUE if object is descended from the class.

o Comparison functions

oenum Comparison
Result of the comparison operation performed by the Compare() function

ovirtual Comparison Compare( const PObject & obj ) const
Compare the two objects and return their relative rank. This function is usually overridden by descendent classes to yield the ranking according to the semantics of the object.

The default function is to use the CompareObjectMemoryDirect() function to do a byte wise memory comparison of the two objects.

Returns:
LessThan, EqualTo or GreaterThan according to the relative rank of the objects.

ovirtual Comparison CompareObjectMemoryDirect( const PObject & obj ) const
Determine the byte wise comparison of two objects. This is the default comparison operation for objects that do not explicitly override the Compare() function.

The PCLASSINFO macro declares an override of this function for the particular class. The user need not implement it.

Returns:
LessThan, EqualTo or GreaterThan according to the result memcpy() function.

oBOOL operator==( const PObject & obj ) const
Compare the two objects.

Returns:
TRUE if objects are equal.

oBOOL operator!=( const PObject & obj ) const
Compare the two objects.

Returns:
TRUE if objects are not equal.

oBOOL operator<( const PObject & obj ) const
Compare the two objects.

Returns:
TRUE if objects are less than.

oBOOL operator>( const PObject & obj ) const
Compare the two objects.

Returns:
TRUE if objects are greater than.

oBOOL operator<=( const PObject & obj ) const
Compare the two objects.

Returns:
TRUE if objects are less than or equal.

oBOOL operator>=( const PObject & obj ) const
Compare the two objects.

Returns:
TRUE if objects are greater than or equal.

o I/O functions

ovirtual void PrintOn( ostream &strm ) const
Output the contents of the object to the stream. The exact output is dependent on the exact semantics of the descendent class. This is primarily used by the standard operator<< function.

The default behaviour is to print the class name.

ovirtual void ReadFrom( istream &strm )
Input the contents of the object from the stream. The exact input is dependent on the exact semantics of the descendent class. This is primarily used by the standard operator>> function.

The default behaviour is to do nothing.

oinline friend ostream& operator<<( ostream &strm, const PObject & obj )
Global function for using the standard << operator on objects descended from PObject. This simply calls the objects PrintOn() function.

Returns:
the strm parameter.

oinline friend istream& operator>>( istream &strm, PObject & obj )
Global function for using the standard >> operator on objects descended from PObject. This simply calls the objects ReadFrom() function.

Returns:
the strm parameter.

ovirtual PINDEX PreSerialise( PSerialiser & strm )
This function is used to determine the size of the object and all other objects it contains. The actual size is dependent on the exact semantics of the descendent object. For example the PString class would return the length of the string plus one, while the PList class would return the sum of the sizes of all of the objects in the list plus the size of an integer for the number of objects.

This in only required by the PBinarySerialiser class which serialises the objects into a binary file. The PTextSerialiser class which serialises into a text stream does not use this function.

Note serialisation requires the use of the PDECLARE_SERIAL and PIMPLEMENT_SERIAL macros.

Returns:
size in bytes of object.

ovirtual void Serialise( PSerialiser & strm )
Serialise the object into the specified stream. This is similar to the PrintOn() function that outputs the contents of the object to a stream, but where PrintOn() usually produces a human readable form of the object, this function outputs enough data so that it can be reconstructed by the PUnSerialiser class.

When the user implements this function they will usually be doing it for one of either the text of binary output versions. In some circumstances, eg libraries, both need be supported so the IsDscendent() function should be used on the strm parameter to determine whether it is a PBinarySerialiser class or a PTextSerialiser class and do the appropriate output.

To a large extent, if only the << operator is used on the PSerialiser instance, the text and binary version can be made identical.

ovirtual void UnSerialise( PUnSerialiser & strm )
Un-serialise the object from the specified stream. This is similar to the ReadFrom() function that inputs the contents of the object from a stream, but where ReadFrom() usually intrerprets a human readable form of the object, this function inputs enough data so that it can be reconstructed from the data provided by the Serialise() function.

When the user implements this function they will usually be doing it for one of either the text of binary input versions. In some circumstances, eg libraries, both need be supported so the IsDscendent() function should be used on the strm parameter to determine whether it is a PBinarySerialiser class or a PTextSerialiser class and do the appropriate input.

To a large extent, if only the >> operator is used on the PUnSerialiser instance, the text and binary version can be made identical.

o Miscellaneous functions

ovirtual PObject* Clone() const
Create a copy of the class on the heap. The exact semantics of the descendent class determine what is required to make a duplicate of the instance. Not all classes can even do a clone operation.

The main user of the clone function is the PDictionary class as it requires copies of the dictionary keys.

The default behaviour is for this function to assert.

Returns:
pointer to new copy of the class instance.

ovirtual PINDEX HashFunction() const
This function yields a hash value required by the PDictionary class. A descendent class that is required to be the key of a dictionary should override this function. The precise values returned is dependent on the semantics of the class. For example, the PString class overrides it to provide a hash function for distinguishing text strings.

The default behaviour is to return the value zero.

Returns:
hash function value for class instance.


Direct child classes:
PShape
PPrintInfo
PKeyCode
PCommandSink
PCommandManager
PClipboard
PMenuEntry
PRegion
PRect
PPoint
PFontFamily
PFont
PDim
PColour
PCanvas
PListViewItem
PSSLPrivateKey
PSSLCertificate
PMessageDigest5
PIpAccessControlEntry
PCypher
PBase64
PURL
PServiceMacro
PMultipartFormInfo
PHTTPResource
PHTTPRequest
PHTTPField
PHTTPConnectionInfo
PHTTPAuthority
PASN_Object
RouteEntry
InterfaceEntry
PThread
PSystemLog
PSemaphore
PReadWriteMutex
PVideoDevice
PTimeInterval
PTime
PRemoteConnection
PMail
PDynaLink
PConfig
PArgList
PFileInfo
PColourConverter
PChannel
PRegularExpression
POrdinalKey
PContainer
PUnSerialiser
PSmartPointer
PSmartObject
PSerialiser

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.