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 **************************************************************************/
16 ////////////////////////////////////////////////////////////////////////////////
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. //
22 ////////////////////////////////////////////////////////////////////////////////
25 #include "AliDCSArray.h"
28 //#include "TTimeStamp.h"
29 #include <TObjArray.h>
30 #include <TObjString.h>
36 AliDCSArray::AliDCSArray() :
50 // default constructor
54 //--------------------------------------------------------------------------
55 AliDCSArray::AliDCSArray(Int_t nentries, Bool_t* value, Double_t timeStamp) :
59 fBool(new Bool_t[fnentries]),
65 fTimeStamp(timeStamp),
69 // constructor for Bool
72 for (Int_t i = 0; i<fnentries; i++){
77 //--------------------------------------------------------------------------
78 AliDCSArray::AliDCSArray(Int_t nentries, Char_t* value, Double_t timeStamp) :
83 fChar(new Char_t[fnentries]),
88 fTimeStamp(timeStamp),
92 // constructor for Char
94 for (Int_t i = 0; i<fnentries; i++){
99 //-------------------------------------------------------------------------
100 AliDCSArray::AliDCSArray(Int_t nentries, Int_t* value, Double_t timeStamp) :
106 fInt(new Int_t[fnentries]),
110 fTimeStamp(timeStamp),
114 // constructor for Int
116 for (Int_t i = 0; i<fnentries; i++){
121 //-------------------------------------------------------------------------
122 AliDCSArray::AliDCSArray(Int_t nentries, UInt_t* value, Double_t timeStamp) :
129 fUInt(new UInt_t[fnentries]),
132 fTimeStamp(timeStamp),
136 // constructor for UInt
139 for (Int_t i = 0; i<fnentries; i++){
144 //-------------------------------------------------------------------------
145 AliDCSArray::AliDCSArray(Int_t nentries, Float_t* value, Double_t timeStamp) :
153 fFloat(new Float_t[fnentries]),
155 fTimeStamp(timeStamp),
159 // constructor for Float
162 for (Int_t i = 0; i<fnentries; i++){
163 fFloat[i] = value[i];
166 //-------------------------------------------------------------------------
167 AliDCSArray::AliDCSArray(Int_t nentries, Double_t* value, Double_t timeStamp) :
177 fTimeStamp(timeStamp),
178 fDouble(new Double_t[fnentries])
181 // constructor for Double
184 for (Int_t i = 0; i<fnentries; i++){
185 fDouble[i] = value[i];
189 //------------------------------------------------------------------------
190 AliDCSArray::AliDCSArray(Int_t nentries, TObjArray* value, Double_t timeStamp) :
199 fStringArray(new TObjArray()),
200 fTimeStamp(timeStamp),
204 // constructor for String
207 fStringArray->SetOwner(1);
208 for (Int_t i = 0; i<fnentries; i++){
209 TObjString* strobj = new TObjString();
210 strobj->SetString(((TObjString*)value->At(i))->String());
211 fStringArray->Add(strobj);
215 //-----------------------------------------------------------------------
216 AliDCSArray::AliDCSArray(const AliDCSArray& c) :
219 fnentries(c.fnentries),
226 fTimeStamp(c.fTimeStamp),
233 if (fType == kBool && c.fBool){
234 fBool = new Bool_t[fnentries];
235 memcpy(fBool,c.fBool,fnentries*sizeof(Bool_t));
237 if (fType == kChar && c.fChar){
238 fChar = new Char_t[fnentries];
239 memcpy(fChar,c.fChar,fnentries*sizeof(Char_t));
241 if (fType == kUInt && c.fUInt){
242 fUInt = new UInt_t[fnentries];
243 memcpy(fUInt,c.fUInt,fnentries*sizeof(UInt_t));
245 if (fType == kInt && c.fInt){
246 fInt = new Int_t[fnentries];
247 memcpy(fInt,c.fInt,fnentries*sizeof(Int_t));
249 if (fType == kFloat && c.fFloat){
250 fFloat = new Float_t[fnentries];
251 memcpy(fFloat,c.fFloat,fnentries*sizeof(Float_t));
253 if (fType == kDouble && c.fDouble){
254 fDouble = new Double_t[fnentries];
255 memcpy(fDouble,c.fDouble,fnentries*sizeof(Double_t));
257 if (fType == kString && c.fStringArray){
258 fStringArray = new TObjArray();
259 fStringArray->SetOwner(1);
260 for (Int_t i = 0; i<fnentries; i++){
261 TObjString* strobj = new TObjString(*(TObjString*)(c.fStringArray->At(i)));
262 fStringArray->Add(strobj);
268 //-----------------------------------------------------------------------
269 AliDCSArray::~AliDCSArray()
295 if (fStringArray!=0x0){
296 AliInfo("Deleting...");
306 //-----------------------------------------------------------------------
307 AliDCSArray &AliDCSArray::operator=(const AliDCSArray &c)
313 if(&c == this) return *this;
314 if (fType == kBool && c.fBool){
315 fBool = new Bool_t[fnentries];
316 memcpy(fBool,c.fBool,fnentries*sizeof(Bool_t));
318 if (fType == kChar && c.fChar){
319 fChar = new Char_t[fnentries];
320 memcpy(fChar,c.fChar,fnentries*sizeof(Char_t));
322 if (fType == kUInt && c.fUInt){
323 fUInt = new UInt_t[fnentries];
324 memcpy(fUInt,c.fUInt,fnentries*sizeof(UInt_t));
326 if (fType == kInt && c.fInt){
327 fInt = new Int_t[fnentries];
328 memcpy(fInt,c.fInt,fnentries*sizeof(Int_t));
330 if (fType == kFloat && c.fFloat){
331 fFloat = new Float_t[fnentries];
332 memcpy(fFloat,c.fFloat,fnentries*sizeof(Float_t));
334 if (fType == kDouble && c.fDouble){
335 fDouble = new Double_t[fnentries];
336 memcpy(fDouble,c.fDouble,fnentries*sizeof(Double_t));
338 if (fType == kString && c.fStringArray){
339 fStringArray = new TObjArray();
340 fStringArray->SetOwner(1);
341 for (Int_t i = 0; i<fnentries; i++){
342 TObjString* strobj = new TObjString(*(TObjString*)(c.fStringArray->At(i)));
343 fStringArray->Add(strobj);
350 //-----------------------------------------------------------------------
351 void AliDCSArray::Init()
354 // init helper, that initializes everything to 0