sipxportlib  Version 3.3
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
UtlContainer Class Referenceabstract

#include <UtlContainer.h>

Inheritance diagram for UtlContainer:
Inheritance graph
[legend]
Collaboration diagram for UtlContainer:
Collaboration graph
[legend]

Public Member Functions

 UtlContainer ()
 
virtual ~UtlContainer ()
 
virtual UtlContainableinsert (UtlContainable *obj)=0
 
virtual UtlBoolean destroy (UtlContainable *)=0
 
virtual void destroyAll ()=0
 
virtual UtlContainableremoveReference (const UtlContainable *object)=0
 
virtual void removeAll ()=0
 
virtual UtlContainablefind (const UtlContainable *) const =0
 
virtual unsigned hash () const
 
virtual UtlContainableType getContainableType () const
 
virtual UtlBoolean isEmpty () const =0
 
virtual UtlBoolean contains (const UtlContainable *) const =0
 
virtual size_t entries () const =0
 
virtual int compareTo (const UtlContainable *otherObject) const
 
- Public Member Functions inherited from UtlContainable
virtual ~UtlContainable ()
 
unsigned directHash () const
 Provides a hash function that uses the object pointer as the hash value. 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 void acquireIteratorConnectionLock ()
 Lock the linkage between containers and iterators. More...
 
static void releaseIteratorConnectionLock ()
 Unlock the linkage between containers and iterators. More...
 
- Static Public Member Functions inherited from UtlContainable
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 = "UtlContainer"
 
- Static Public Attributes inherited from UtlContainable
static const UtlContainableType TYPE = "UtlContainable"
 

Protected Member Functions

void addIterator (UtlIterator *newIterator) const
 Add an iterator to the list to be notified of changes to this container. More...
 
void removeIterator (UtlIterator *existingIterator) const
 Called from iterator destructor to prevent further notices. More...
 
void invalidateIterators ()
 Call the invalidate method on all iterators. More...
 

Protected Attributes

OsBSem mContainerLock
 Must be taken when making any change to container state. More...
 
UtlChain mIteratorList
 

Friends

class UtlIterator
 
class UtlInit
 

Detailed Description

UtlContainer defines an abstract container designed to hold UtlContainable derived objects.

Constructor & Destructor Documentation

< Class type used for runtime checking Default Constructor

~UtlContainer ( )
virtual

Destructor

Member Function Documentation

virtual UtlContainable* insert ( UtlContainable obj)
pure virtual

Inserts the designated containable object into the list

Returns
the object if successful, otherwise null

Implemented in UtlSList, UtlHashMap, UtlHashBag, and UtlSortedList.

virtual UtlBoolean destroy ( UtlContainable )
pure virtual

Removes the designated objects from the list and frees the object by calling delete.

Implemented in UtlHashMap, UtlList, UtlSList, and UtlHashBag.

virtual void destroyAll ( )
pure virtual

Removes all elements from the container and deletes each one.

Implemented in UtlHashMap, UtlList, and UtlHashBag.

virtual UtlContainable* removeReference ( const UtlContainable object)
pure virtual

Removes the designated object by reference (as opposed to searching for an equality match).

Returns
the object if successful, otherwise null

Implemented in UtlHashMap, UtlList, and UtlHashBag.

virtual void removeAll ( )
pure virtual

Removes all elements from the container without freeing the objects.

Implemented in UtlHashMap, UtlList, and UtlHashBag.

virtual UtlContainable* find ( const UtlContainable ) const
pure virtual

Find the designated value within the container

Implemented in UtlHashMap, UtlList, UtlSList, UtlHashBag, and UtlSortedList.

unsigned hash ( ) const
virtual

Calculate a unique hash code for this object. If the equals operator returns true for another object, then both of those objects must return the same hashcode.

Calculate a unique hash code for this object. If the equals operator returns true between two objects, then both objects must have the same hash code.

Implements UtlContainable.

UtlContainableType getContainableType ( ) const
virtual

Get the ContainableType for a UtlContainable derived class.

Implements UtlContainable.

Reimplemented in UtlList, UtlHashMap, UtlHashBag, UtlSList, UtlCopyableSList, UtlSortedList, UtlCopyableSortedList, OsContactList, and UtlDList.

virtual UtlBoolean isEmpty ( ) const
pure virtual

Determine if the container is empty.

Implemented in UtlList, UtlHashMap, and UtlHashBag.

virtual UtlBoolean contains ( const UtlContainable ) const
pure virtual

Determine if the container includes the designated objects.

Implemented in UtlList, UtlHashMap, and UtlHashBag.

virtual size_t entries ( ) const
pure virtual

Determine the number of elements within the container.

Implemented in UtlList, UtlHashMap, and UtlHashBag.

int compareTo ( const UtlContainable otherObject) const
virtual

Compare the this object to another like-objects. Results for designating a non-like object are undefined.

Returns
0 if equal, < 0 if less then and >0 if greater.

Compare the this object to another like object. Results for comparing with a non-like object are undefined.

Returns
0 if equal, <0 if less than and >0 if greater.

Implements UtlContainable.

void acquireIteratorConnectionLock ( )
static

Lock the linkage between containers and iterators.

This must be called by any code that will take both the mContainerRefLock in an iterator and the mContainerLock in a container. It can be released as soon as both those locks are acquired, and should be, since most operations on any iterator will need to take it briefly.

void releaseIteratorConnectionLock ( )
static

Unlock the linkage between containers and iterators.

void addIterator ( UtlIterator newIterator) const
protected

Add an iterator to the list to be notified of changes to this container.

Parameters
newIteratorto be notified of container changes
void removeIterator ( UtlIterator existingIterator) const
protected

Called from iterator destructor to prevent further notices.

< The caller must be holding this->mContainerLock and newIterator->mContainerRefLock

This also sets the mpMyContainer pointer in newIterator. The caller must be holding both this->mContainerLock and existingIterator->mContainerRefLock; see also acquireIteratorConnectionLock.

Remove the existingIterator from the list to be called for changes to this UtlContainer.

Parameters
existingIteratoriterator to remove from notice list
void invalidateIterators ( )
protected

Call the invalidate method on all iterators.

This is for use in subclasses that have other state that must be cleaned up.

:NOTE: the caller must be holding the iterator list lock; see iteratorListLock

Friends And Related Function Documentation

friend class UtlIterator
friend
friend class UtlInit
friend

Member Data Documentation

const UtlContainableType TYPE = "UtlContainer"
static
OsBSem mContainerLock
mutableprotected

Must be taken when making any change to container state.

UtlChain mIteratorList
protected

mpIterator list is the list of existing UtlIterator objects constructed using this UtlContainer

This is used to invoke methods on each UtlIterator when changes are made to the UtlContainer ->remove when an element is about to be removed from the UtlContainer, ->invalidate when this UtlContainer is being deleted see sIteratorConnectionLock