PObject Class Reference

Detailed Description

The PObject class is the root class of all Papillon classes; all PObject behaves like shared references.

Definition at line 27 of file PObject.h.

#include <PObject.h>

Constructor & Destructor Documentation

◆ PObject() [1/2]

PObject::PObject ( )

Construct an empty object.

◆ PObject() [2/2]

PObject::PObject ( const PObject obj)
inline

Constructs a shared copy of other.

Definition at line 38 of file PObject.h.

◆ ~PObject()

virtual PObject::~PObject ( )
virtual

Destroys this object.

Member Function Documentation

◆ CastTo() [1/2]

PResult PObject::CastTo ( PObject obj)

Casts this object to the specified PObject; returns PResult::C_OK if success, another result otherwise.

Note: argument is not modified on failure.

◆ CastTo() [2/2]

PResult PObject::CastTo ( PObject obj) const

Casts this object to the specified PObject; returns PResult::C_OK if success, another result otherwise.

Note: argument is not modified on failure.

◆ DebugCounter()

papillon::uint32 PObject::DebugCounter ( ) const

For debug purpose: returns the number of instances managing the current object.

◆ DebugInternalPointer()

PString PObject::DebugInternalPointer ( ) const

For debug purpose: returns a string representing the internal address of this object.

◆ Equal()

bool PObject::Equal ( const PObject e) const

Returns true if the specified element is the same than this one, otherwise returns false.

◆ FromBase64()

PResult PObject::FromBase64 ( const PString base64representation)

Reads this object from a base-64 string representation (deserialisation).

This method first checked the type of the object. If deserialisation failed, then this object is unchanged. Returns PResult::C_OK if success, another result otherwise.

◆ FromString()

PResult PObject::FromString ( const PString s)

Builds a PObject from a string (destringify).

Returns PResult::C_OK if success, another result otherwise.

◆ GetClassId()

classid PObject::GetClassId ( ) const

Returns the class identifier associated with this object.

◆ GetHashCode()

papillon::uint32 PObject::GetHashCode ( ) const

Returns a hash code value for the object.

This method is supported for the benefit of hash tables such as those provided by PMap. GetHashCode() is not implemented for all classes. If not implemented, the method will return 0. See documentation of sub-classes to know if GetHashCode() exists.

The general contract of GetHashCode is:

  • it is invoked on the same object more than once during an execution of a an application, the GetHashCode method must consistently return the same integer. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the == method, then calling the GetHashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the == method, then calling the GetHashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.

◆ IsNullReference()

bool PObject::IsNullReference ( ) const

Returns true if this object is a NULL reference, false otherwise.

◆ IsSame()

bool PObject::IsSame ( const PObject obj) const

Returns true underlying object is same.

◆ IsSerialisable()

bool PObject::IsSerialisable ( ) const

Returns true if this object is serialisable, false otherwise.

◆ ObjImpl() [1/2]

template<typename T >
const T& PObject::ObjImpl ( ) const
inlineprotected

Definition at line 213 of file PObject.h.

◆ ObjImpl() [2/2]

template<typename T >
T& PObject::ObjImpl ( )
inlineprotected

Definition at line 215 of file PObject.h.

◆ ObjImplS() [1/2]

template<typename T >
const T& PObject::ObjImplS ( ) const
inlineprotected

Definition at line 221 of file PObject.h.

◆ ObjImplS() [2/2]

template<typename T >
T& PObject::ObjImplS ( )
inlineprotected

Definition at line 223 of file PObject.h.

◆ ObjPimpl() [1/2]

template<typename T >
std::shared_ptr<const T> PObject::ObjPimpl ( ) const
inlineprotected

Definition at line 198 of file PObject.h.

◆ ObjPimpl() [2/2]

template<typename T >
std::shared_ptr<T> PObject::ObjPimpl ( )
inlineprotected

Definition at line 201 of file PObject.h.

◆ ObjPimplS()

template<typename T >
std::shared_ptr<T> PObject::ObjPimplS ( )
inlineprotected

Definition at line 207 of file PObject.h.

◆ operator=()

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

Performs a shared copy of other to this object.

See also
Clone()

Definition at line 45 of file PObject.h.

◆ Read()

PResult PObject::Read ( PByteStream is,
ESerialisationFormat  format = papillon::E_BINARY_FORMAT 
)

Reads this object from the bytes stream retrieved from the specified input stream (deserialisation).

This method first checked the type of the object. If deserialisation failed, then this object is unchanged. Returns PResult::C_OK if success, another result otherwise.

See also
Write()

◆ ReadObject()

PObject PObject::ReadObject ( PByteStream is,
PResult result 
) const

Builds a PObject from a byte stream (deserialisation).

This method assumes that the type of object has already been decoded from the byte stream. If deserialisation failed, an empty object will be returned. Ret is set to PResult::C_OK if success, another result otherwise.

◆ Swap()

void PObject::Swap ( PObject other)

Exchanges the contents of the object with those of other, transferring ownership of any managed object between them without destroying or altering the use count of either.

Warning: the object must have the same types.

◆ ToBase64()

PString PObject::ToBase64 ( ) const

Returns a base-64 string representation of this object (serialisation).

◆ ToByteArray()

PByteArray PObject::ToByteArray ( ) const

Returns a byte buffer representing a binary representation of this object (serialisation).

◆ ToString()

PString PObject::ToString ( ) const

Returns a string representation of this object.

◆ Write()

PResult PObject::Write ( PByteStream os,
ESerialisationFormat  format = papillon::E_BINARY_FORMAT 
) const

Writes a canonical representation of this object to the specified output stream (serialisation).

Returns PResult::C_OK if success, another result otherwise.

See also
Read()

Friends And Related Function Documentation

◆ operator<<

PAPILLON_API_CORE std::ostream& operator<< ( std::ostream &  os,
const PObject obj 
)
friend

Writes a string representation of this object to the specified std::ostream.

◆ PObjectImpl

friend class PObjectImpl
friend

Definition at line 185 of file PObject.h.

Member Data Documentation

◆ m_pimpl

std::shared_ptr<PObjectImpl> PObject::m_pimpl
mutableprotected

Definition at line 190 of file PObject.h.