Including St2 in the new geometry segmentation (Christian)
[u/mrichter/AliRoot.git] / CONTAINERS / AliDataType.cxx
CommitLineData
08edbb90 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
88cb7938 16/* $Id$ */
70479d0e 17
08edbb90 18///////////////////////////////////////////////////////////////////////////////
19// //
20// AliDataType //
21// //
22// Defined to make unified interface to primitive types (in Root described by//
23// TDataType) and TClass. //
24// //
25///////////////////////////////////////////////////////////////////////////////
26
27
28#include "AliDataType.h"
08edbb90 29
30#include "TMath.h"
31#include "TClass.h"
32#include "TDataType.h"
33
34#include "TROOT.h"
70479d0e 35#include "Riostream.h"
08edbb90 36
37
38ClassImp(AliDataType)
39
40
41
42AliDataType::AliDataType(const char *name)
43{
44 //
45 // AliData type constructor
46 fDataType = new TDataType(name);
47 if (fDataType->GetType()<0) fDataType= (gROOT->GetType(name,kTRUE));
48 if ((fDataType) && (fDataType->GetType())){
49 fSize = fDataType->Size();
50 // fType = (EDataType) fDataType->GetType();
51 SetTitle(name);
52 SetName(name);
53 fgList.Add(this);
54 }
55}
56
57
58const char * AliDataType::GetClassName()
59{
60 //class name of the object
61 return (fDataType) ? fDataType->GetName():0;
62}
63
64void AliDataType::StreamBuffer(TBuffer& b, const void *object, UInt_t size)
65{
66 //streamer for buffer of objects
67 char * last = &((char*)object)[size*fSize];
68 char * pfirst = (char*)object;
69 char *p;
70 if (b.IsWriting()){
71 switch ((EDataType) fDataType->GetType()){
72 case kChar_t:
73 for (p= pfirst; p<last;p+=fSize) b<<*((Char_t*)p);
74 break;
75 case kShort_t:
76 for (p= pfirst; p<last;p+=fSize) b<<*((Short_t*)p);
77 break;
78 case kInt_t:
79 for (p= pfirst; p<last;p+=fSize) b<<*((Int_t*)p);
80 break;
81 case kLong_t:
82 for (p= pfirst; p<last;p+=fSize) b<<*((Long_t*)p);
83 break;
84 case kUChar_t:
85 for (p= pfirst; p<last;p+=fSize) b<<*((UChar_t*)p);
86 break;
87 case kUShort_t:
88 for (p= pfirst; p<last;p+=fSize) b<<*((UShort_t*)p);
89 break;
90 case kUInt_t:
91 for (p= pfirst; p<last;p+=fSize) b<<*((UInt_t*)p);
92 break;
93 case kFloat_t:
94 for (p= pfirst; p<last;p+=fSize) b<<*((Float_t*)p);
95 break;
96 case kDouble_t:
97 for (p= pfirst; p<last;p+=fSize) b<<*((Double_t*)p);
98 break;
99 default:
100 break;
101 }
102 }
103 else
104 switch ((EDataType) fDataType->GetType()){
105 case kChar_t:
106 for (p= pfirst; p<last;p+=fSize) b>>*((Char_t*)p);
107 break;
108 case kShort_t:
109 for (p= pfirst; p<last;p+=fSize) b>>*((Short_t*)p);
110 break;
111 case kInt_t:
112 for (p= pfirst; p<last;p+=fSize) b>>*((Int_t*)p);
113 break;
114 case kLong_t:
115 for (p= pfirst; p<last;p+=fSize) b>>*((Long_t*)p);
116 break;
117 case kUChar_t:
118 for (p= pfirst; p<last;p+=fSize) b>>*((UChar_t*)p);
119 break;
120 case kUShort_t:
121 for (p= pfirst; p<last;p+=fSize) b>>*((UShort_t*)p);
122 break;
123 case kUInt_t:
124 for (p= pfirst; p<last;p+=fSize) b>>*((UInt_t*)p);
125 break;
126 case kFloat_t:
127 for (p= pfirst; p<last;p+=fSize) b>>*((Float_t*)p);
128 break;
129 case kDouble_t:
130 for (p= pfirst; p<last;p+=fSize) b>>*((Double_t*)p);
131 break;
132 default:
133 break;
134 }
135
136}
137
138void AliDataType::ObjectDump(void *p)
139{
140 //
141 // dump object information
142 // assume that object p has type described by AliDataTYPE
143 switch ((EDataType) fDataType->GetType()){
144 case kChar_t:
145 cout<<*((Char_t*)p)<<"\n";
146 break;
147 case kShort_t:
148 cout<<*((Short_t*)p)<<"\n";
149 break;
150 case kInt_t:
151 cout<<*((Int_t*)p)<<"\n";
152 break;
153 case kLong_t:
154 cout<<*((Long_t*)p)<<"\n";
155 break;
156 case kUChar_t:
157 cout<<*((UChar_t*)p)<<"\n";
158 break;
159 case kUShort_t:
160 cout<<*((UShort_t*)p)<<"\n";
161 break;
162 case kUInt_t:
163 cout<<*((UInt_t*)p)<<"\n";
164 break;
165 case kFloat_t:
166 cout<<*((Float_t*)p)<<"\n";
167 break;
168 case kDouble_t:
169 cout<<*((Double_t*)p)<<"\n";
170 break;
171 default:
172 break;
173 }
174}