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

BxDataObjects.h

00001 // ##################################################################
00002 // BinX
00003 // $Id: BxDataObjects_8h-source.html,v 1.1.1.1 2006/04/19 14:19:02 edikt2 Exp $
00004 //
00005 // Simple list class to be used as an ordered collection to hold
00006 // data objects.
00007 // ##################################################################
00008 /*
00009 
00010 //  edikt::BinX
00011 //  www.edikt.org
00012 //  support@edikt.org
00013 
00014 // Copyright (c) 2003 The University of Edinburgh.
00015 
00016 */
00017 
00018 #ifndef __BxDataObjects__
00019 #define __BxDataObjects__
00020 
00021 #include "BxObject.h"
00022 #include "BxDataObject.h"
00023 
00024 /*
00025  * Collection class holding an ordered list of BxDataObject instances.
00026  * An instance of this class holds references to one or more objects.
00027  * The referenced objects must be instances of any class
00028  * derived from the class BXDataObject.
00029  * Hence, an instance of the class BxDataObjects holds references to objects of different types.
00030  * This class implements collection management methods to:
00031  * <ul>
00032  * <li>Add and remove object instances from the collection.</li>
00033  * <li>Locate an object in the collection
00034  * based on it relative location in the collection list or based on its value.</li>
00035  * </UL>
00036  * <BR><B>Implementation Notes:</B><BR>
00037  * Currently, a collection is initially constructed to hold
00038  * a small number of object references.
00039  * Objects references can be incrementally added to the collection.
00040  * When the number of objects would exceed the initial size of the collection,
00041  * the collection capacity is increased by a fixed amount.
00042  * <BR><B>Since:</B>  BinX version 1.0.
00043  */
00044 class DECLSPEC BxDataObjects : public BxObject
00045 {
00046 private:
00047     BxDataObject ** elements_;   //<an array to hold references to the objects in this set
00048     int     capacity_;      //<number of elements the current array can hold
00049     int     elementCount_;  //<number of initialized elements in the array of objects
00050     int     incrementSize_;    //<number of physical elements slots to add each time the object set must be expanded
00051 
00052 public:
00053     BxDataObjects();
00054     BxDataObjects(int,int);    //capacity and incrementSize
00055     virtual ~BxDataObjects();
00056 
00057     virtual char* className() const { return "BxDataObjects"; } //<Returns the null-terminated string "BxDataObjects".
00058 
00059     bool add(BxDataObject*);   //add a created data object at the end of the array
00060     BxDataObject * remove(int index);     //remove an element by index
00061     BxDataObject * remove(const char * typeName);
00062     void clear();   //remove all elements
00063     BxDataObject * get(int index) const;  //get the object pointer by index
00064     BxDataObject * operator[](int index) const;
00065     BxDataObject * searchByTypeName(const char * typeName);
00066     int count() const { return elementCount_; }    //return elementCount_, the number of elements in the list
00067 
00068 protected:
00069     bool expand();
00070 };
00071 
00072 #endif

Generated on Fri May 6 13:36:17 2005 for edikt::BinX by doxygen 1.3.3