PTLib Version 2.12.9

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PObject Class Reference

Ultimate parent class for all objects in the class library. More...

`#include <object.h>`

Inherited by Info, MXRecord, PAdaptiveDelay, PAec, PArgList, PASNObject, PBase64, PChannel, PColourConverter, PConfig, PContainer, PCypher, PDNS::NAPTRRecord, PDNS::SRVRecord, PDTMFDecoder, PDynaLink, PEthSocket::Frame, PEthSocketThread, PFileInfo, PHMAC, PHTTPAuthority, PHTTPClientAuthentication, PHTTPConnectionInfo, PHTTPField, PHTTPRequest, PHTTPResource, PInterfaceFilter, PIpAccessControlEntry, PIPSocket::Address, PIPSocket::InterfaceEntry, PIPSocket::RouteEntry, PKey< T >, PLDAPAttributeBase, PLDAPSchema, PLDAPSession, PLDAPSession::ModAttrib, PLDAPStructBase, PMail, PMessageDigest, PMultiPartInfo, PNotifierListTemplate< ParamType >, PNotifierListTemplate< P_INT_PTR >, PODBC, PODBC::RecordSet, PODBC::Row, PPluginManager, PPluginModuleManager, PPluginService, PProcessStartup, PReadWriteMutex, PRegularExpression, PSafeCollection, PSafeObject, PSafePtrBase, PScriptLanguage, PServiceMacro, PSHA1Context, PSmartObject, PSmartPointer, PSNMPVarBindingList, PSOAPClient, PSOAPServerRequestResponse, PSpoolDirectory`[private]`, PSSLCertificate, PSSLCertificate::X509_Name, PSSLContext, PSSLDiffieHellman, PSSLPrivateKey, PSync, PSystemLog, PSystemLogTarget, PThread, PThreadPoolBase, PTime, PTimeInterval, PTimerList, PURL, PURLLoader, PURLScheme, PVarType, PVideoControlInfo, PVideoFont, PVideoFrameInfo, PVideoInputControl, PVideoInteractionInfo, PVXMLGrammar, PVXMLNodeHandler, PVXMLPlayable, PVXMLRecordable, PXMLBase, PXMLObject, PXMLRPC, PXMLRPCServerParms, PXMLRPCStructBase, PXMLRPCVariableBase, XMPP::Disco::Item, XMPP::Identity, XMPP::JID, XMPP::MUC::Room, XMPP::MUC::User, XMPP::Roster, and XMPP::Roster::Item.

## Public Member Functions
unsigned | GetTraceContextIdentifier () const
| Get PTRACE context identifier. More...
void | SetTraceContextIdentifier (unsigned id)
void | GetTraceContextIdentifier (PObject &obj)
void | GetTraceContextIdentifier (PObject *obj)
void | SetTraceContextIdentifier (const PObject &obj)
void | SetTraceContextIdentifier (const PObject *obj)
virtual | ~PObject ()
Miscellaneous functions
virtual PObject * | Clone () const
| Create a copy of the class on the heap. More...
template<class CLS >
CLS * | CloneAs () const
| As for Clone() but converts to specified type. More...
virtual PINDEX | HashFunction () const
| This function yields a hash value required by the `PDictionary` class. More...

## Protected Member Functions
| PObject ()
| Constructor for PObject, made protected so cannot ever create one on its own. More...

## Protected Attributes
unsigned | m_traceContextIdentifier

## Run Time Type functions
virtual const char * | GetClass (unsigned ancestor=0) const
| Get the current dynamic type of the object instance. More...
PBoolean | IsClass (const char *cls) const
virtual PBoolean | InternalIsDescendant (const char *clsName) const
| Determine if the dynamic type of the current instance is a descendent of the specified class. More...
__inline const PObject * | PTraceObjectInstance () const
static const char * | Class ()
| Get the name of the class as a C string. More...
static __inline const PObject * | PTraceObjectInstance (const char *)
static __inline const PObject * | PTraceObjectInstance (const PObject *obj)

## Comparison functions
enum | Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
| Result of the comparison operation performed by the `Compare()` function. More...
virtual Comparison | Compare (const PObject &obj) const
| Compare the two objects and return their relative rank. More...
virtual Comparison | CompareObjectMemoryDirect (const PObject &obj) const
| Determine the byte wise comparison of two objects. More...
bool | operator== (const PObject &obj) const
| Compare the two objects. More...
bool | operator!= (const PObject &obj) const
| Compare the two objects. More...
bool | operator< (const PObject &obj) const
| Compare the two objects. More...
bool | operator> (const PObject &obj) const
| Compare the two objects. More...
bool | operator<= (const PObject &obj) const
| Compare the two objects. More...
bool | operator>= (const PObject &obj) const
| Compare the two objects. More...
static Comparison | InternalCompareObjectMemoryDirect (const PObject *obj1, const PObject *obj2, PINDEX size)
| Internal function caled from CompareObjectMemoryDirect() More...

