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"
60 #include "TTimeStamp.h"
65 AliDCSValue::AliDCSValue() :
75 // default constructor
78 AliDCSValue::AliDCSValue(Bool_t value, UInt_t timeStamp) :
91 AliDCSValue::AliDCSValue(Char_t value, UInt_t timeStamp) :
104 AliDCSValue::AliDCSValue(Int_t value, UInt_t timeStamp) :
112 fTimeStamp(timeStamp)
117 AliDCSValue::AliDCSValue(UInt_t value, UInt_t timeStamp) :
125 fTimeStamp(timeStamp)
130 AliDCSValue::AliDCSValue(Float_t value, UInt_t timeStamp) :
138 fTimeStamp(timeStamp)
144 fTimeStamp = timeStamp;
150 AliDCSValue::AliDCSValue(const AliDCSValue& c) :
158 fTimeStamp(c.fTimeStamp)
163 void AliDCSValue::Init()
165 // init helper, that initializes everything to 0
178 AliDCSValue::~AliDCSValue()
183 AliDCSValue &AliDCSValue::operator=(const AliDCSValue &c)
185 // assigment operator
188 ((AliDCSValue &) c).Copy(*this);
193 void AliDCSValue::Copy(TObject& c) const
197 AliDCSValue& target = (AliDCSValue &) c;
201 target.fType = fType;
203 target.fBool = fBool;
204 target.fChar = fChar;
206 target.fUInt = fUInt;
207 target.fFloat = fFloat;
209 target.fTimeStamp = fTimeStamp;
212 Int_t AliDCSValue::GetSize() const
214 // returns size in bytes of stored structure
216 Int_t size = sizeof(fTimeStamp);
220 case kBool: size += sizeof(Bool_t); break;
221 case kChar: size += sizeof(Char_t); break;
222 case kInt: size += sizeof(Int_t); break;
223 case kUInt: size += sizeof(UInt_t); break;
224 case kFloat: size += sizeof(Float_t); break;
226 case kInvalid: break;
232 const Char_t* AliDCSValue::ToString() const
238 case kBool: str = (fBool == kFALSE) ? "FALSE" : "TRUE"; break;
239 case kChar: str.Form("%d", fChar); break;
240 case kInt: str.Form("%d", fInt); break;
241 case kUInt: str.Form("%d", fUInt); break;
242 case kFloat: str.Form("%f", fFloat); break;
244 case kInvalid: break;
247 return Form("%s Timestamp: %s (%d)", str.Data(), TTimeStamp(fTimeStamp).AsString(), fTimeStamp);
250 void AliDCSValue::Print(Option_t* /*opt*/) const
252 printf("%s\n", ToString());