]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliDCSArray.cxx
Adding TString in the included files.
[u/mrichter/AliRoot.git] / STEER / AliDCSArray.cxx
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"
26 #include "AliLog.h"
27
28 //#include "TTimeStamp.h"
29 #include <TObjArray.h>
30 #include <TObjString.h>
31 #include <TString.h>
32 #include <TMath.h>
33
34 ClassImp(AliDCSArray)
35         
36 AliDCSArray::AliDCSArray() :
37                 TObject(),
38                 fType(kInvalid),
39                 fnentries(0),
40                 fBool(0x0),
41                 fChar(0x0),
42                 fInt(0x0),
43                 fUInt(0x0),
44                 fFloat(0x0),
45                 fStringArray(0x0),
46                 fTimeStamp(-1.),
47                 fDouble(0x0)
48 {
49         //
50         // default constructor
51         //
52 }
53
54 //--------------------------------------------------------------------------
55 AliDCSArray::AliDCSArray(Int_t nentries, Bool_t* value, Double_t timeStamp) : 
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),
64         fStringArray(0x0),
65         fTimeStamp(timeStamp),
66         fDouble(0x0)
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 //--------------------------------------------------------------------------
78 AliDCSArray::AliDCSArray(Int_t nentries, Char_t* value, Double_t timeStamp) :
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),
87         fStringArray(0x0),
88         fTimeStamp(timeStamp),
89         fDouble(0x0)
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 //-------------------------------------------------------------------------
100 AliDCSArray::AliDCSArray(Int_t nentries, Int_t* value, Double_t timeStamp) :
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),
109         fStringArray(0x0),
110         fTimeStamp(timeStamp),
111         fDouble(0x0)
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 //-------------------------------------------------------------------------
122 AliDCSArray::AliDCSArray(Int_t nentries, UInt_t* value, Double_t timeStamp) :
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),
131         fStringArray(0x0),
132         fTimeStamp(timeStamp),
133         fDouble(0x0)
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 //-------------------------------------------------------------------------
145 AliDCSArray::AliDCSArray(Int_t nentries, Float_t* value, Double_t timeStamp) :
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]),
154         fStringArray(0x0),
155         fTimeStamp(timeStamp),
156         fDouble(0x0)
157 {
158         //
159         // constructor for Float
160         //
161
162         for (Int_t i = 0; i<fnentries; i++){
163                 fFloat[i] = value[i];
164         }
165 }
166 //-------------------------------------------------------------------------
167 AliDCSArray::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 }
188
189 //------------------------------------------------------------------------
190 AliDCSArray::AliDCSArray(Int_t nentries, TObjArray* value, Double_t timeStamp) :
191         TObject(),
192         fType(kString),
193         fnentries(nentries),
194         fBool(0x0),
195         fChar(0x0),
196         fInt(0x0),
197         fUInt(0x0),
198         fFloat(0x0),
199         fStringArray(new TObjArray()),
200         fTimeStamp(timeStamp),
201         fDouble(0x0)
202 {
203         //
204         // constructor for String
205         //
206
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);
212         }
213 }
214
215 //-----------------------------------------------------------------------
216 AliDCSArray::AliDCSArray(const AliDCSArray& c) :
217         TObject(c),
218         fType(c.fType),
219         fnentries(c.fnentries),
220         fBool(0x0),
221         fChar(0x0),
222         fInt(0x0),
223         fUInt(0x0),
224         fFloat(0x0),
225         fStringArray(0x0),
226         fTimeStamp(c.fTimeStamp),
227         fDouble(0x0)
228 {
229         //
230         // copy constructor
231         //
232         
233         if (fType == kBool && c.fBool){
234                 fBool = new Bool_t[fnentries];
235                 memcpy(fBool,c.fBool,fnentries*sizeof(Bool_t));
236         } 
237         if (fType == kChar && c.fChar){
238                 fChar = new Char_t[fnentries];
239                 memcpy(fChar,c.fChar,fnentries*sizeof(Char_t));
240         } 
241         if (fType == kUInt && c.fUInt){
242                 fUInt = new UInt_t[fnentries];
243                 memcpy(fUInt,c.fUInt,fnentries*sizeof(UInt_t));
244         } 
245         if (fType == kInt && c.fInt){
246                 fInt = new Int_t[fnentries];
247                 memcpy(fInt,c.fInt,fnentries*sizeof(Int_t));
248         } 
249         if (fType == kFloat && c.fFloat){
250                 fFloat = new Float_t[fnentries];
251                 memcpy(fFloat,c.fFloat,fnentries*sizeof(Float_t));
252         } 
253         if (fType == kDouble && c.fDouble){
254                 fDouble = new Double_t[fnentries];
255                 memcpy(fDouble,c.fDouble,fnentries*sizeof(Double_t));
256         } 
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);
263                 }
264         }
265
266 }
267
268 //-----------------------------------------------------------------------
269 AliDCSArray::~AliDCSArray()
270 {
271         //
272         // destructor
273         //
274
275         if (fBool){
276                 delete fBool;
277                 fBool = 0x0;
278         }
279         if (fChar){
280                 delete fChar;
281                 fChar = 0x0;
282         }
283         if (fUInt){
284                 delete fUInt;
285                 fUInt = 0x0;
286         }
287         if (fInt){
288                 delete fInt;
289                 fInt = 0x0;
290         }
291         if (fFloat){
292                 delete fFloat;
293                 fFloat = 0x0;
294         }
295         if (fStringArray!=0x0){
296                 AliInfo("Deleting...");
297                 delete fStringArray;
298                 fStringArray = 0x0;
299         }
300         if (fDouble){
301                 delete fDouble;
302                 fDouble = 0x0;
303         }
304 }
305
306 //-----------------------------------------------------------------------
307 AliDCSArray &AliDCSArray::operator=(const AliDCSArray &c)
308 {
309         //
310         // operator = 
311         //
312         
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));
317         } 
318         if (fType == kChar && c.fChar){
319                 fChar = new Char_t[fnentries];
320                 memcpy(fChar,c.fChar,fnentries*sizeof(Char_t));
321         } 
322         if (fType == kUInt && c.fUInt){
323                 fUInt = new UInt_t[fnentries];
324                 memcpy(fUInt,c.fUInt,fnentries*sizeof(UInt_t));
325         } 
326         if (fType == kInt && c.fInt){
327                 fInt = new Int_t[fnentries];
328                 memcpy(fInt,c.fInt,fnentries*sizeof(Int_t));
329         } 
330         if (fType == kFloat && c.fFloat){
331                 fFloat = new Float_t[fnentries];
332                 memcpy(fFloat,c.fFloat,fnentries*sizeof(Float_t));
333         } 
334         if (fType == kDouble && c.fDouble){
335                 fDouble = new Double_t[fnentries];
336                 memcpy(fDouble,c.fDouble,fnentries*sizeof(Double_t));
337         } 
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);
344                 }
345         }
346
347         return *this;
348 }
349
350 //-----------------------------------------------------------------------
351 void AliDCSArray::Init()
352 {
353         //
354         // init helper, that initializes everything to 0
355         //
356         
357         fType = kInvalid;
358         
359         fnentries = 0;
360         fBool = 0x0;
361         fChar = 0x0;
362         fInt = 0x0;
363         fUInt = 0x0;
364         fFloat = 0x0;
365         fDouble = 0x0;
366         fStringArray = 0x0;
367         
368         fTimeStamp = -1.;
369 }
370