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