]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliSimpleValue.h
Geometry builder classes moved from base to sim.
[u/mrichter/AliRoot.git] / STEER / AliSimpleValue.h
CommitLineData
57459306 1#ifndef ALI_SIMPLE_VALUE_H
2#define ALI_SIMPLE_VALUE_H
3
4/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
6
7/* $Id$ */
8
9//
10// This class is a simple wrapper of
11// all primitive types used in PVSS SCADA system.
0bd5d12b 12// bool, char, byte, int ,uint, float, and arrays of these values
57459306 13//
14
15#include <TObject.h>
16#include <TString.h>
17
18class AliSimpleValue: public TObject {
19public:
20 enum Type {
21 kInvalid = 0,
22 kBool = 1,
23 kByte = 2,
24 kInt = 3,
25 kUInt = 4,
26 kFloat = 5,
27 kDynBool = 11,
28 kDynByte = 12,
29 kDynInt = 13,
30 kDynUInt = 14,
31 kDynFloat = 15
32 };
33
34
35 AliSimpleValue();
36
37 AliSimpleValue(const AliSimpleValue& other);
38
39 AliSimpleValue(Type type, Int_t size = 0);
40
41 AliSimpleValue(Bool_t val);
42
43 AliSimpleValue(Char_t val);
44
45 AliSimpleValue(Int_t val);
46
47 AliSimpleValue(UInt_t val);
48
49 AliSimpleValue(Float_t val);
50
51 AliSimpleValue(Int_t size, const Bool_t* vals);
52
53 AliSimpleValue(Int_t size, const Char_t* vals);
54
55 AliSimpleValue(Int_t size, const Int_t* vals);
56
57 AliSimpleValue(Int_t size, const UInt_t* vals);
58
59 AliSimpleValue(Int_t size, const Float_t* vals);
60
61 ~AliSimpleValue();
62
63
64 AliSimpleValue& operator=(const AliSimpleValue& other);
65
66 Bool_t operator==(const AliSimpleValue& other) const;
67
68 void SetBool(Bool_t val);
69
70 void SetByte(Char_t val);
71
72 void SetInt(Int_t val);
73
74 void SetUInt(UInt_t val);
75
76 void SetFloat(Float_t val);
77
78
79 Bool_t GetBool() const;
80
81 Char_t GetByte() const;
82
83 Int_t GetInt() const;
84
85 UInt_t GetUInt() const;
86
87 Float_t GetFloat() const;
88
89
90 void SetDynBool(Int_t n, Bool_t val);
91
92 void SetDynByte(Int_t n, Char_t val);
93
94 void SetDynInt(Int_t n, Int_t val);
95
96 void SetDynUInt(Int_t n, UInt_t val);
97
98 void SetDynFloat(Int_t n, Float_t val);
99
100
101 Bool_t GetDynBool(Int_t n) const;
102
103 Char_t GetDynByte(Int_t n) const;
104
105 Int_t GetDynInt(Int_t n) const;
106
107 UInt_t GetDynUInt(Int_t n) const;
108
109 Float_t GetDynFloat(Int_t n) const;
110
111
112 Type GetType() const {return fType;};
113
114 Int_t GetSize() const;
115
116 Int_t GetDynamicSize() const;
117
118 TString ToString() const;
119
120
121 static Bool_t IsDynamic(Type type);
122
123 static Int_t GetPrimitiveSize(Type type);
124
125 static const char* GetTypeString(Type type);
126
127private:
128
0bd5d12b 129 class AliBoolHolder: public TObject {
130
131 friend class AliSimpleValue;
132
57459306 133 public:
0bd5d12b 134 AliBoolHolder() {}
135 virtual ~AliBoolHolder() {}
57459306 136
0bd5d12b 137 AliBoolHolder(Bool_t val):fValue(val) {}
57459306 138
139 virtual TObject* Clone(const char* name) const;
140
141 virtual Bool_t IsEqual(const TObject* object) const;
142
0bd5d12b 143 private:
144 Bool_t fValue; // The value
145
146 ClassDef(AliBoolHolder, 1);
57459306 147 };
148
0bd5d12b 149 class AliByteHolder: public TObject {
150
151 friend class AliSimpleValue;
152
57459306 153 public:
57459306 154
0bd5d12b 155 AliByteHolder() {};
156 virtual ~AliByteHolder() {}
57459306 157
0bd5d12b 158 AliByteHolder(Char_t val):fValue(val) {}
57459306 159
160 virtual TObject* Clone(const char* name) const;
161
162 virtual Bool_t IsEqual(const TObject* object) const;
163
0bd5d12b 164 private:
165 Char_t fValue; // The value
166
167 ClassDef(AliByteHolder, 1);
57459306 168 };
169
0bd5d12b 170 class AliIntHolder: public TObject {
171
172 friend class AliSimpleValue;
173
57459306 174 public:
57459306 175
0bd5d12b 176 AliIntHolder() {}
177 virtual ~AliIntHolder() {}
57459306 178
0bd5d12b 179 AliIntHolder(Int_t val):fValue(val) {}
57459306 180
181 virtual TObject* Clone(const char* name) const;
182
183 virtual Bool_t IsEqual(const TObject* object) const;
184
0bd5d12b 185
186 private:
187 Int_t fValue; // The value
188
189 ClassDef(AliIntHolder, 1);
57459306 190 };
191
0bd5d12b 192 class AliUIntHolder: public TObject {
193
194 friend class AliSimpleValue;
195
57459306 196 public:
57459306 197
0bd5d12b 198 AliUIntHolder() {}
199 virtual ~AliUIntHolder() {}
57459306 200
0bd5d12b 201 AliUIntHolder(UInt_t val):fValue(val) {}
57459306 202
203 virtual TObject* Clone(const char* name) const;
204
205 virtual Bool_t IsEqual(const TObject* object) const;
206
0bd5d12b 207
208 private:
209 UInt_t fValue; // The value
210
211 ClassDef(AliUIntHolder, 1);
57459306 212 };
213
0bd5d12b 214 class AliFloatHolder: public TObject {
215
216 friend class AliSimpleValue;
217
57459306 218 public:
57459306 219
0bd5d12b 220 AliFloatHolder() {}
221 virtual ~AliFloatHolder() {}
57459306 222
0bd5d12b 223 AliFloatHolder(Float_t val):fValue(val) {}
57459306 224
225 virtual TObject* Clone(const char* name) const;
226
227 virtual Bool_t IsEqual(const TObject* object) const;
228
0bd5d12b 229 private:
230 Float_t fValue; // The value
231
232 ClassDef(AliFloatHolder, 1);
57459306 233 };
234
0bd5d12b 235 class AliDynHolder: public TObject {
236
237 friend class AliSimpleValue;
238
57459306 239 public:
57459306 240
0bd5d12b 241 AliDynHolder(): fSize(0) {}
242 AliDynHolder(Int_t size): fSize(size){}
57459306 243
0bd5d12b 244 Int_t fSize; // The size
245 ClassDef(AliDynHolder, 0);
57459306 246 };
247
0bd5d12b 248 class AliDynBoolHolder: public AliDynHolder {
249
250 friend class AliSimpleValue;
251
57459306 252 public:
57459306 253
0bd5d12b 254 AliDynBoolHolder(): fValues(NULL) {}
57459306 255
0bd5d12b 256 AliDynBoolHolder(Int_t size, const Bool_t* buf = NULL):
257 AliDynHolder(size) {
57459306 258 fValues = new Bool_t[size];
259 if (buf) memcpy(fValues, buf, size * sizeof(Bool_t));
260 }
261
0bd5d12b 262 virtual ~AliDynBoolHolder() {if (fValues) delete[] fValues;}
57459306 263
264 virtual TObject* Clone(const char* name) const;
265
266 virtual Bool_t IsEqual(const TObject* object) const;
267
0bd5d12b 268
269 private:
270 AliDynBoolHolder(const AliDynBoolHolder& /*other*/): AliDynHolder() { }
271 AliDynBoolHolder& operator= (const AliDynBoolHolder& /*other*/) {return *this;}
272 Bool_t* fValues; //[fSize] The value
273
274 ClassDef(AliDynBoolHolder, 1);
57459306 275 };
276
0bd5d12b 277 class AliDynByteHolder: public AliDynHolder {
278
279 friend class AliSimpleValue;
280
57459306 281 public:
57459306 282
0bd5d12b 283 AliDynByteHolder(): fValues(NULL) {}
57459306 284
0bd5d12b 285 AliDynByteHolder(Int_t size, const Char_t* buf = NULL):
286 AliDynHolder(size) {
57459306 287 fValues = new Char_t[size];
288 if (buf) memcpy(fValues, buf, size * sizeof(Char_t));
289 }
290
0bd5d12b 291 virtual ~AliDynByteHolder() {if (fValues) delete[] fValues;}
57459306 292
293 virtual TObject* Clone(const char* name) const;
294
295 virtual Bool_t IsEqual(const TObject* object) const;
296
0bd5d12b 297
298 private:
299 AliDynByteHolder(const AliDynByteHolder& /*other*/): AliDynHolder() { }
300 AliDynByteHolder& operator= (const AliDynByteHolder& /*other*/) {return *this;}
301 Char_t* fValues; //[fSize] The value
302
303 ClassDef(AliDynByteHolder, 1);
57459306 304 };
305
0bd5d12b 306 class AliDynIntHolder: public AliDynHolder {
307
308 friend class AliSimpleValue;
309
57459306 310 public:
57459306 311
0bd5d12b 312 AliDynIntHolder(): fValues(NULL) {}
57459306 313
0bd5d12b 314 AliDynIntHolder(Int_t size, const Int_t* buf = NULL):
315 AliDynHolder(size) {
57459306 316 fValues = new Int_t[size];
317 if (buf) memcpy(fValues, buf, size * sizeof(Int_t));
318 }
319
0bd5d12b 320 virtual ~AliDynIntHolder() {if (fValues) delete[] fValues;}
57459306 321
322 virtual TObject* Clone(const char* name) const;
323
324 virtual Bool_t IsEqual(const TObject* object) const;
325
0bd5d12b 326
327 private:
328 AliDynIntHolder(const AliDynIntHolder& /*other*/): AliDynHolder() { }
329 AliDynIntHolder& operator= (const AliDynIntHolder& /*other*/) {return *this;}
330 Int_t* fValues; //[fSize] The value
331
332 ClassDef(AliDynIntHolder, 1);
57459306 333 };
334
0bd5d12b 335 class AliDynUIntHolder: public AliDynHolder {
336
337 friend class AliSimpleValue;
338
57459306 339 public:
57459306 340
0bd5d12b 341 AliDynUIntHolder(): fValues(NULL) {}
57459306 342
0bd5d12b 343 AliDynUIntHolder(Int_t size, const UInt_t* buf = NULL):
344 AliDynHolder(size) {
57459306 345 fValues = new UInt_t[size];
346 if (buf) memcpy(fValues, buf, size * sizeof(UInt_t));
347 }
348
0bd5d12b 349 virtual ~AliDynUIntHolder() {if (fValues) delete[] fValues;}
57459306 350
351 virtual TObject* Clone(const char* name) const;
352
353 virtual Bool_t IsEqual(const TObject* object) const;
354
0bd5d12b 355
356 private:
357 AliDynUIntHolder(const AliDynUIntHolder& /*other*/): AliDynHolder() { }
358 AliDynUIntHolder& operator= (const AliDynUIntHolder& /*other*/) {return *this;}
359 UInt_t* fValues; //[fSize] The value
360
361 ClassDef(AliDynUIntHolder, 1);
57459306 362 };
363
0bd5d12b 364 class AliDynFloatHolder: public AliDynHolder {
365
366 friend class AliSimpleValue;
367
57459306 368 public:
57459306 369
0bd5d12b 370 AliDynFloatHolder(): fValues(NULL) {}
57459306 371
0bd5d12b 372 AliDynFloatHolder(Int_t size, const Float_t* buf = NULL):
373 AliDynHolder(size) {
57459306 374 fValues = new Float_t[size];
375 if (buf) memcpy(fValues, buf, size * sizeof(Float_t));
376 }
377
0bd5d12b 378 virtual ~AliDynFloatHolder() {if (fValues) delete[] fValues;}
57459306 379
380 virtual TObject* Clone(const char* name) const;
381
382 virtual Bool_t IsEqual(const TObject* object) const;
383
0bd5d12b 384
385 private:
386 AliDynFloatHolder(const AliDynFloatHolder& /*other*/): AliDynHolder() { }
387 AliDynFloatHolder& operator= (const AliDynFloatHolder& /*other*/) {return *this;}
388 Float_t* fValues; //[fSize] The value
389
390 ClassDef(AliDynFloatHolder, 1);
57459306 391 };
392
393
0bd5d12b 394 TObject* fHolder; // Holder of the basic type value
57459306 395
0bd5d12b 396 Type fType; // Type of the basic type value
57459306 397
398
399 Bool_t TypeOk(Type type) const;
400
401 Bool_t BoundsOk(Int_t n) const;
402
403
404 ClassDef(AliSimpleValue, 1);
405};
406
407#endif