sipxportlib
Version 3.3
|
#include <UtlContainable.h>
Public Member Functions | |
virtual | ~UtlContainable () |
virtual UtlContainableType | getContainableType () const =0 |
virtual unsigned | hash () const =0 |
Calculate a hash code for this object. More... | |
unsigned | directHash () const |
Provides a hash function that uses the object pointer as the hash value. More... | |
virtual int | compareTo (UtlContainable const *) const =0 |
Compare this object to another object. More... | |
virtual UtlBoolean | isEqual (UtlContainable const *) const |
Test this object to another object for equality. More... | |
virtual UtlBoolean | isInstanceOf (const UtlContainableType type) const |
Determine if this object is a derivative of the specified UtlContainableType. More... | |
Static Public Member Functions | |
static unsigned | stringHash (char const *value) |
Provides a hash function appropriate for null-terminated string values. More... | |
static UtlBoolean | areSameTypes (const UtlContainableType type1, const UtlContainableType type2) |
Are UtlContainable types the same. More... | |
Static Public Attributes | |
static const UtlContainableType | TYPE = "UtlContainable" |
An UtlContainable object is an abstract object that serves as the base class for anything that can be contained in one of the UtlContainer- derived classes. One of the largest values of a UtlContainable-derived object is the ability for any UtlContainer to destroy objects, sort objects, etc.
|
virtual |
< Class type used for runtime checking Destructor
|
pure virtual |
Get the ContainableType for a UtlContainable-derived class.
Implemented in UtlString, OsTimer, UtlList, UtlHashMap, OsMsg, OsContact, UtlHashBag, UtlSList, UtlContainer, UtlInt, UtlCopyableSList, UtlIntPtr, UtlSortedList, UtlLongLongInt, OsSocket, UtlVoidPtr, UtlBool, UtlCopyableSortedList, OsContactList, UtlContainablePair, UtlDateTime, UtlDList, UtlCopyableContainable, and DbEntry.
|
pure virtual |
Calculate a hash code for this object.
The hash method should return a value that is a function of the key used to locate the object. As much as possible, hash values should be uniformly distributed over the range of legal unsigned values.
Implemented in UtlString, OsTimer, OsMsg, OsContact, UtlContainer, UtlInt, UtlIntPtr, UtlLongLongInt, UtlVoidPtr, UtlBool, UtlDateTime, UtlContainablePair, DbEntry, and UtlContainableAtomic.
unsigned directHash | ( | ) | const |
Provides a hash function that uses the object pointer as the hash value.
This may be used by any UtlContainable class for which generating a value hash is difficult or not meaningful. Note that pointer values, since they are not uniformly distributed, probably make poor hash codes so this should not be used normally.
To use this, define your hash function as just:
unsigned int Foo::hash() const { return directHash(); }
If you use directHash as the hash method, you probably want to use pointer comparison as the compareTo method:
int Foo::compareTo(UtlContainable const* inVal) const { int result ;
result = this > other ? 1 : this < other ? -1 : 0;
return result; }
|
static |
Provides a hash function appropriate for null-terminated string values.
To use this, define your hash function as just:
Foo hash() { return stringHash(value); }
|
pure virtual |
Compare this object to another object.
Results of comparison to an object not of the same UtlContainableType may be undefined.
Results for comparing with a non-like object are undefined, other than that it must return non-equal. Note that a copy of an object might not compare equal to the original, unless the definition of its type requires it.
Implemented in UtlString, OsTimer, OsMsg, OsContact, UtlContainer, UtlInt, UtlIntPtr, UtlVoidPtr, UtlLongLongInt, UtlBool, UtlDateTime, UtlContainablePair, DbEntry, and UtlContainableAtomic.
|
virtual |
Test this object to another object for equality.
Results for objects not of the same UtlContainableType may be undefined.
A default implementation of this is provided that should be adequate for any UtlContainableType.
Reimplemented in UtlString, OsContact, UtlInt, UtlIntPtr, and UtlLongLongInt.
|
static |
Are UtlContainable types the same.
|
virtual |
Determine if this object is a derivative of the specified UtlContainableType.
Determine if this object is an instance of the designated runtime class identifer or one of its derivatives. For example:
if (pMyObject->isInstanceOf(UtlInt::TYPE)) { ... }
If you want to determine if this object is exactly the same type as the given type (i.e. not a deriviative) use the following:
if(myObject->getContainableType() == UtlInt::TYPE) { ... }
Reimplemented in UtlString, UtlInt, UtlIntPtr, UtlBool, and UtlCopyableContainable.
|
static |