Merge branch 'master' into TPCdev
[u/mrichter/AliRoot.git] / STEER / STEER / AliDCSArray.cxx
CommitLineData
d96c6484 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// //
18// This class represents the value(s) of a the LHC DPs at a given timestamp //
19// The variuos measurement that occurred at the same timestamp are associated //
20// to the same timestamp. //
21// //
22////////////////////////////////////////////////////////////////////////////////
23
24
25#include "AliDCSArray.h"
30ec5bf7 26#include "AliLog.h"
d96c6484 27
30ec5bf7 28//#include "TTimeStamp.h"
29#include <TObjArray.h>
30#include <TObjString.h>
d96c6484 31#include <TString.h>
30ec5bf7 32#include <TMath.h>
d96c6484 33
34ClassImp(AliDCSArray)
35
36AliDCSArray::AliDCSArray() :
37 TObject(),
38 fType(kInvalid),
39 fnentries(0),
40 fBool(0x0),
41 fChar(0x0),
42 fInt(0x0),
43 fUInt(0x0),
44 fFloat(0x0),
30ec5bf7 45 fStringArray(0x0),
46 fTimeStamp(-1.),
47 fDouble(0x0)
d96c6484 48{
49 //
50 // default constructor
51 //
52}
53
54//--------------------------------------------------------------------------
30ec5bf7 55AliDCSArray::AliDCSArray(Int_t nentries, Bool_t* value, Double_t timeStamp) :
d96c6484 56 TObject(),
57 fType(kBool),
58 fnentries(nentries),
59 fBool(new Bool_t[fnentries]),
60 fChar(0x0),
61 fInt(0x0),
62 fUInt(0x0),
63 fFloat(0x0),
30ec5bf7 64 fStringArray(0x0),
65 fTimeStamp(timeStamp),
66 fDouble(0x0)
d96c6484 67{
68 //
69 // constructor for Bool
70 //
71
72 for (Int_t i = 0; i<fnentries; i++){
73 fBool[i] = value[i];
74 }
75}
76
77//--------------------------------------------------------------------------
30ec5bf7 78AliDCSArray::AliDCSArray(Int_t nentries, Char_t* value, Double_t timeStamp) :
d96c6484 79 TObject(),
80 fType(kChar),
81 fnentries(nentries),
82 fBool(0x0),
83 fChar(new Char_t[fnentries]),
84 fInt(0x0),
85 fUInt(0x0),
86 fFloat(0x0),
30ec5bf7 87 fStringArray(0x0),
88 fTimeStamp(timeStamp),
89 fDouble(0x0)
d96c6484 90{
91 //
92 // constructor for Char
93 //
94 for (Int_t i = 0; i<fnentries; i++){
95 fChar[i] = value[i];
96 }
97}
98
99//-------------------------------------------------------------------------
30ec5bf7 100AliDCSArray::AliDCSArray(Int_t nentries, Int_t* value, Double_t timeStamp) :
d96c6484 101 TObject(),
102 fType(kInt),
103 fnentries(nentries),
104 fBool(0x0),
105 fChar(0x0),
106 fInt(new Int_t[fnentries]),
107 fUInt(0x0),
108 fFloat(0x0),
30ec5bf7 109 fStringArray(0x0),
110 fTimeStamp(timeStamp),
111 fDouble(0x0)
d96c6484 112{
113 //
114 // constructor for Int
115 //
116 for (Int_t i = 0; i<fnentries; i++){
117 fInt[i] = value[i];
118 }
119}
120
121//-------------------------------------------------------------------------
30ec5bf7 122AliDCSArray::AliDCSArray(Int_t nentries, UInt_t* value, Double_t timeStamp) :
d96c6484 123 TObject(),
124 fType(kUInt),
125 fnentries(nentries),
126 fBool(0x0),
127 fChar(0x0),
128 fInt(0x0),
129 fUInt(new UInt_t[fnentries]),
130 fFloat(0x0),
30ec5bf7 131 fStringArray(0x0),
132 fTimeStamp(timeStamp),
133 fDouble(0x0)
d96c6484 134{
135 //
136 // constructor for UInt
137 //
138
139 for (Int_t i = 0; i<fnentries; i++){
140 fUInt[i] = value[i];
141 }
142}
143
144//-------------------------------------------------------------------------
30ec5bf7 145AliDCSArray::AliDCSArray(Int_t nentries, Float_t* value, Double_t timeStamp) :
d96c6484 146 TObject(),
147 fType(kFloat),
148 fnentries(nentries),
149 fBool(0x0),
150 fChar(0x0),
151 fInt(0x0),
152 fUInt(0x0),
153 fFloat(new Float_t[fnentries]),
30ec5bf7 154 fStringArray(0x0),
155 fTimeStamp(timeStamp),
156 fDouble(0x0)
d96c6484 157{
158 //
159 // constructor for Float
160 //
161
162 for (Int_t i = 0; i<fnentries; i++){
163 fFloat[i] = value[i];
164 }
165}
30ec5bf7 166//-------------------------------------------------------------------------
167AliDCSArray::AliDCSArray(Int_t nentries, Double_t* value, Double_t timeStamp) :
168 TObject(),
169 fType(kDouble),
170 fnentries(nentries),
171 fBool(0x0),
172 fChar(0x0),
173 fInt(0x0),
174 fUInt(0x0),
175 fFloat(0x0),
176 fStringArray(0x0),
177 fTimeStamp(timeStamp),
178 fDouble(new Double_t[fnentries])
179{
180 //
181 // constructor for Double
182 //
183
184 for (Int_t i = 0; i<fnentries; i++){
185 fDouble[i] = value[i];
186 }
187}
d96c6484 188
189//------------------------------------------------------------------------
30ec5bf7 190AliDCSArray::AliDCSArray(Int_t nentries, TObjArray* value, Double_t timeStamp) :
d96c6484 191 TObject(),
192 fType(kString),
193 fnentries(nentries),
194 fBool(0x0),
195 fChar(0x0),
196 fInt(0x0),
197 fUInt(0x0),
198 fFloat(0x0),
30ec5bf7 199 fStringArray(new TObjArray()),
200 fTimeStamp(timeStamp),
201 fDouble(0x0)
d96c6484 202{
203 //
204 // constructor for String
205 //
206
30ec5bf7 207 fStringArray->SetOwner(1);
d96c6484 208 for (Int_t i = 0; i<fnentries; i++){
30ec5bf7 209 TObjString* strobj = new TObjString();
210 strobj->SetString(((TObjString*)value->At(i))->String());
211 fStringArray->Add(strobj);
d96c6484 212 }
213}
214
215//-----------------------------------------------------------------------
d96c6484 216AliDCSArray::~AliDCSArray()
217{
218 //
219 // destructor
220 //
221
222 if (fBool){
e541e2aa 223 delete [] fBool;
30ec5bf7 224 fBool = 0x0;
d96c6484 225 }
226 if (fChar){
e541e2aa 227 delete [] fChar;
30ec5bf7 228 fChar = 0x0;
d96c6484 229 }
230 if (fUInt){
e541e2aa 231 delete [] fUInt;
30ec5bf7 232 fUInt = 0x0;
d96c6484 233 }
234 if (fInt){
e541e2aa 235 delete [] fInt;
30ec5bf7 236 fInt = 0x0;
d96c6484 237 }
238 if (fFloat){
e541e2aa 239 delete [] fFloat;
30ec5bf7 240 fFloat = 0x0;
d96c6484 241 }
30ec5bf7 242 if (fStringArray!=0x0){
30ec5bf7 243 delete fStringArray;
244 fStringArray = 0x0;
d96c6484 245 }
30ec5bf7 246 if (fDouble){
e541e2aa 247 delete [] fDouble;
30ec5bf7 248 fDouble = 0x0;
d96c6484 249 }
250}
251
252//-----------------------------------------------------------------------
d96c6484 253void AliDCSArray::Init()
254{
255 //
256 // init helper, that initializes everything to 0
257 //
258
259 fType = kInvalid;
260
261 fnentries = 0;
262 fBool = 0x0;
263 fChar = 0x0;
264 fInt = 0x0;
265 fUInt = 0x0;
266 fFloat = 0x0;
30ec5bf7 267 fDouble = 0x0;
268 fStringArray = 0x0;
d96c6484 269
30ec5bf7 270 fTimeStamp = -1.;
d96c6484 271}
30ec5bf7 272