]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliDCSValue.cxx
New versions of GDC and CDH raw data headers. Some CDH getters are added
[u/mrichter/AliRoot.git] / STEER / AliDCSValue.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /*
17 $Log$
18 Revision 1.2  2006/07/04 14:58:11  jgrosseo
19 revision of AliDCSValue: Removed wrapper classes, reduced storage size per value by factor 2
20
21 Revision 1.1  2006/06/02 14:14:36  hristov
22 Separate library for CDB (Jan)
23
24 Revision 1.2  2006/03/07 07:52:34  hristov
25 New version (B.Yordanov)
26
27 Revision 1.2  2005/11/17 14:43:23  byordano
28 import to local CVS
29
30 Revision 1.1.1.1  2005/10/28 07:33:58  hristov
31 Initial import as subdirectory in AliRoot
32
33 Revision 1.1.1.1  2005/09/12 22:11:40  byordano
34 SHUTTLE package
35
36 Revision 1.2  2005/08/30 10:53:23  byordano
37 some more descriptions added
38
39 */
40
41 //
42 // This class represents the value(s) of
43 // a DCS data point at a given timestamp.
44 // It stores different data types, the current implementation has a member for all of them.
45 // This is definitly not efficient, but the only way to use the automatic streamers generated by ROOT.
46 //
47 // Each element of this value series has two fields:
48 // fValue - primitive value which represents the real measured value
49 // fTimestamp - timestamp when the measurement was made
50 //
51
52 #include "AliDCSValue.h"
53
54 #include "TTimeStamp.h"
55 #include <TString.h>
56
57 ClassImp(AliDCSValue)
58
59 AliDCSValue::AliDCSValue() : TObject()
60 {
61   // default constructor
62
63   Init();
64 }
65
66 AliDCSValue::AliDCSValue(Bool_t value, UInt_t timeStamp) : TObject()
67 {
68   // constructor
69
70   Init();
71
72   fTimeStamp = timeStamp;
73
74   fType = kBool;
75   fBool = value;
76 }
77
78 AliDCSValue::AliDCSValue(Char_t value, UInt_t timeStamp) : TObject()
79 {
80   // constructor
81
82   Init();
83
84   fTimeStamp = timeStamp;
85
86   fType = kChar;
87   fChar = value;
88 }
89
90 AliDCSValue::AliDCSValue(Int_t value, UInt_t timeStamp) : TObject()
91 {
92   // constructor
93
94   Init();
95
96   fTimeStamp = timeStamp;
97
98   fType = kInt;
99   fInt = value;
100 }
101
102 AliDCSValue::AliDCSValue(UInt_t value, UInt_t timeStamp) : TObject()
103 {
104   // constructor
105
106   Init();
107
108   fTimeStamp = timeStamp;
109
110   fType = kUInt;
111   fUInt = value;
112 }
113
114 AliDCSValue::AliDCSValue(Float_t value, UInt_t timeStamp) : TObject()
115 {
116   // constructor
117
118   Init();
119
120   fTimeStamp = timeStamp;
121
122   fType = kFloat;
123   fFloat = value;
124 }
125
126 AliDCSValue::AliDCSValue(const AliDCSValue& c) : TObject(c)
127 {
128   // copy constructor
129
130   ((AliDCSValue &)c).Copy(*this);
131 }
132
133 void AliDCSValue::Init()
134 {
135   // init helper, that initializes everything to 0
136
137   fType = kInvalid;
138
139   fBool = kFALSE;
140   fChar = 0;
141   fInt = 0;
142   fUInt = 0;
143   fFloat = 0;
144
145   fTimeStamp = 0;
146 }
147
148 AliDCSValue::~AliDCSValue()
149 {
150   // destructor
151 }
152
153 AliDCSValue &AliDCSValue::operator=(const AliDCSValue &c)
154 {
155   // assigment operator
156
157   if (this != &c) 
158     ((AliDCSValue &) c).Copy(*this);
159
160   return *this;
161 }
162
163 void AliDCSValue::Copy(TObject& c) const
164 {
165   // copy function
166
167   AliDCSValue& target = (AliDCSValue &) c;
168
169   target.Init();
170
171   target.fType = fType;
172
173   target.fBool = fBool;
174   target.fChar = fChar;
175   target.fInt = fInt;
176   target.fUInt = fUInt;
177   target.fFloat = fFloat;
178
179   target.fTimeStamp = fTimeStamp;
180 }
181
182 Int_t AliDCSValue::GetSize() const
183 {
184   // returns size in bytes of stored structure
185
186   Int_t size = sizeof(fTimeStamp);
187
188   switch (fType)
189   {
190     case kBool:  size += sizeof(Bool_t);  break;
191     case kChar:  size += sizeof(Char_t);  break;
192     case kInt:   size += sizeof(Int_t);   break;
193     case kUInt:  size += sizeof(UInt_t);  break;
194     case kFloat: size += sizeof(Float_t); break;
195
196     case kInvalid: break;
197   }
198
199   return size;
200 }
201
202 const Char_t* AliDCSValue::ToString() const
203 {
204   TString str;
205
206   switch (fType)
207   {
208     case kBool:  str.Form("%d", fBool);  break;
209     case kChar:  str.Form("%d", fChar);  break;
210     case kInt:   str.Form("%d", fInt);  break;
211     case kUInt:  str.Form("%d", fUInt);  break;
212     case kFloat: str.Form("%f", fFloat);  break;
213
214     case kInvalid: break;
215   }
216
217   return Form("%s Timestamp: %s", str.Data(), TTimeStamp(fTimeStamp).AsString());
218 }