libUTL++
utl::Object Class Reference

Root of UTL++ class hierarchy. More...

#include <Object.h>

Inherited by utl::Number< double >, utl::Span< Time, Duration >, utl::TCollection< Vertex >, utl::Application, utl::ArithContext, utl::Base64decode, utl::Base64encode, utl::BBcodeParser, utl::BitArray, utl::BitArrayElem, utl::Bool, utl::BoyerMooreSearch< T >, utl::CachedObject, utl::CmdLineArgs, utl::Collection, utl::ConditionVar, utl::CRC32, utl::DBconnection, utl::DBfield, utl::DBresult, utl::DBresultIterator, utl::Decimal, utl::Exception, utl::ExtArray, utl::Factory, utl::FSobject, utl::FwdIt, utl::HostOS, utl::HttpRequest, utl::HttpResponse, utl::InetHostAddress, utl::LogMgr, utl::Mapping, utl::MaxObject, utl::MD5, utl::MD5sum, utl::Mutex, utl::Number< T >, utl::ObjectRegistry, utl::Ordering, utl::OStimer, utl::Pair, utl::Predicate, utl::RDparser, utl::ReCaptcha, utl::RegexMatch, utl::RWlock, utl::RWlockLF, utl::Semaphore, utl::ServerSocket, utl::SHA256, utl::SHA256sum, utl::Span< T, D >, utl::Stream, utl::String, utl::StringEscape, utl::StringTranslator, utl::StringVars, utl::TCollection< T >, utl::Thread, utl::Time, utl::Tokenizer, utl::TokenizerTokens, utl::UnixModeMask, utl::URI, utl::Vector< T >, utl::VectorMD< T >, utl::Vertex, utl::Vector< byte_t >, utl::Vector< uint_t >, utl::Vector< utl::Object *>, and utl::Vector< utl::PointerIntPair >.

Public Member Functions

void clear ()
 Revert to initial state. More...
 
virtual int compare (const Object &rhs) const
 Compare with another object. More...
 
virtual void copy (const Object &rhs)
 Copy another instance. More...
 
virtual void vclone (const Object &rhs)
 Make an exact copy of another instance. More...
 
virtual void steal (Object &rhs)
 "Steal" the internal representation from another instance. More...
 
virtual void dump (Stream &os, uint_t level=uint_t_max) const
 Dump a human-readable representation of self to the given output stream. More...
 
void dumpWithClassName (Stream &os, uint_t indent=4, uint_t level=uint_t_max) const
 Front-end for dump() that prints the object's class name. More...
 
virtual const ObjectgetKey () const
 Get the key for this object. More...
 
bool hasKey () const
 Determine whether or not the object has a key. More...
 
virtual const ObjectgetProxiedObject () const
 Get the proxied object (= self if none). More...
 
virtual ObjectgetProxiedObject ()
 Get the proxied object (= self if none). More...
 
virtual size_t hash (size_t size) const
 Get the hash code for the object. More...
 
bool _isA (const RunTimeClass *runTimeClass) const
 Determine whether self's class is a descendent of the given class. More...
 
virtual String toString () const
 Return a string representation of self. More...
 
 operator String () const
 Conversion to String. More...
 
size_t allocatedSize () const
 Get the total allocated size of this object. More...
 
virtual size_t innerAllocatedSize () const
 Get the "inner" allocated size. More...
 
virtual void addOwnedIt (const class FwdIt *it) const
 Notify self that it owns the given iterator. More...
 
virtual void removeOwnedIt (const class FwdIt *it) const
 Notify self that the given owned iterator has been destroyed. More...
 
Comparison Operators
bool operator< (const Object &rhs) const
 Less-than operator. More...
 
bool operator<= (const Object &rhs) const
 Less-than-or-equal-to operator. More...
 
bool operator> (const Object &rhs) const
 Greater-than operator. More...
 
bool operator>= (const Object &rhs) const
 Greater-than-or-equal-to operator. More...
 
bool operator== (const Object &rhs) const
 Equal-to operator. More...
 
bool operator!= (const Object &rhs) const
 Unequal-to operator. More...
 

Serialization

void serializeIn (Stream &is, uint_t mode=ser_default)
 Serialize from an input stream. More...
 
void serializeOut (Stream &os, uint_t mode=ser_default) const
 Serialize to an output stream. More...
 
virtual void serialize (Stream &stream, uint_t io, uint_t mode=ser_default)
 Serialize to or from a stream. More...
 
void serializeOutBoxed (Stream &os, uint_t mode=ser_default) const
 Serialize a boxed object to an output stream. More...
 
static ObjectserializeInNullable (Stream &is, uint_t mode=ser_default)
 Serialize a nullptr-able object from an input stream. More...
 
static void serializeOutNullable (const Object *object, Stream &os, uint_t mode=ser_default)
 Serialize a nullptr-able object to an output stream. More...
 
