StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
dbNodes.h
1 /***************************************************************************
2  *
3  * $Id: dbNodes.h,v 1.5 2001/01/22 18:40:25 porter Exp $
4  *
5  * Author: R. Jeff Porter
6  ***************************************************************************
7  *
8  * Description: simple list of nodes (db objects)
9  *
10  ***************************************************************************
11  *
12  * $Log: dbNodes.h,v $
13  * Revision 1.5 2001/01/22 18:40:25 porter
14  * Added a wrapper for StMessage so one can use it in StDbLib
15  *
16  * Revision 1.4 2000/01/27 20:30:40 porter
17  * cleaned up dtor & error logic
18  *
19  * Revision 1.3 2000/01/27 05:56:03 porter
20  * update for compiling on CC5+HPUX-aCC+KCC
21  *
22  * Revision 1.2 2000/01/14 14:49:10 porter
23  * set verbose level for checking, added $Id & $Logs, & made node container
24  * more robust for interactions with StDbLib
25  *
26  * Revision 1.1 2000/01/10 20:31:17 porter
27  * modified StDbBroker to be an interface to the DB-interface, StDbLib.
28  * - old functionality is retained for the short-term & modifications
29  * are extensions
30  *
31  *
32  **************************************************************************/
33 #ifndef DBNODES_HH
34 #define DBNODES_HH
35 
36 #include "dbNodeArray.h"
37 #include "StDbLib/StDbNode.hh"
38 
39 #include <vector>
40 #if !defined(ST_NO_NAMESPACES)
41 using std::vector;
42 #endif
43 
44 #ifdef ST_NO_TEMPLATE_DEF_ARGS
45 typedef vector<StDbNode*, allocator<StDbNode*> > nodeVec;
46 #else
47 typedef vector<StDbNode*> nodeVec;
48 #endif
49 
50 
51 class dbNodes : public dbNodeArray {
52 
53 protected:
54 
55 nodeVec mnodes;
56 int numNodes;
57 int curNode;
58 
59 int* mpids;
60 int maxList;
61 
62  void extendParentList();
63 
64 public:
65 
66  dbNodes();
67  ~dbNodes() { deleteLists(); }
68 
69  virtual void deleteLists();
70 
71  virtual int addNode(StDbNode* node, int parentID);
72  virtual StDbNode* getNode(int index) ;
73 
74  virtual int getParentID(int index) ;
75  virtual StDbNode* getParent(int index) ;
76 
77  virtual int getNumNodes() ;
78  virtual void reset() ;
79  virtual StDbNode* next() ;
80 
81 };
82 
83 inline
84 int dbNodes::getNumNodes(){ return numNodes; }
85 
86 inline
87 void dbNodes::reset(){ curNode=0; }
88 
89 inline
90 void dbNodes::extendParentList() {
91  int newMax = 2*maxList;
92  int* tmpList = new int[newMax];
93  memcpy(tmpList,mpids,maxList*sizeof(int));
94  delete [] mpids;
95  mpids = tmpList;
96  maxList = newMax;
97 }
98 
99 
100 #endif
101 
102 
103 
104 
105 
106 
107