Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

rdObjectArray Class Reference

A class for storing an array of rdObject's. More...

#include <rdObjectArray.h>

Inheritance diagram for rdObjectArray:

rdObject rdFunctionSet suTrackObjectSet rdGCVSplineSet List of all members.

Public Member Functions

 rdObjectArray (int aCapacity=128, const char *aName="UNKNOWN")
 Default constructor.

 rdObjectArray (const char *aFileName)
 Construct from a file.

 rdObjectArray (IDOM_Element *aElement)
 Construct based on an XML element.

virtual ~rdObjectArray ()
 Destructor.

virtual void setDescription (const char *aDescrip=NULL)
 Set the description of this storage.

virtual const char * getDescription () const
 Get a description of this storage.

virtual bool ensureCapacity (int aCapacity)
 Ensure that the capacity of this expandable array is at least the specified amount.

virtual int getCapacity () const
 Get the capacity of this storage instance.

virtual void setCapacityIncrement (int aIncrement=-1)
 Set the amount by which the capacity is increased.

virtual int getCapacityIncrement () const
 Get the amount by which the capacity is increased.

virtual void reset ()
 Reset the storage to start storing at index 0.

virtual void reset (int aIndex)
 Reset the storage to start storing after the specified index.

virtual int getFirstEmpty () const
 Get the index of the first empty array element.

virtual int getIndex (const char *aName, int aStart=0) const
 Get the index of the first object with the specified name.

virtual int getIndex (rdObject *aObject) const
 Get the index of an object by pointer value.

virtual rdObjectset (int aIndex, rdObject *aObject)
 Set the pointer at a specified array index.

virtual rdObjectget (int aIndex) const
 Get the pointer at a specified array index.

virtual rdObjectgetLast () const
 Get the last pointer in the array.

virtual int append (rdObject *aObject)
 Append an object.

virtual int append (rdObjectArray *aArray)
 Append all the objects in an rdObjectArray object.

virtual rdObjectremove (int aIndex)
 Remove an object by index.

virtual rdObjectremove (rdObject *aObject)
 Remove an object based on the object's pointer.

virtual void updateObject (bool aDeep=true)
 Update this object based on its XML node.

virtual void updateNode (bool aDeep=true)
 Update the XML node representing this object.


Protected Attributes

char * _descrip
 Description.

int _capacity
 Current capacity.

int _capacityIncrement
 Increment by which the current capacity is increased when the capacity of this storage instance is reached.

rdObject ** _array
 Array of pointers to rdObjects.


Static Protected Attributes

const int CAPMIN = rdObjectArray_CAPMIN
 Minimum capacity.


Private Member Functions

void allocateCapacity ()
void setNull ()
 Set all member variables to their null or default values.


Private Attributes

int _firstEmpty
 Index of the first empty rdStateVector pointer.


Detailed Description

A class for storing an array of rdObject's.

The capacity of the class grows as needed.

When an rdObjectArray object is deleted, the objects held by the array are deleted.

Version:
1.0
Author:
Frank C. Anderson


Constructor & Destructor Documentation

rdObjectArray::rdObjectArray const char *  aFileName  ) 
 

Construct from a file.

Parameters:
aElement 

rdObjectArray::rdObjectArray IDOM_Element *  aElement  ) 
 

Construct based on an XML element.

Parameters:
aElement 

rdObjectArray::~rdObjectArray  )  [virtual]
 

Destructor.

The destructor does NOT call the destructor for the pointer elements held in the array. It simply deletes the array itself.


Member Function Documentation

int rdObjectArray::append rdObject aObject  )  [virtual]
 

Append an object.

Parameters:
aObject Object to be appended.
Returns:
Index to the first empty element in the array (i.e., the end of the array).

bool rdObjectArray::ensureCapacity int  aCapacity  )  [virtual]
 

Ensure that the capacity of this expandable array is at least the specified amount.

Parameters:
aCapacity Desired capacity.
Returns:
true if the capacity was successfully obtained, false otherwise.

rdObject * rdObjectArray::get int  aIndex  )  const [virtual]
 

Get the pointer at a specified array index.