static void serializeNullable (Object *&object, Stream &stream, uint_t io, uint_t mode=ser_default)
 Serialize a nullptr-able object to or from a stream. More...
 
static ObjectserializeInBoxed (Stream &is, uint_t mode=ser_default)
 Serialize a boxed object from an input stream. More...
 
static void serializeBoxed (Object *&object, Stream &stream, uint_t io, uint_t mode=ser_default)
 Serialize a boxed object to or from a stream. More...
 

Detailed Description

Root of UTL++ class hierarchy.

Object provides a standard interface for functionality that is very commonly required. Most notably, Object defines virtual methods for functionality such as:

  • copying
  • comparison
  • serialization
  • dumping (e.g. for debugging purposes)
  • run-time type identification (RTTI)

When you use the UTL_CLASS_DECL and UTL_CLASS_IMPL macros (macros.h) with your classes, the following methods are implemented for you:

  • default constructor - calls init()
  • copy constructor - calls init(), then copy()
  • virtual destructor - calls deInit()
  • clone - create copy of self (via copy())
  • create - create new instance of same class
  • operator= - copy another object (calls copy())
  • pointer conversion - conversion to pointer
  • const pointer conversion - conversion to const pointer
  • getClass (virtual) - get self's class
  • getClassName (virtual) - get the name of self's class
  • getThisClass - get self's class
  • getThisClassName - get the name of self's class
  • getBaseClass - get the base class
  • getBaseClassName - get the name of the base class
Author
Adam McKee
See also
RunTimeClass

Definition at line 52 of file Object.h.

Member Function Documentation

◆ clear()

void utl::Object::clear ( )

Revert to initial state.

◆ compare()

virtual int utl::Object::compare ( const Object rhs) const
virtual

◆ copy()

◆ vclone()

virtual void utl::Object::vclone ( const Object rhs)
virtual

Make an exact copy of another instance.

The default implementation just calls copy(), so you have to override this if you want different behavior for copy construction and cloning.

Reimplemented in utl::Hashtable, utl::Collection, and utl::Pair.

◆ steal()

virtual void utl::Object::steal ( Object rhs)
virtual

◆ dump()

virtual void utl::Object::dump ( Stream os,
uint_t  level = uint_t_max 
) const
virtual

Dump a human-readable representation of self to the given output stream.

A common use of this is for debugging & testing.

Parameters
osstream to dump to
levellevel of 'verbosity' for the dump

Reimplemented in utl::StringTranslator, utl::Directory, utl::Collection, utl::Translator, utl::TCollection< T >, utl::TCollection< Vertex >, utl::BitArray, utl::FSobject, and utl::SpanAllocator< T, D >.

◆ dumpWithClassName()

void utl::Object::dumpWithClassName ( Stream os,
uint_t  indent = 4,
uint_t  level = uint_t_max 
) const

Front-end for dump() that prints the object's class name.

Parameters
osstream to dump to
indent(optional : 4) indent the object?
levellevel of 'verbosity' for the dump

◆ getKey()

virtual const Object& utl::Object::getKey ( ) const
virtual

Get the key for this object.

The key for an object is used to re-start the comparison process when all overridden compare() have failed. Usually an object's key uniquely identifies the object, though it doesn't necessarily need to. By default, a class has no associated key.

See also
compare hasKey
Returns
object's key (= self if the object has no key)

Reimplemented in utl::NetServerClient, utl::Pair, utl::FSobject, utl::CachedObject, utl::Vertex, and utl::Thread.

Referenced by utl::SpanCol< T, D >::add(), utl::SpanAllocator< T, D >::alloc(), and utl::SpanSizeOrdering< T, D >::cmp().

◆ hasKey()

bool utl::Object::hasKey ( ) const
inline

Determine whether or not the object has a key.

See also
compare getKey
Returns
true iff the object has a key.

Definition at line 124 of file Object.h.

◆ getProxiedObject() [1/2]

virtual const Object& utl::Object::getProxiedObject ( ) const
virtual

Get the proxied object (= self if none).

Reimplemented in utl::TBidIt< T >, utl::TFwdIt< T >, and utl::TRandIt< T >.

◆ getProxiedObject() [2/2]

virtual Object& utl::Object::getProxiedObject ( )
virtual

Get the proxied object (= self if none).

Reimplemented in utl::TBidIt< T >, utl::TFwdIt< T >, and utl::TRandIt< T >.

◆ hash()

virtual size_t utl::Object::hash ( size_t  size) const
virtual

Get the hash code for the object.

The default implementation will return the hash code of the object's key, or abort if the object has none.

Returns
the hash code
Parameters
sizehash table size

Reimplemented in utl::SHA256sum, utl::String, utl::InetHostAddress, utl::MD5sum, utl::Integer< T >, utl::Integer< int64_t >, utl::Integer< char >, and utl::Integer< uint64_t >.

◆ _isA()

bool utl::Object::_isA ( const RunTimeClass runTimeClass) const
inline

