]>
Commit | Line | Data |
---|---|---|
57459306 | 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$ | |
fe12e09c | 18 | Revision 1.3 2006/07/20 09:43:46 jgrosseo |
19 | removing dynamic types | |
20 | ||
60d864bd | 21 | Revision 1.2 2006/07/04 14:58:11 jgrosseo |
22 | revision of AliDCSValue: Removed wrapper classes, reduced storage size per value by factor 2 | |
23 | ||
45a493ce | 24 | Revision 1.1 2006/06/02 14:14:36 hristov |
25 | Separate library for CDB (Jan) | |
26 | ||
57459306 | 27 | Revision 1.2 2006/03/07 07:52:34 hristov |
28 | New version (B.Yordanov) | |
29 | ||
30 | Revision 1.2 2005/11/17 14:43:23 byordano | |
31 | import to local CVS | |
32 | ||
33 | Revision 1.1.1.1 2005/10/28 07:33:58 hristov | |
34 | Initial import as subdirectory in AliRoot | |
35 | ||
36 | Revision 1.1.1.1 2005/09/12 22:11:40 byordano | |
37 | SHUTTLE package | |
38 | ||
39 | Revision 1.2 2005/08/30 10:53:23 byordano | |
40 | some more descriptions added | |
41 | ||
42 | */ | |
43 | ||
44 | // | |
45a493ce | 45 | // This class represents the value(s) of |
46 | // a DCS data point at a given timestamp. | |
47 | // It stores different data types, the current implementation has a member for all of them. | |
48 | // This is definitly not efficient, but the only way to use the automatic streamers generated by ROOT. | |
49 | // | |
57459306 | 50 | // Each element of this value series has two fields: |
51 | // fValue - primitive value which represents the real measured value | |
52 | // fTimestamp - timestamp when the measurement was made | |
53 | // | |
54 | ||
55 | #include "AliDCSValue.h" | |
56 | ||
57 | #include "TTimeStamp.h" | |
45a493ce | 58 | #include <TString.h> |
57459306 | 59 | |
60 | ClassImp(AliDCSValue) | |
61 | ||
fe12e09c | 62 | AliDCSValue::AliDCSValue() : |
63 | TObject(), | |
64 | fType(kInvalid), | |
65 | fBool(kFALSE), | |
66 | fChar(0), | |
67 | fInt(0), | |
68 | fUInt(0), | |
69 | fFloat(0), | |
70 | fTimeStamp(0) | |
45a493ce | 71 | { |
72 | // default constructor | |
45a493ce | 73 | } |
74 | ||
fe12e09c | 75 | AliDCSValue::AliDCSValue(Bool_t value, UInt_t timeStamp) : |
76 | TObject(), | |
77 | fType(kBool), | |
78 | fBool(value), | |
79 | fChar(0), | |
80 | fInt(0), | |
81 | fUInt(0), | |
82 | fFloat(0), | |
83 | fTimeStamp(timeStamp) | |
45a493ce | 84 | { |
85 | // constructor | |
45a493ce | 86 | } |
87 | ||
fe12e09c | 88 | AliDCSValue::AliDCSValue(Char_t value, UInt_t timeStamp) : |
89 | TObject(), | |
90 | fType(kChar), | |
91 | fBool(kFALSE), | |
92 | fChar(value), | |
93 | fInt(0), | |
94 | fUInt(0), | |
95 | fFloat(0), | |
96 | fTimeStamp(timeStamp) | |
45a493ce | 97 | { |
98 | // constructor | |
45a493ce | 99 | } |
100 | ||
fe12e09c | 101 | AliDCSValue::AliDCSValue(Int_t value, UInt_t timeStamp) : |
102 | TObject(), | |
103 | fType(kInt), | |
104 | fBool(kFALSE), | |
105 | fChar(0), | |
106 | fInt(value), | |
107 | fUInt(0), | |
108 | fFloat(0), | |
109 | fTimeStamp(timeStamp) | |
45a493ce | 110 | { |
111 | // constructor | |
45a493ce | 112 | } |
113 | ||
fe12e09c | 114 | AliDCSValue::AliDCSValue(UInt_t value, UInt_t timeStamp) : |
115 | TObject(), | |
116 | fType(kUInt), | |
117 | fBool(kFALSE), | |
118 | fChar(0), | |
119 | fInt(0), | |
120 | fUInt(value), | |
121 | fFloat(0), | |
122 | fTimeStamp(timeStamp) | |
45a493ce | 123 | { |
124 | // constructor | |
45a493ce | 125 | } |
126 | ||
fe12e09c | 127 | AliDCSValue::AliDCSValue(Float_t value, UInt_t timeStamp) : |
128 | TObject(), | |
129 | fType(kFloat), | |
130 | fBool(kFALSE), | |
131 | fChar(0), | |
132 | fInt(0), | |
133 | fUInt(0), | |
134 | fFloat(value), | |
135 | fTimeStamp(timeStamp) | |
45a493ce | 136 | { |
137 | // constructor | |
138 | ||
139 | Init(); | |
140 | ||
141 | fTimeStamp = timeStamp; | |
142 | ||
143 | fType = kFloat; | |
144 | fFloat = value; | |
145 | } | |
146 | ||
fe12e09c | 147 | AliDCSValue::AliDCSValue(const AliDCSValue& c) : |
148 | TObject(c), | |
149 | fType(c.fType), | |
150 | fBool(c.fBool), | |
151 | fChar(c.fChar), | |
152 | fInt(c.fInt), | |
153 | fUInt(c.fUInt), | |
154 | fFloat(c.fFloat), | |
155 | fTimeStamp(c.fTimeStamp) | |
45a493ce | 156 | { |
157 | // copy constructor | |
45a493ce | 158 | } |
159 | ||
160 | void AliDCSValue::Init() | |
161 | { | |
162 | // init helper, that initializes everything to 0 | |
163 | ||
164 | fType = kInvalid; | |
165 | ||
166 | fBool = kFALSE; | |
167 | fChar = 0; | |
168 | fInt = 0; | |
169 | fUInt = 0; | |
170 | fFloat = 0; | |
171 | ||
45a493ce | 172 | fTimeStamp = 0; |
173 | } | |
174 | ||
175 | AliDCSValue::~AliDCSValue() | |
176 | { | |
177 | // destructor | |
57459306 | 178 | } |
179 | ||
45a493ce | 180 | AliDCSValue &AliDCSValue::operator=(const AliDCSValue &c) |
57459306 | 181 | { |
45a493ce | 182 | // assigment operator |
57459306 | 183 | |
45a493ce | 184 | if (this != &c) |
185 | ((AliDCSValue &) c).Copy(*this); | |
186 | ||
187 | return *this; | |
57459306 | 188 | } |
189 | ||
45a493ce | 190 | void AliDCSValue::Copy(TObject& c) const |
191 | { | |
192 | // copy function | |
193 | ||
194 | AliDCSValue& target = (AliDCSValue &) c; | |
195 | ||
196 | target.Init(); | |
197 | ||
198 | target.fType = fType; | |
57459306 | 199 | |
45a493ce | 200 | target.fBool = fBool; |
201 | target.fChar = fChar; | |
202 | target.fInt = fInt; | |
203 | target.fUInt = fUInt; | |
204 | target.fFloat = fFloat; | |
57459306 | 205 | |
45a493ce | 206 | target.fTimeStamp = fTimeStamp; |
57459306 | 207 | } |
208 | ||
45a493ce | 209 | Int_t AliDCSValue::GetSize() const |
210 | { | |
211 | // returns size in bytes of stored structure | |
212 | ||
213 | Int_t size = sizeof(fTimeStamp); | |
214 | ||
215 | switch (fType) | |
216 | { | |
217 | case kBool: size += sizeof(Bool_t); break; | |
218 | case kChar: size += sizeof(Char_t); break; | |
219 | case kInt: size += sizeof(Int_t); break; | |
220 | case kUInt: size += sizeof(UInt_t); break; | |
221 | case kFloat: size += sizeof(Float_t); break; | |
222 | ||
45a493ce | 223 | case kInvalid: break; |
224 | } | |
57459306 | 225 | |
45a493ce | 226 | return size; |
227 | } | |
228 | ||
45a493ce | 229 | const Char_t* AliDCSValue::ToString() const |
230 | { | |
231 | TString str; | |
232 | ||
233 | switch (fType) | |
234 | { | |
235 | case kBool: str.Form("%d", fBool); break; | |
236 | case kChar: str.Form("%d", fChar); break; | |
237 | case kInt: str.Form("%d", fInt); break; | |
238 | case kUInt: str.Form("%d", fUInt); break; | |
239 | case kFloat: str.Form("%f", fFloat); break; | |
240 | ||
45a493ce | 241 | case kInvalid: break; |
242 | } | |
243 | ||
244 | return Form("%s Timestamp: %s", str.Data(), TTimeStamp(fTimeStamp).AsString()); | |
245 | } |