If the index is greater than or equal to the capacity of the array, NULL is returned.

Parameters:
aIndex Index of the desired array element.
Returns:
Pointer at aIndex or NULL.

const char * rdObjectArray::getDescription  )  const [virtual]
 

Get a description of this storage.

Returns:
Description.

int rdObjectArray::getFirstEmpty  )  const [virtual]
 

Get the index of the first empty array element.

Returns:
Index of the first empty array element.

int rdObjectArray::getIndex rdObject aObject  )  const [virtual]
 

Get the index of an object by pointer value.

Parameters:
aObject Pointer value of the object whose index is desired.
Returns:
Index of the object; -1 if no such object is in the array.

int rdObjectArray::getIndex const char *  aName,
int  aStart = 0
const [virtual]
 

Get the index of the first object with the specified name.

A case-sensitive comparison of the specified name is performed to identify the object.

Parameters:
aName Name of the object.
aStart Index at which to start searching. If no match is found, the search restarts at index 0. aStart has a default value of 0.
Returns:
Index of the first object with the specified name. If no object is found with a matching name, -1 is returned.

rdObject * rdObjectArray::getLast  )  const [virtual]
 

Get the last pointer in the array.

Returns:
Last pointer in the array.

rdObject * rdObjectArray::remove rdObject aObject  )  [virtual]
 

Remove an object based on the object's pointer.

When an object is removed, the array locations of all objects following the removed object are shifted down by 1.

This method is fairly expensive to call at this time because the entire array is searched sequentially. The caller is responsible for deleting the removed object.

To remove an object without shifting the array locations of all objects following the removed object, use the method set().

Parameters:
aObject Pointer to the object to be removed.
Returns:
Pointer to the object that was removed. If no object was found, NULL is returned.
See also:
set()

rdObject * rdObjectArray::remove int  aIndex  )  [virtual]
 

Remove an object by index.

When an object is removed, the array locations of all objects following the removed object are shifted down by 1.

The caller is responsible for deleting the removed object.

To remove an object without shifting the array locations of all objects following the removed object, use the method set().

Parameters:
aIndex Index of the object to remove.
Returns:
Pointer to the removed object; NULL if there was no object at aIndex.
See also:
set()

rdObject * rdObjectArray::set int  aIndex,
rdObject aObject
[virtual]
 

Set the pointer at a specified array index.

If the index is greater than or equal to the capacity, sufficient capacity is added. It is permissible to set the value of an array element to NULL.

Parameters:
aIndex Index of the array element being set.
aObject Pointer to an object or NULL.
Returns:
Pointer to the object formerly at aIndex. The caller is responsible for deleting any non-null returned object.

void rdObjectArray::setCapacityIncrement int  aIncrement = -1  )  [virtual]
 

Set the amount by which the capacity is increased.

If an increment is sent in that is less than 0 or this method is called with no argument, the capacity is set to double whenever the capacity is exceeded.

Parameters:
aIncrement Desired capacity increment. By default, the capacity increment is set to double.

void rdObjectArray::setDescription const char *  aDescrip = NULL  )  [virtual]
 

Set the description of this storage.

If the last character of a description is a carriage return, it is stripped.

Parameters:
aDescrip Description.

void rdObjectArray::updateNode bool  aDeep = true  )  [virtual]
 

Update the XML node representing this object.

Parameters:
aDeep If true, update the XML node of this object AND the XML nodes of all class members that are rdObjects (child nodes); if false, update only the XML node of this object without updating the XML nodes of its children.

Reimplemented from rdObject.

Reimplemented in rdFunctionSet, and suTrackObjectSet.

void rdObjectArray::updateObject bool  aDeep = true  )  [virtual]
 

Update this object based on its XML node.

Parameters:
aDeep If true, update this object and all its child objects (that is, member variables that are rdObject's); if false, update only the member variables that are not rdObject's.

Reimplemented from rdObject.

Reimplemented in rdFunctionSet, and suTrackObjectSet.


The documentation for this class was generated from the following files:
Generated on Wed Aug 20 02:17:12 2003 for Simulation Software by doxygen1.3