StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StDbElementIndex.hh
1 /***************************************************************************
2  *
3  * $Id: StDbElementIndex.hh,v 1.1 2001/01/22 18:37:53 porter Exp $
4  *
5  * Author: R. Jeff Porter
6  ***************************************************************************
7  *
8  * Description: Simple name-value pair index set for selecting elementID's
9  * from the database
10  *
11  ***************************************************************************
12  *
13  * $Log: StDbElementIndex.hh,v $
14  * Revision 1.1 2001/01/22 18:37:53 porter
15  * Update of code needed in next year running. This update has little
16  * effect on the interface (only 1 method has been changed in the interface).
17  * Code also preserves backwards compatibility so that old versions of
18  * StDbLib can read new table structures.
19  * -Important features:
20  * a. more efficient low-level table structure (see StDbSql.cc)
21  * b. more flexible indexing for new systems (see StDbElememtIndex.cc)
22  * c. environment variable override KEYS for each database
23  * d. StMessage support & clock-time logging diagnostics
24  * -Cosmetic features
25  * e. hid stl behind interfaces (see new *Impl.* files) to again allow rootcint access
26  * f. removed codes that have been obsolete for awhile (e.g. db factories)
27  * & renamed some classes for clarity (e.g. tableQuery became StDataBaseI
28  * and mysqlAccessor became StDbSql)
29  *
30  *
31  **************************************************************************/
32 #ifndef STDBELEMENTINDEX_HH
33 #define STDBELEMENTINDEX_HH
34 
35 #define N_MAX_INDEXVALS 10
36 #include <string.h>
37 
38 struct indexNameVals {
39 
40  char iname[64];
41  int ival;
42 
43 };
44 
46 
47  int mnumIndeces;
48  indexNameVals mnvals[N_MAX_INDEXVALS];
49  int mcurrent;
50 
51  public:
52 
55  virtual ~StDbElementIndex(){};
56 
57  virtual void clearIndex();
58 
59  virtual void addElementIndex(StDbElementIndex* inval);
60  virtual int addNameValuePair(const char* name, int ival);
61  virtual int getNumIndeces() const;
62  virtual int getIndexVal(int indexNumber);
63  virtual char* getIndexName(int indexNumber);
64  virtual char* printIndexName(int indexNumber);
65 
66  virtual void resetCounter();
67  virtual char* getNextIndex(int& indexVal);
68  virtual char* printNextIndex(int& indexVal);
69 
70 };
71 
72 inline void StDbElementIndex::clearIndex() {
73  mcurrent=0; mnumIndeces=0;
74  memset(&mnvals,0,N_MAX_INDEXVALS*sizeof(indexNameVals));
75 }
76 inline int StDbElementIndex::getNumIndeces() const { return mnumIndeces; }
77 
78 inline int StDbElementIndex::getIndexVal(int indexNum) {
79  if(indexNum>=N_MAX_INDEXVALS)return -1;
80  return mnvals[indexNum].ival;
81 }
82 inline char* StDbElementIndex::printIndexName(int indexNum) {
83  if(indexNum>=N_MAX_INDEXVALS)return (char*)0;
84  return (char*)mnvals[indexNum].iname;
85 }
86 inline void StDbElementIndex::resetCounter() { mcurrent=0; }
87 
88 #endif
89 
90