1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 Revision 1.4 2006/09/04 17:42:34 hristov
19 Changes required by Effective C++
21 Revision 1.3 2006/07/20 09:43:46 jgrosseo
22 removing dynamic types
24 Revision 1.2 2006/07/04 14:58:11 jgrosseo
25 revision of AliDCSValue: Removed wrapper classes, reduced storage size per value by factor 2
27 Revision 1.1 2006/06/02 14:14:36 hristov
28 Separate library for CDB (Jan)
30 Revision 1.2 2006/03/07 07:52:34 hristov
31 New version (B.Yordanov)
33 Revision 1.2 2005/11/17 14:43:23 byordano
36 Revision 1.1.1.1 2005/10/28 07:33:58 hristov
37 Initial import as subdirectory in AliRoot
39 Revision 1.1.1.1 2005/09/12 22:11:40 byordano
42 Revision 1.2 2005/08/30 10:53:23 byordano
43 some more descriptions added
48 // This class represents the value(s) of
49 // a DCS data point at a given timestamp.
50 // It stores different data types, the current implementation has a member for all of them.
51 // This is definitly not efficient, but the only way to use the automatic streamers generated by ROOT.
53 // Each element of this value series has two fields:
54 // fValue - primitive value which represents the real measured value
55 // fTimestamp - timestamp when the measurement was made
58 #include "AliDCSValue.h"
61 #include "TTimeStamp.h"
66 AliDCSValue::AliDCSValue() :
76 // default constructor
79 AliDCSValue::AliDCSValue(Bool_t value, UInt_t timeStamp) :
92 AliDCSValue::AliDCSValue(Char_t value, UInt_t timeStamp) :
100 fTimeStamp(timeStamp)
105 AliDCSValue::AliDCSValue(Int_t value, UInt_t timeStamp) :
113 fTimeStamp(timeStamp)
118 AliDCSValue::AliDCSValue(UInt_t value, UInt_t timeStamp) :
126 fTimeStamp(timeStamp)
131 AliDCSValue::AliDCSValue(Float_t value, UInt_t timeStamp) :
139 fTimeStamp(timeStamp)
145 fTimeStamp = timeStamp;
151 AliDCSValue::AliDCSValue(const AliDCSValue& c) :
159 fTimeStamp(c.fTimeStamp)
164 void AliDCSValue::Init()
166 // init helper, that initializes everything to 0
179 AliDCSValue::~AliDCSValue()
184 AliDCSValue &AliDCSValue::operator=(const AliDCSValue &c)
186 // assigment operator
189 ((AliDCSValue &) c).Copy(*this);
194 void AliDCSValue::Copy(TObject& c) const
198 AliDCSValue& target = (AliDCSValue &) c;
202 target.fType = fType;
204 target.fBool = fBool;
205 target.fChar = fChar;
207 target.fUInt = fUInt;
208 target.fFloat = fFloat;
210 target.fTimeStamp = fTimeStamp;
213 Int_t AliDCSValue::GetSize() const
215 // returns size in bytes of stored structure
217 Int_t size = sizeof(fTimeStamp);
221 case kBool: size += sizeof(Bool_t); break;
222 case kChar: size += sizeof(Char_t); break;
223 case kInt: size += sizeof(Int_t); break;
224 case kUInt: size += sizeof(UInt_t); break;
225 case kFloat: size += sizeof(Float_t); break;
227 case kInvalid: break;
233 const Char_t* AliDCSValue::ToString() const
239 case kBool: str = (fBool == kFALSE) ? "FALSE" : "TRUE"; break;
240 case kChar: str.Form("%d", fChar); break;
241 case kInt: str.Form("%d", fInt); break;
242 case kUInt: str.Form("%d", fUInt); break;
243 case kFloat: str.Form("%f", fFloat); break;
245 case kInvalid: break;
248 return Form("%s Timestamp: %s (%d)", str.Data(), TTimeStamp(fTimeStamp).AsString(), fTimeStamp);
251 void AliDCSValue::Print(Option_t* /*opt*/) const
253 printf("%s\n", ToString());
256 Bool_t AliDCSValue::GetBool() const
259 if (fType!=kBool) AliError(Form("invalid request, object is not of type kBool (%d) but %d", kBool, fType));
263 Char_t AliDCSValue::GetChar() const
266 if (fType!=kChar) AliError(Form("invalid request, object is not of type kChar (%d) but %d", kChar, fType));
270 Int_t AliDCSValue::GetInt() const
273 if (fType!=kInt) AliError(Form("invalid request, object is not of type kInt (%d) but %d", kInt, fType));
277 UInt_t AliDCSValue::GetUInt() const
280 if (fType!=kUInt) AliError(Form("invalid request, object is not of type kUInt (%d) but %d", kUInt, fType));
284 Float_t AliDCSValue::GetFloat() const
286 // return float value
287 if (fType!=kFloat) AliError(Form("invalid request, object is not of type kFloat (%d) but %d", kFloat, fType));