Determine whether self's class is a descendent of the given class.

The macro isA provides a more convenient usage.

See also
RunTimeClass
Returns
true iff self's class is a descendent of the given class
Parameters
runTimeClassclass we are comparing with

Definition at line 151 of file Object.h.

◆ serializeIn()

void utl::Object::serializeIn ( Stream is,
uint_t  mode = ser_default 
)
inline

Serialize from an input stream.

Parameters
isinput stream to serialize from
modesee utl::serialize_t

Definition at line 164 of file Object.h.

References utl::io_rd, and utl::serialize().

Referenced by utl::Number< double >::serialize().

◆ serializeOut()

void utl::Object::serializeOut ( Stream os,
uint_t  mode = ser_default 
) const
inline

Serialize to an output stream.

Parameters
osoutput stream to serialize to
modesee utl::serialize_t

Definition at line 175 of file Object.h.

References const_cast_this, utl::io_wr, utl::ser_default, utl::serialize(), and utl::serializeNullable().

Referenced by utl::Number< double >::serialize().

◆ serialize()

◆ serializeInNullable()

static Object* utl::Object::serializeInNullable ( Stream is,
uint_t  mode = ser_default 
)
static

Serialize a nullptr-able object from an input stream.

See also
serializeInBoxed
Returns
newly created/serialized object (nullptr if none)
Parameters
isinput stream to serialize from
modesee utl::serialize_t

◆ serializeOutNullable()

static void utl::Object::serializeOutNullable ( const Object object,
Stream os,
uint_t  mode = ser_default 
)
static

Serialize a nullptr-able object to an output stream.

See also
serializeOutBoxed
Parameters
objectobject to serialize (can be nullptr)
osoutput stream to serialize to
modesee utl::serialize_t

◆ serializeNullable()

static void utl::Object::serializeNullable ( Object *&  object,
Stream stream,
uint_t  io,
uint_t  mode = ser_default 
)
static

Serialize a nullptr-able object to or from a stream.

See also
serializeBoxed
Parameters
objectobject to serialize (can be nullptr)
streamstream to serialize from/to
iosee utl::io_t
modesee utl::serialize_t

◆ serializeInBoxed()

static Object* utl::Object::serializeInBoxed ( Stream is,
uint_t  mode = ser_default 
)
static

Serialize a boxed object from an input stream.

Create a new object from scratch, given the classname and serialized data read from the input stream.

Returns
newly created/serialized object (nullptr if none)
Parameters
isinput stream to serialize from
modesee utl::serialize_t

◆ serializeOutBoxed()

void utl::Object::serializeOutBoxed ( Stream os,
uint_t  mode = ser_default 
) const

Serialize a boxed object to an output stream.

The object's classname is written to the stream first, so that serializeInBoxed() will be able to re-create the object from scratch.

Parameters
osstream to serialize to
modesee utl::serialize_t

◆ serializeBoxed()

static void utl::Object::serializeBoxed ( Object *&  object,
Stream stream,
uint_t  io,
uint_t  mode = ser_default 
)
inlinestatic

Serialize a boxed object to or from a stream.

Parameters
objectobject to be serialized
streamstream to serialize from/to
iosee utl::io_t
modesee utl::serialize_t

Definition at line 244 of file Object.h.

References utl::allocatedSize(), utl::io_rd, and utl::toString().

◆ toString()

◆ operator String()

utl::Object::operator String ( ) const

Conversion to String.

◆ allocatedSize()

size_t utl::Object::allocatedSize ( ) const

Get the total allocated size of this object.

◆ innerAllocatedSize()

◆ operator<()

bool utl::Object::operator< ( const Object rhs) const
inline

Less-than operator.

Definition at line 268 of file Object.h.

References utl::compare().

◆ operator<=()

bool utl::Object::operator<= ( const Object rhs) const
inline

Less-than-or-equal-to operator.

Definition at line 273 of file Object.h.

References utl::compare().

◆ operator>()

bool utl::Object::operator> ( const Object rhs) const
inline

Greater-than operator.

Definition at line 278 of file Object.h.

References utl::compare().

◆ operator>=()

bool utl::Object::operator>= ( const Object rhs) const
inline

Greater-than-or-equal-to operator.

Definition at line 283 of file Object.h.

References utl::compare().

◆ operator==()

bool utl::Object::operator== ( const Object rhs) const
inline

Equal-to operator.

Definition at line 288 of file Object.h.

References utl::compare().

◆ operator!=()

bool utl::Object::operator!= ( const Object rhs) const
inline

Unequal-to operator.

Definition at line 293 of file Object.h.

References utl::compare().

◆ addOwnedIt()

virtual void utl::Object::addOwnedIt ( const class FwdIt it) const
virtual

Notify self that it owns the given iterator.

◆ removeOwnedIt()

virtual void utl::Object::removeOwnedIt ( const class FwdIt it) const
virtual

Notify self that the given owned iterator has been destroyed.


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