00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 #ifndef DBNODES_HH
00034 #define DBNODES_HH
00035
00036 #include "dbNodeArray.h"
00037 #include "StDbLib/StDbNode.hh"
00038
00039 #include <vector>
00040 #if !defined(ST_NO_NAMESPACES)
00041 using std::vector;
00042 #endif
00043
00044 #ifdef ST_NO_TEMPLATE_DEF_ARGS
00045 typedef vector<StDbNode*, allocator<StDbNode*> > nodeVec;
00046 #else
00047 typedef vector<StDbNode*> nodeVec;
00048 #endif
00049
00050
00051 class dbNodes : public dbNodeArray {
00052
00053 protected:
00054
00055 nodeVec mnodes;
00056 int numNodes;
00057 int curNode;
00058
00059 int* mpids;
00060 int maxList;
00061
00062 void extendParentList();
00063
00064 public:
00065
00066 dbNodes();
00067 ~dbNodes() { deleteLists(); }
00068
00069 virtual void deleteLists();
00070
00071 virtual int addNode(StDbNode* node, int parentID);
00072 virtual StDbNode* getNode(int index) ;
00073
00074 virtual int getParentID(int index) ;
00075 virtual StDbNode* getParent(int index) ;
00076
00077 virtual int getNumNodes() ;
00078 virtual void reset() ;
00079 virtual StDbNode* next() ;
00080
00081 };
00082
00083 inline
00084 int dbNodes::getNumNodes(){ return numNodes; }
00085
00086 inline
00087 void dbNodes::reset(){ curNode=0; }
00088
00089 inline
00090 void dbNodes::extendParentList() {
00091 int newMax = 2*maxList;
00092 int* tmpList = new int[newMax];
00093 memcpy(tmpList,mpids,maxList*sizeof(int));
00094 delete [] mpids;
00095 mpids = tmpList;
00096 maxList = newMax;
00097 }
00098
00099
00100 #endif
00101
00102
00103
00104
00105
00106
00107