Coding conventions (Alberto)
[u/mrichter/AliRoot.git] / STEER / AliSimpleValue.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 $Log$
18 Revision 1.1  2006/06/02 14:14:36  hristov
19 Separate library for CDB (Jan)
20
21 Revision 1.2  2006/03/07 07:52:34  hristov
22 New version (B.Yordanov)
23
24 Revision 1.2  2005/11/17 14:43:23  byordano
25 import to local CVS
26
27 Revision 1.1.1.1  2005/10/28 07:33:58  hristov
28 Initial import as subdirectory in AliRoot
29
30 Revision 1.1.1.1  2005/09/12 22:11:40  byordano
31 SHUTTLE package
32
33 Revision 1.2  2005/08/30 10:53:23  byordano
34 some more descriptions added
35
36 */
37
38 //
39 // This class is a simple wrapper of
40 // all primitive types used in PVSS SCADA system.
41 //
42
43
44 #include "AliSimpleValue.h"
45
46 #include "AliLog.h"
47 #include <TClass.h>
48
49 //______________________________________________________________________
50 TObject* AliSimpleValue::AliBoolHolder::Clone(const char* /*name*/) const {
51         return new AliBoolHolder(fValue);
52 // Clone a value
53
54 }
55
56 //______________________________________________________________________
57 Bool_t AliSimpleValue::AliBoolHolder::IsEqual(const TObject* obj) const {
58 // check whether this is equal to obj
59         
60         if (this == obj) {
61                 return kTRUE;
62         }
63
64         if (AliBoolHolder::Class() != obj->IsA()) {
65                 return kFALSE;
66         }
67
68         return fValue == ((const AliBoolHolder*) obj)->fValue;
69 }
70
71 //______________________________________________________________________
72 TObject* AliSimpleValue::AliByteHolder::Clone(const char* /*name*/) const {
73 // Clone a value
74
75         return new AliByteHolder(fValue);
76 }
77
78 //______________________________________________________________________
79 Bool_t AliSimpleValue::AliByteHolder::IsEqual(const TObject* obj) const {
80 // check whether this is equal to obj
81
82         if (this == obj) {
83                 return kTRUE;
84         }
85
86         if (AliByteHolder::Class() != obj->IsA()) {
87                 return kFALSE;
88         }
89
90         return fValue == ((const AliByteHolder*) obj)->fValue;
91 }
92
93 //______________________________________________________________________
94 TObject* AliSimpleValue::AliIntHolder::Clone(const char* /*name*/) const {
95 // Clone a value
96         return new AliIntHolder(fValue);
97 }
98
99 //______________________________________________________________________
100 Bool_t AliSimpleValue::AliIntHolder::IsEqual(const TObject* obj) const {
101 // check whether this is equal to obj
102
103         if (this == obj) {
104                 return kTRUE;
105         }
106
107         if (AliIntHolder::Class() != obj->IsA()) {
108                 return kFALSE;
109         }
110
111         return fValue == ((const AliIntHolder*) obj)->fValue;
112 }
113
114 //______________________________________________________________________
115 TObject* AliSimpleValue::AliUIntHolder::Clone(const char* /*name*/) const {
116 // Clone a value
117         return new AliUIntHolder(fValue);
118 }
119
120 //______________________________________________________________________
121 Bool_t AliSimpleValue::AliUIntHolder::IsEqual(const TObject* obj) const {
122 // check whether this is equal to obj
123
124         if (this == obj) {
125                 return kTRUE;
126         }
127
128         if (AliUIntHolder::Class() != obj->IsA()) {
129                 return kFALSE;
130         }
131
132         return fValue == ((const AliUIntHolder*) obj)->fValue;
133 }
134
135 //______________________________________________________________________
136 TObject* AliSimpleValue::AliFloatHolder::Clone(const char* /*name*/) const {
137  // Clone a value
138        return new AliFloatHolder(fValue);
139 }
140
141 //______________________________________________________________________
142 Bool_t AliSimpleValue::AliFloatHolder::IsEqual(const TObject* obj) const {
143 // check whether this is equal to obj
144
145         if (this == obj) {
146                 return kTRUE;
147         }
148
149         if (AliFloatHolder::Class() != obj->IsA()) {
150                 return kFALSE;
151         }
152
153         return fValue == ((const AliFloatHolder*) obj)->fValue;
154 }
155
156 //______________________________________________________________________
157 TObject* AliSimpleValue::AliDynBoolHolder::Clone(const char* /*name*/) const {
158  // Clone a value
159        return new AliDynBoolHolder(fSize, fValues);
160 }
161
162 //______________________________________________________________________
163 Bool_t AliSimpleValue::AliDynBoolHolder::IsEqual(const TObject* obj) const {
164 // check whether this is equal to obj
165
166         if (this == obj) {
167                 return kTRUE;
168         }
169
170         if (AliDynBoolHolder::Class() != obj->IsA()) {
171                 return kFALSE;
172         }
173
174         const AliDynBoolHolder* other = ((const AliDynBoolHolder*) obj);
175         
176         if (fSize != other->fSize) {
177                 return kFALSE;
178         }
179
180         return !memcmp(fValues, other->fValues, fSize * sizeof(Bool_t));
181 }
182
183 //______________________________________________________________________
184 TObject* AliSimpleValue::AliDynByteHolder::Clone(const char* /*name*/) const {
185 // Clone a value
186         return new AliDynByteHolder(fSize, fValues);
187 }
188
189 //______________________________________________________________________
190 Bool_t AliSimpleValue::AliDynByteHolder::IsEqual(const TObject* obj) const {
191 // check whether this is equal to obj
192
193         if (this == obj) {
194                 return kTRUE;
195         }
196
197         if (AliDynByteHolder::Class() != obj->IsA()) {
198                 return kFALSE;
199         }
200
201         const AliDynByteHolder* other = ((const AliDynByteHolder*) obj);
202
203         if (fSize != other->fSize) {
204                 return kFALSE;
205         }
206
207         return !memcmp(fValues, other->fValues, fSize * sizeof(Char_t));
208 }
209
210 //______________________________________________________________________
211 TObject* AliSimpleValue::AliDynIntHolder::Clone(const char* /*name*/) const {
212 // Clone a value
213         return new AliDynIntHolder(fSize, fValues);
214 }
215
216 //______________________________________________________________________
217 Bool_t AliSimpleValue::AliDynIntHolder::IsEqual(const TObject* obj) const {
218 // check whether this is equal to obj
219
220        if (this == obj) {
221                 return kTRUE;
222         }
223
224         if (AliDynIntHolder::Class() != obj->IsA()) {
225                 return kFALSE;
226         }
227
228         const AliDynIntHolder* other = ((const AliDynIntHolder*) obj);
229
230         if (fSize != other->fSize) {
231                 return kFALSE;
232         }
233
234         return !memcmp(fValues, other->fValues, fSize * sizeof(Int_t));
235 }
236
237 //______________________________________________________________________
238 TObject* AliSimpleValue::AliDynUIntHolder::Clone(const char* /*name*/) const {
239 // Clone a value
240         return new AliDynUIntHolder(fSize, fValues);
241 }
242
243 //______________________________________________________________________
244 Bool_t AliSimpleValue::AliDynUIntHolder::IsEqual(const TObject* obj) const {
245 // check whether this is equal to obj
246
247         if (this == obj) {
248                 return kTRUE;
249         }
250
251         if (AliDynUIntHolder::Class() != obj->IsA()) {
252                 return kFALSE;
253         }
254
255         const AliDynUIntHolder* other = ((const AliDynUIntHolder*) obj);
256
257         if (fSize != other->fSize) {
258                 return kFALSE;
259         }
260
261         return !memcmp(fValues, other->fValues, fSize * sizeof(UInt_t));
262 }
263
264 //______________________________________________________________________
265 TObject* AliSimpleValue::AliDynFloatHolder::Clone(const char* /*name*/) const {
266         return new AliDynFloatHolder(fSize, fValues);
267 }
268
269 //______________________________________________________________________
270 Bool_t AliSimpleValue::AliDynFloatHolder::IsEqual(const TObject* obj) const {
271 // check whether this is equal to obj
272
273         if (this == obj) {
274                 return kTRUE;
275         }
276
277         if (AliDynFloatHolder::Class() != obj->IsA()) {
278                 return kFALSE;
279         }
280
281         const AliDynFloatHolder* other = ((const AliDynFloatHolder*) obj);
282
283         if (fSize != other->fSize) {
284                 return kFALSE;
285         }
286
287         return !memcmp(fValues, other->fValues, fSize * sizeof(Float_t));
288 }
289
290 //______________________________________________________________________
291 //______________________________________________________________________
292
293 ClassImp(AliSimpleValue)
294
295 //______________________________________________________________________
296 AliSimpleValue::AliSimpleValue():
297         fHolder(NULL), fType(kInvalid)
298 {
299 // empty constructor
300 }
301
302 //______________________________________________________________________
303 AliSimpleValue::AliSimpleValue(const AliSimpleValue& other):
304         TObject(other), fHolder(NULL), fType(other.fType)
305 {
306 // copy contructor
307         if (other.fHolder) {
308                 fHolder = other.fHolder->Clone();
309         }
310 }
311
312 //______________________________________________________________________
313 AliSimpleValue::AliSimpleValue(AliSimpleValue::Type type, Int_t size):
314         fHolder(NULL), fType(type)
315 {
316 // constructor
317         
318         switch (type) {
319                 case kBool:
320                         fHolder = new AliBoolHolder();
321                         break;
322                 case kByte:
323                         fHolder = new AliByteHolder();
324                         break;
325                 case kInt:
326                         fHolder = new AliIntHolder();
327                         break;
328                 case kUInt:
329                         fHolder = new AliUIntHolder();
330                         break;
331                 case kFloat:
332                         fHolder = new AliFloatHolder();
333                         break;
334                 case kDynBool:
335                         fHolder = new AliDynBoolHolder(size);
336                         break;
337                 case kDynByte:
338                         fHolder = new AliDynByteHolder(size);
339                         break;
340                 case kDynInt:
341                         fHolder = new AliDynIntHolder(size);
342                         break;
343                 case kDynUInt:
344                         fHolder = new AliDynUIntHolder(size);
345                         break;
346                 case kDynFloat:
347                         fHolder = new AliDynFloatHolder(size);
348                         break;
349                 default:        
350                         break;
351         }
352 }
353
354 //______________________________________________________________________
355 AliSimpleValue::AliSimpleValue(Bool_t val) {
356 // contructor
357
358         fType = kBool;
359         fHolder = new AliBoolHolder(val);
360 }
361
362 //______________________________________________________________________
363 AliSimpleValue::AliSimpleValue(Char_t val) {
364 // contructor
365         
366         fType = kByte;
367         fHolder = new AliByteHolder(val);
368 }
369
370 //______________________________________________________________________
371 AliSimpleValue::AliSimpleValue(Int_t val) {
372 // contructor
373         
374         fType = kInt;
375         fHolder = new AliIntHolder(val);
376 }
377
378 //______________________________________________________________________
379 AliSimpleValue::AliSimpleValue(UInt_t val) {
380 // contructor
381         
382         fType = kUInt;
383         fHolder = new AliUIntHolder(val);
384 }
385
386 //______________________________________________________________________
387 AliSimpleValue::AliSimpleValue(Float_t val) {
388 // contructor
389
390         fType = kFloat;
391         fHolder = new AliFloatHolder(val);
392 }
393
394 //______________________________________________________________________
395 AliSimpleValue::AliSimpleValue(Int_t size, const Bool_t* buf) {
396 // contructor
397         
398         fType = kDynBool;
399         fHolder = new AliDynBoolHolder(size, buf);
400 }
401
402 //______________________________________________________________________
403 AliSimpleValue::AliSimpleValue(Int_t size, const Char_t* buf) {
404 // contructor
405
406         fType = kDynByte;
407         fHolder = new AliDynByteHolder(size, buf);
408 }
409
410 //______________________________________________________________________
411 AliSimpleValue::AliSimpleValue(Int_t size, const Int_t* buf) {
412 // contructor
413
414         fType = kDynInt;
415         fHolder = new AliDynIntHolder(size, buf);
416 }
417
418 //______________________________________________________________________
419 AliSimpleValue::AliSimpleValue(Int_t size, const UInt_t* buf) {
420 // contructor
421
422         fType = kDynUInt;
423         fHolder = new AliDynUIntHolder(size, buf);
424 }
425
426 //______________________________________________________________________
427 AliSimpleValue::AliSimpleValue(Int_t size, const Float_t* buf) {
428 // contructor
429
430         fType = kDynFloat;
431         fHolder = new AliDynFloatHolder(size, buf);
432 }
433
434 //______________________________________________________________________
435 AliSimpleValue::~AliSimpleValue() {
436 // destructor
437         
438         if (fHolder) {
439                 delete fHolder;
440         }
441 }
442
443 //______________________________________________________________________
444 AliSimpleValue& AliSimpleValue::operator=(const AliSimpleValue& other) {
445 // assignment op
446
447         if (fHolder) {
448                 delete fHolder;
449         }
450
451         fType = other.fType;
452         
453         if (other.fHolder) {
454                 fHolder = other.fHolder->Clone();
455         } else {
456                 fHolder = NULL;
457         }
458
459         return *this;
460 }
461
462 //______________________________________________________________________
463 Bool_t AliSimpleValue::operator==(const AliSimpleValue& other) const {
464 // equality op
465
466         if (fType != other.fType) {
467                 return kFALSE;
468         }
469
470         if (!(fHolder && other.fHolder)) {
471                 return kFALSE;
472         }
473
474         return fHolder->IsEqual(other.fHolder);
475 }
476
477 //______________________________________________________________________
478 void AliSimpleValue::SetBool(Bool_t val) {
479 // set value
480
481         if (!TypeOk(kBool)) {
482                 return;
483         }
484
485         ((AliBoolHolder*) fHolder)->fValue = val;
486 }
487
488 //______________________________________________________________________
489 void AliSimpleValue::SetByte(Char_t val) {
490 // set value
491
492         if (!TypeOk(kByte)) {
493                 return;
494         }
495
496         ((AliByteHolder*) fHolder)->fValue = val;
497 }
498
499 //______________________________________________________________________
500 void AliSimpleValue::SetInt(Int_t val) {
501 // set value
502
503         if (!TypeOk(kInt)) {
504                 return;
505         }
506
507         ((AliIntHolder*) fHolder)->fValue = val;
508 }
509
510 //______________________________________________________________________
511 void AliSimpleValue::SetUInt(UInt_t val) {
512 // set value
513
514         if (!TypeOk(kUInt)) {
515                 return;
516         }
517         
518         ((AliUIntHolder*) fHolder)->fValue = val;
519 }
520
521 //______________________________________________________________________
522 void AliSimpleValue::SetFloat(Float_t val) {
523 // set value
524
525         if (!TypeOk(kFloat)) {
526                 return;
527         }
528
529         ((AliFloatHolder*) fHolder)->fValue = val;
530 }
531
532 //______________________________________________________________________
533 Bool_t AliSimpleValue::GetBool() const {
534 // get value
535
536         if (!TypeOk(kBool)) {
537                 return kFALSE;
538         }       
539
540         return ((AliBoolHolder*) fHolder)->fValue;
541 }
542
543 //______________________________________________________________________
544 Char_t AliSimpleValue::GetByte() const {
545 // get value
546
547         if (!TypeOk(kByte)) {
548                 return 0;
549         }
550         
551         return ((AliByteHolder*) fHolder)->fValue;
552 }
553
554 //______________________________________________________________________
555 Int_t AliSimpleValue::GetInt() const {
556 // get value
557
558         if (!TypeOk(kInt)) {
559                 return 0;
560         }
561         return ((AliIntHolder*) fHolder)->fValue;
562 }
563
564 //______________________________________________________________________
565 UInt_t AliSimpleValue::GetUInt() const {
566 // get value
567
568         if (!TypeOk(kUInt)) {
569                 return 0;
570         }
571
572         return ((AliUIntHolder*) fHolder)->fValue;
573 }
574
575 //______________________________________________________________________
576 Float_t AliSimpleValue::GetFloat() const {
577 // get value
578
579         if (!TypeOk(kFloat)) {
580                 return 0;
581         }
582
583         return ((AliFloatHolder*) fHolder)->fValue;
584 }
585
586 //______________________________________________________________________
587 void AliSimpleValue::SetDynBool(Int_t n, Bool_t val) {
588 // set dyn value
589         
590         if (!TypeOk(kDynBool)) {
591                 return;
592         }
593
594         if (!BoundsOk(n)) {
595                 return;
596         }
597
598         ((AliDynBoolHolder*) fHolder)->fValues[n] = val;
599 }
600
601 //______________________________________________________________________
602 void AliSimpleValue::SetDynByte(Int_t n, Char_t val) {
603 // set dyn value
604
605         if (!TypeOk(kDynByte)) {
606                 return;
607         }
608
609         if (!BoundsOk(n)) {
610                 return;
611         }
612
613         ((AliDynByteHolder*) fHolder)->fValues[n] = val;
614 }
615
616 //______________________________________________________________________
617 void AliSimpleValue::SetDynInt(Int_t n, Int_t val) {
618 // set dyn value
619
620         if (!TypeOk(kDynInt)) {
621                 return;
622         }
623
624         if (!BoundsOk(n)) {
625                 return;
626         }
627
628         ((AliDynIntHolder*) fHolder)->fValues[n] = val;
629 }
630
631 //______________________________________________________________________
632 void AliSimpleValue::SetDynUInt(Int_t n, UInt_t val) {
633 // set dyn value
634
635         if (!TypeOk(kDynUInt)) {
636                 return;
637         }
638
639         if (!BoundsOk(n)) {
640                 return;
641         }
642
643         ((AliDynUIntHolder*) fHolder)->fValues[n] = val;
644 }
645
646 //______________________________________________________________________
647 void AliSimpleValue::SetDynFloat(Int_t n, Float_t val) {
648 // set dyn value
649
650         if (!TypeOk(kDynFloat)) {
651                 return;
652         }
653
654         if (!BoundsOk(n)) {
655                 return;
656         }
657
658         ((AliDynFloatHolder*) fHolder)->fValues[n] = val;
659 }
660
661 //______________________________________________________________________
662 Bool_t AliSimpleValue::GetDynBool(Int_t n) const {
663 // get dyn value
664
665         if (!TypeOk(kDynBool)) {
666                 return kFALSE;
667         }
668
669         if (!BoundsOk(n)) {
670                 return kFALSE;
671         }
672
673         return ((AliDynBoolHolder*) fHolder)->fValues[n];
674 }
675
676 //______________________________________________________________________
677 Char_t AliSimpleValue::GetDynByte(Int_t n) const {
678 // get dyn value
679
680         if (!TypeOk(kDynByte)) {
681                 return 0;
682         }
683
684         if (!BoundsOk(n)) {
685                 return 0;
686         }
687
688         return ((AliDynByteHolder*) fHolder)->fValues[n];
689 }
690
691 //______________________________________________________________________
692 Int_t AliSimpleValue::GetDynInt(Int_t n) const {
693 // get dyn value
694
695         if (!TypeOk(kDynInt)) {
696                 return 0;
697         }
698
699         if (!BoundsOk(n)) {
700                 return 0;
701         }
702
703         return ((AliDynIntHolder*) fHolder)->fValues[n];
704 }
705
706 //______________________________________________________________________
707 UInt_t AliSimpleValue::GetDynUInt(Int_t n) const {
708 // get dyn value
709
710         if (!TypeOk(kDynUInt)) {
711                 return 0;
712         }
713
714         if (!BoundsOk(n)) {
715                 return 0;
716         }
717
718         return ((AliDynUIntHolder*) fHolder)->fValues[n];
719 }
720
721 //______________________________________________________________________
722 Float_t AliSimpleValue::GetDynFloat(Int_t n) const {
723 // get dyn value
724
725         if (!TypeOk(kDynFloat)) {
726                 return 0;
727         }
728
729         if (!BoundsOk(n)) {
730                 return 0;
731         }
732
733         return ((AliDynFloatHolder*) fHolder)->fValues[n];
734 }
735
736 //______________________________________________________________________
737 Bool_t AliSimpleValue::TypeOk(AliSimpleValue::Type type) const {
738 // check that AliSimpleValue is of type type
739
740         if (fType != type) {
741                 AliError(Form("SimpleValue type is not %s!", 
742                         GetTypeString(type)));
743                 return kFALSE;
744         }
745
746         return kTRUE;
747 }
748
749 //______________________________________________________________________
750 Bool_t AliSimpleValue::BoundsOk(Int_t n) const {
751 // Check that n is within bounds of dyn value
752
753         switch (fType) {
754                 case kDynBool:
755                 case kDynByte:
756                 case kDynInt:
757                 case kDynUInt:
758                 case kDynFloat: {
759                         Int_t size = ((AliDynHolder*) fHolder)->fSize;
760                         if (n < 0 || n >= size) {
761                                 AliError(Form("Index %d out of bounds!", n));
762                                 return kFALSE;
763                         }
764                         return kTRUE;
765                 }
766                 case kBool:
767                 case kByte:
768                 case kInt:
769                 case kUInt:
770                 case kFloat:
771                         AliError(Form("SimpleValue type %s is not dynamic!",
772                                 GetTypeString(fType)));
773                         return kFALSE;
774                 default:
775                         AliError("Invalid or unknown type!");
776                         return kFALSE;
777         }
778 }
779
780 //______________________________________________________________________
781 Int_t AliSimpleValue::GetDynamicSize() const {
782         //
783         // returns the size of dynamic type or 0 in case of 
784         // none dynamic type.
785         //
786
787         if (!fHolder) {
788                 return 0;
789         }
790
791         if (!fHolder->IsA()->InheritsFrom(AliDynHolder::Class())) {
792                 return 0;
793         }
794
795         return ((AliDynHolder*) fHolder)->fSize;
796 }
797
798 //______________________________________________________________________
799 TString AliSimpleValue::ToString() const {
800 // Print value
801         
802         TString result;
803         
804         result += "Type: ";
805         result += GetTypeString(fType);
806         
807         result += ", Value: ";
808         switch (fType) {
809                 case kBool:
810                         result += GetBool();
811                         break;
812                 case kByte:
813                         result += (Int_t) GetByte();
814                         break;
815                 case kInt:
816                         result += GetInt();
817                         break;
818                 case kUInt:
819                         result += GetUInt();
820                         break;
821                 case kFloat:
822                         result += GetFloat();
823                         break;
824                 case kDynBool: {
825                                 result += "[";
826                                 Int_t size = GetDynamicSize();
827                                 for (Int_t k = 0; k < size; k ++) {
828                                         result += GetDynBool(k);
829                                         if (k + 1 < size) {
830                                                 result += ", ";
831                                         }
832                                 }
833                                 result += "]";
834                         }
835                         break;
836                 case kDynByte: {
837                                 result += "[";
838                                 Int_t size = GetDynamicSize();
839                                 for (Int_t k = 0; k < size; k ++) {
840                                         result += GetDynByte(k);
841                                         if (k + 1 < size) {
842                                                 result += ", ";
843                                         }
844                                 }
845                                 result += "]";
846                         }
847                         break;
848                 case kDynInt: {
849                                 result += "[";
850                                 Int_t size = GetDynamicSize();
851                                 for (Int_t k = 0; k < size; k ++) {
852                                         result += GetDynInt(k);
853                                         if (k + 1 < size) {
854                                                 result += ", ";
855                                         }
856                                 }
857                                 result += "]";
858                         }
859                         break;
860                 case kDynUInt: {
861                                 result += "[";
862                                 Int_t size = GetDynamicSize();
863                                 for (Int_t k = 0; k < size; k ++) {
864                                         result += GetDynUInt(k);
865                                         if (k + 1 < size) {
866                                                 result += ", ";
867                                         }
868                                 }
869                                 result += "]";
870                         }
871                         break;
872                 case kDynFloat: {
873                                 result += "[";
874                                 Int_t size = GetDynamicSize();
875                                 for (Int_t k = 0; k < size; k ++) {
876                                         result += GetDynFloat(k);
877                                         if (k + 1 < size) {
878                                                 result += ", ";
879                                         }
880                                 }
881                                 result += "]";
882                         }
883                         break;
884                 default:
885                         result += "Unknown";            
886         }       
887
888         return result;
889 }
890
891 //______________________________________________________________________
892 Bool_t AliSimpleValue::IsDynamic(AliSimpleValue::Type type) {
893 // check that type is dynamic
894
895          switch (type) {
896                 case kDynBool:
897                 case kDynByte:
898                 case kDynInt:
899                 case kDynUInt:
900                 case kDynFloat:
901                         return kTRUE;
902                 default:
903                         return kFALSE; 
904         }
905 }
906
907 //______________________________________________________________________
908 Int_t AliSimpleValue::GetSize() const {
909         //
910         // return the number of bytes used by this value.
911         // In case of dynamic type it returns dynamic size multiplied
912         // by the size of corresponding primitive type.
913         //
914         
915         return IsDynamic(fType) ? 
916                 GetDynamicSize() * AliSimpleValue::GetPrimitiveSize(fType): 
917                 AliSimpleValue::GetPrimitiveSize(fType);
918
919
920 //______________________________________________________________________
921 Int_t AliSimpleValue::GetPrimitiveSize(AliSimpleValue::Type type) {
922         //
923         // returns the number of bytes used by particular primitive type
924         // or by the corresponding primitive type in case of dynamic type.
925         //
926
927
928         switch (type) {
929
930                 case kBool: 
931                 case kDynBool: return sizeof(Bool_t);
932                 case kByte: 
933                 case kDynByte: return sizeof(Char_t);
934                 case kInt: 
935                 case kDynInt: return sizeof(Int_t);
936                 case kUInt: 
937                 case kDynUInt: return sizeof(UInt_t);
938                 case kFloat: 
939                 case kDynFloat: return sizeof(Float_t);
940                 default:
941                         return 0;
942         }
943
944
945 //______________________________________________________________________
946 const char* AliSimpleValue::GetTypeString(AliSimpleValue::Type type) {
947 // return type name correspondyng to type
948
949         switch (type) {
950                 case kBool: return "Bool";
951                 case kByte: return "Byte";
952                 case kInt: return "Int";
953                 case kUInt: return "UInt";
954                 case kFloat: return "Float";
955                 case kDynBool: return "DynBool";
956                 case kDynByte: return "DynByte";
957                 case kDynInt: return "DynInt";
958                 case kDynUInt: return "DynUInt";
959                 case kDynFloat: return "DynFloat";
960                 default:
961                         return "Unknown";
962         }
963 }