## I/O functions
virtual void | PrintOn (ostream &strm) const
| Output the contents of the object to the stream. More...
virtual void | ReadFrom (istream &strm)
| Input the contents of the object from the stream. More...
ostream & | operator<< (ostream &strm, const PObject &obj)
| Global function for using the standard << operator on objects descended from PObject. More...
istream & | operator>> (istream &strm, PObject &obj)
| Global function for using the standard >> operator on objects descended from PObject. More...

## Detailed Description

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.

## Member Enumeration Documentation

enum PObject::Comparison

Result of the comparison operation performed by the `Compare()` function.

Enumerator
LessThan |
EqualTo |
GreaterThan |

## Constructor & Destructor Documentation

PObject::PObject | ( |  | ) |
| inline protected

Constructor for PObject, made protected so cannot ever create one on its own.

virtual PObject::~PObject | ( |  | ) |
| inline virtual

## Member Function Documentation

static const char* PObject::Class | ( |  | ) |
| inline static

Get the name of the class as a C string.

This is a static function which returns the type of a specific class.

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.

Returns
  pointer to C string literal.

Referenced by GetClass().

virtual PObject* PObject::Clone | ( |  | ) | const
| virtual

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.

Reimplemented in PStringDictionary< K >, PStringSet, PStringList, PStringArray, PCaselessString, POrdinalDictionary< K >, PHTTPMultiSimpAuth, PHTTPSimpleAuth, PBitArray, PDictionary< K, D >, PDictionary< PString, PDynaLink >, PDictionary< XMPP::JID, PNotifierListTemplate< P_INT_PTR > >, PDictionary< PString, XMPP::Presence >, PDictionary< PRFC1155_ObjectName, PRFC1155_ObjectSyntax >, PDictionary< PString, PXMLRPCVariableBase >, PDictionary< PString, PLDAPAttributeBase >, PDictionary< PString, PNotifierListTemplate< P_INT_PTR > >, PDictionary< K, POrdinalKey >, PDictionary< K, PString >, PSortedList< T >, PArray< T >, PArray< PString >, PArray< PBYTEArray >, PArray< PPluginService >, PArray< K >, PArray< PDynaLink >, PArray< PXMLRPCVariableBase >, PArray< PODBC::Field >, PBYTEArray, PStack< T >, PCharArray, PSet< T >, PSet< PString >, PQueue< T >, PQueue< PXML >, PASNNull, PASNObjectID, PString, PASNGauge, PASNCounter, PASNTimeTicks, PList< T >, PList< PString >, PList< PSafeObject >, PList< PThread >, PList< PNotifier >, PList< PMultiPartInfo >, PASNIPAddress, PSocksUDPSocket, PBaseArray< T >, PBaseArray< int >, PBaseArray< PObject * >, PBaseArray< const char * >, PBaseArray< struct berval * >, PBaseArray< BYTE >, PBaseArray< PHashTableElement * >, PBaseArray< unsigned >, PBaseArray< DWORD >, PBaseArray< char >, PASNString, PSocks5Socket, PASNInteger, PSocks4Socket, PVarType, PHashTableInfo, PASNObject, PTime, XMPP::BareJID, PGloballyUniqueID, PTimeInterval, PTCPSocket, XMPP::JID, and PKey< T >.

Referenced by CloneAs().

template<class CLS >

CLS* PObject::CloneAs | ( |  | ) | const
| inline

As for Clone() but converts to specified type.

References Clone().

virtual Comparison PObject::Compare | ( | const PObject & | obj | ) | const
| virtual

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.

Reimplemented in PAbstractSortedList, PArrayObjects, PSafePtrMultiThreaded, PSafePtrBase, PString, PHTTPClientDigestAuthentication, PServiceMacro, PHTTPClientBasicAuthentication, MXRecord, PSSLCertificate::X509_Name, PHTTPClientAuthentication, PProcess, PDNS::SRVRecord, PHashTable, PAbstractArray, PFile, PSmartPointer, PTime, PChannel, PAbstractList, PIPSocket::Address, XMPP::BareJID, PTimeInterval, PVideoFrameInfo, PURL, PKey< T >, XMPP::MUC::User, PIndirectChannel, PIpAccessControlEntry, PMemoryFile, XMPP::JID, PHTTPField, and PDNS::NAPTRRecord.

Referenced by operator!=(), operator<(), operator<=(), operator==(), operator>(), and operator>=().

virtual Comparison PObject::CompareObjectMemoryDirect | ( | const PObject & | obj | ) | const
| virtual

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.

virtual const char* PObject::GetClass | ( | unsigned | ancestor = `0` | ) | const
| inline virtual

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.

References Class().

Referenced by IsClass().

