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