StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StDbTime.h
1 /***************************************************************************
2  *
3  * $Id: StDbTime.h,v 1.5 2002/01/30 15:40:48 porter Exp $
4  *
5  * Author: R. Jeff Porter
6  ***************************************************************************
7  *
8  * Description: Time class for "unix & date-time" timestamp access to DB
9  *
10  ***************************************************************************
11  *
12  * $Log: StDbTime.h,v $
13  * Revision 1.5 2002/01/30 15:40:48 porter
14  * changed limits on flavor tag & made defaults retrieving more readable
15  *
16  * Revision 1.4 2000/02/15 20:27:45 porter
17  * Some updates to writing to the database(s) via an ensemble (should
18  * not affect read methods & haven't in my tests.
19  * - closeAllConnections(node) & closeConnection(table) method to mgr.
20  * - 'NullEntry' version to write, with setStoreMode in table;
21  * - updated both StDbTable's & StDbTableDescriptor's copy-constructor
22  *
23  * Revision 1.3 2000/01/27 05:54:35 porter
24  * Updated for compiling on CC5 + HPUX-aCC + KCC (when flags are reset)
25  * Fixed reConnect()+transaction model mismatch
26  * added some in-code comments
27  *
28  * Revision 1.2 2000/01/10 20:37:55 porter
29  * expanded functionality based on planned additions or feedback from Online work.
30  * update includes:
31  * 1. basis for real transaction model with roll-back
32  * 2. limited SQL access via the manager for run-log & tagDb
33  * 3. balance obtained between enumerated & string access to databases
34  * 4. 3-levels of diagnostic output: Quiet, Normal, Verbose
35  * 5. restructured Node model for better XML support
36  *
37  * Revision 1.1 1999/09/30 02:06:11 porter
38  * add StDbTime to better handle timestamps, modify SQL content (mysqlAccessor)
39  * allow multiple rows (StDbTable), & Added the comment sections at top of
40  * each header and src file
41  *
42  **************************************************************************/
43 #ifndef STDBTIME_H
44 #define STDBTIME_H
45 
46 #include <string.h>
47 
48 
49 class StDbTime {
50 
51 public:
52 
53 unsigned int munixTime;
54 char* mdateTime;
55 
56  StDbTime(): munixTime(0), mdateTime(0) {};
57  StDbTime(unsigned int utime): mdateTime(0) { munixTime = utime;};
58 
59  StDbTime(const char* dtime): munixTime(0) { if(dtime){
60  mdateTime=new char[strlen(dtime)+1];
61  strcpy(mdateTime,dtime);
62  } else {mdateTime=0;}};
63 
64  StDbTime(StDbTime& time) { munixTime=0; mdateTime=0;
65  if(time.mdateTime){
66  mdateTime=new char[strlen(time.mdateTime)+1];
67  strcpy(mdateTime,time.mdateTime);
68  }
69  munixTime=time.munixTime;
70  }
71  ~StDbTime() { if(mdateTime) delete [] mdateTime; }
72 
73  void setUnixTime(unsigned int utime) { munixTime = utime;}
74  void setDateTime(const char* dtime) { if(!dtime) return;
75  if(mdateTime) delete [] mdateTime;
76  mdateTime=new char[strlen(dtime)+1];
77  strcpy(mdateTime,dtime); };
78 
79  void setTime(unsigned int utime, const char* dtime){
80  setUnixTime(utime);
81  setDateTime(dtime);}
82  unsigned int getUnixTime() { return munixTime; }
83  char* getDateTime(){ return mdateTime; }
84 
85 };
86 
87 
88 #endif
89 
90 
91 
92 
93 
94 
95