unsigned PObject::GetTraceContextIdentifier | ( |  | ) | const
| inline

Get PTRACE context identifier.

References m_traceContextIdentifier.

void PObject::GetTraceContextIdentifier | ( | PObject & | obj | ) |
| inline

References m_traceContextIdentifier.

void PObject::GetTraceContextIdentifier | ( | PObject * | obj | ) |
| inline

References m_traceContextIdentifier.

virtual PINDEX PObject::HashFunction | ( |  | ) | const
| virtual

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.

Reimplemented in PString, PChannel, PGloballyUniqueID, PKey< T >, and PURL.

static Comparison PObject::InternalCompareObjectMemoryDirect | ( | const PObject * | obj1,
|  | const PObject * | obj2,
|  | PINDEX | size
| ) |  |
| static

Internal function caled from CompareObjectMemoryDirect()

virtual PBoolean PObject::InternalIsDescendant | ( | const char * | clsName | ) | const
| inline virtual

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.

References IsClass().

PBoolean PObject::IsClass | ( | const char * | cls | ) | const
| inline

References GetClass().

Referenced by InternalIsDescendant().

bool PObject::operator!= | ( | const PObject & | obj | ) | const
| inline

Compare the two objects.

Returns
  true if objects are not equal.

References Compare(), and EqualTo.

bool PObject::operator< | ( | const PObject & | obj | ) | const
| inline

Compare the two objects.

Returns
  true if objects are less than.

References Compare(), and LessThan.

bool PObject::operator<= | ( | const PObject & | obj | ) | const
| inline

Compare the two objects.

Returns
  true if objects are less than or equal.

References Compare(), and GreaterThan.

bool PObject::operator== | ( | const PObject & | obj | ) | const
| inline

Compare the two objects.

Returns
  true if objects are equal.

References Compare(), and EqualTo.

bool PObject::operator> | ( | const PObject & | obj | ) | const
| inline

Compare the two objects.

Returns
  true if objects are greater than.

References Compare(), and GreaterThan.

bool PObject::operator>= | ( | const PObject & | obj | ) | const
| inline

Compare the two objects.

Returns
  true if objects are greater than or equal.

References Compare(), and LessThan.

virtual void PObject::PrintOn | ( | ostream & | strm | ) | const
| virtual

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.

Reimplemented in PIPSocket::InterfaceEntry, PBYTEArray, PIPSocket::RouteEntry, PCharArray, PSafePtrBase, PASNSequence, PASNNull, PASNObjectID, PLDAPStructBase, PCollection, PSafeCollection, PASNUnsignedInteger, PSSLCertificate, MXRecord, PXMLElement, PSSLCertificate::X509_Name, PASNString, PXMLRPCStructBase, PDNS::SRVRecord, PASNInteger, PXMLRPCArrayBase, PThread, PASNObject, PXML, PAbstractArray, XMPP::JID, PIpAccessControlEntry, PSNMPVarBindingList, and PDNS::NAPTRRecord.

__inline const PObject* PObject::PTraceObjectInstance | ( |  | ) | const
| inline

static __inline const PObject* PObject::PTraceObjectInstance | ( | const char * |  | ) |
| inline static

static __inline const PObject* PObject::PTraceObjectInstance | ( | const PObject * | obj | ) |
| inline static

virtual void PObject::ReadFrom | ( | istream & | strm | ) |
| virtual

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.

Reimplemented in PBYTEArray, PCharArray, PXML, PAbstractArray, and PIpAccessControlEntry.

void PObject::SetTraceContextIdentifier | ( | unsigned | id | ) |
| inline

References m_traceContextIdentifier.

void PObject::SetTraceContextIdentifier | ( | const PObject & | obj | ) |
| inline

References m_traceContextIdentifier.

void PObject::SetTraceContextIdentifier | ( | const PObject * | obj | ) |
| inline

References m_traceContextIdentifier.

## Friends And Related Function Documentation

ostream& operator<< | ( | ostream & | strm,
|  | const PObject & | obj
| ) |  |
| friend

Global function for using the standard << operator on objects descended from PObject.

This simply calls the objects `PrintOn()` function.

Returns
  the `strm` parameter.

Parameters

  strm | Stream to print the object into.
  obj | Object to print to the stream.

istream& operator>> | ( | istream & | strm,
|  | PObject & | obj
| ) |  |
| friend

Global function for using the standard >> operator on objects descended from PObject.

This simply calls the objects `ReadFrom()` function.

Returns
  the `strm` parameter.

Parameters

  strm | Stream to read the objects contents from.
  obj | Object to read inormation into.

## Member Data Documentation

unsigned PObject::m_traceContextIdentifier
| protected

Referenced by GetTraceContextIdentifier(), and SetTraceContextIdentifier().

The documentation for this class was generated from the following file:

- object.h