Main Page | Class Hierarchy | Compound List | File List | Compound Members

BxUnionCases Class Reference

Class storing a collection of BxUnionCase objects. More...

#include <BxUnionCases.h>

Inheritance diagram for BxUnionCases:

BxObject List of all members.

Public Member Functions

 BxUnionCases ()
 BxUnionCases (int, int)
 BxUnionCases (const BxUnionCases &)
bool add (BxUnionCase *)
BxUnionCaseremove (int index)
void clear ()
BxUnionCaseget (int index) const
BxDataObjectgetArm (int index) const
BxDataObjectgetArm (const BxDataObject &discriminant) const
BxUnionCaseoperator[] (int index) const

Detailed Description

By default, an instance of this class is constructed to hold a small number of BxUnionCase objects in its collection. The colelction size is incrementally expanded if required. It is also possible to explicitly create a large collection when the object is first constructed.
Useful methods are getArm() which returns a union-selected data object, that is a data object of the dat type selected by the union discriminant and the application data value of that type. The data object can be selected by the index value for the matched union case or by specifying the discriminant value for matching against the union cases. This object is used by the class BxUnion to keep a list of the union selection cases in a union object. In turn, this object uses the class BxUnionCase to create and initialise individual case selections from a union specification.
Since: BinX version 1.0.


Constructor & Destructor Documentation

BxUnionCases::BxUnionCases  ) 
 

Default constructor.

Constructs an instance of the class BxUnionCases. Default attribute values are assigned as follows:

       elementCount_ = 0;
       capacity_ = 4;
       incrementSize_ = 1;
   
An empty collection to hold individual union cases is created. The maximum number of entries in the collection is defined by the capacity_ attribute value.

BxUnionCases::BxUnionCases int  capacity,
int  incrementsize
 

Construct a union cases object having a specified collection size and expansion size.

The new union cases object holds a collection of the specified size. An empty collection to hold individual union cases is created. The maximum number of entries in the collection is specified by the input capacity number. The collection can be expanded in the specified increments. The method expand()should be used to increase the size of the collection stored in this object.

Parameters:
capacity The maximum number of entries in the union cases collection.
incrementsize The increment size for future expansions of the collection size.

BxUnionCases::BxUnionCases const BxUnionCases copy  ) 
 

Construct a union cases object having attribute values identical to a specified instance of BxUnionCases.

Attributes of the new union instance are initialised by copying attribute values from the specified input union cases object. Upon completion of the construction operation, the two union cases instances are independent. They do not share objects and they must be individually destructed.

Parameters:
copy The BxUnionCases instance whose attribute values are to be copied.


Member Function Documentation

bool BxUnionCases::add BxUnionCase pObj  ) 
 

Append a specified union case object to the end of this union cases collection.

If an object has not been constructed to hold the collection or the collection is full, the collection is expanded by incrementSize_ entries.

Parameters:
pObj A pointer to the union case object to be appended to the collection.

void BxUnionCases::clear  ) 
 

Delete all the union case objects in the collection.

All union case objects in the collection are destructed and the collection size is set to zero.
Implementation Notes:
The current implementation of this method does not always succeed in destructing the union case objects. This results in a slow memory leak. The method fails to perform deletions based on specific object types.

int BxUnionCases::count  )  const [inline]
 

Returns the total number of union cases in the list.

BxUnionCase * BxUnionCases::get int  index  )  const
 

Get a union case object from the collection.

The object is specified by index position in the collection. The index position must be specified as a zero-based reference into the collection. If the specified index value is out of range for the number of entries in the collection, this method return a NULL pointer. If the specified index value is in range, then a pointer to the union case object is returned. The caller must not destruct the returned object as it is managed by this union cases object.

Parameters:
index The zero-based index value specifying a union case object in the collection.
Returns:
A pointer to the union case object in the specified collection position.

BxDataObject * BxUnionCases::getArm const BxDataObject discriminant  )  const
 

Get the data object value corresponding to a specified case selection entry in the collection.

A discriminant selection value specifies a case selection entry in this union case object. The data object value associated with the identified case selection entry (and originally read from the associated binary data file), is returned to the caller.
If the specified discriminant value does not match any of the defined discriminant selection values this method return a NULL pointer.

Parameters:
discriminant A data object containing the discriminante value to be matched.
Returns:
A pointer to the data object if a matching case selection value was found,
A NULL pointer no matching case selection value was found.

BxDataObject * BxUnionCases::getArm int  index  )  const
 

Get the data object value corresponding to a specified case selection entry in the collection.

An input index value specifies a case selection entry in this union case object. The data object value associated with the identified case selection entry (and originally read from the associated binary data file), is returned to the caller.
The index position must be specified as a zero-based reference into the collection. If the specified index value is out of range for the number of entries in the collection, this method returns a NULL pointer.

Parameters:
index An index of the union case object in the collection.
Returns:
A pointer to the data object if the index is in range,
A NULL pointer if the index is out of range.

BxUnionCase * BxUnionCases::operator[] int  index  )  const
 

Overloaded operator [] provides array-like access to entries in the collection.

Parameters:
index The zero-based index value specifying a union case object in the collection.
Returns:
A pointer to the specified union case object.

BxUnionCase * BxUnionCases::remove int  index  ) 
 

Extract a union case object specified by index position in the collection.

The index position must be specified as a zero-based reference into the collection. If the specified index value is out of range, no action is performed by this method. The union case object is removed from the collectin and returned to the caller. The caller is responsible for destructing the object, based on the object type.

Parameters:
index An index value identifying the zero-based position of a union case object in the collection.


The documentation for this class was generated from the following files:
Generated on Fri May 6 13:36:19 2005 for edikt::BinX by doxygen 1.3.3