1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
22 // Defined to make unified interface to primitive types (in Root described by//
23 // TDataType) and TClass. //
25 ///////////////////////////////////////////////////////////////////////////////
28 #include "AliDataType.h"
32 #include "TDataType.h"
35 #include "Riostream.h"
42 AliDataType::AliDataType(const char *name)
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();
58 const char * AliDataType::GetClassName()
60 //class name of the object
61 return (fDataType) ? fDataType->GetName():0;
64 void AliDataType::StreamBuffer(TBuffer& b, const void *object, UInt_t size)
66 //streamer for buffer of objects
67 char * last = &((char*)object)[size*fSize];
68 char * pfirst = (char*)object;
71 switch ((EDataType) fDataType->GetType()){
73 for (p= pfirst; p<last;p+=fSize) b<<*((Char_t*)p);
76 for (p= pfirst; p<last;p+=fSize) b<<*((Short_t*)p);
79 for (p= pfirst; p<last;p+=fSize) b<<*((Int_t*)p);
82 for (p= pfirst; p<last;p+=fSize) b<<*((Long_t*)p);
85 for (p= pfirst; p<last;p+=fSize) b<<*((UChar_t*)p);
88 for (p= pfirst; p<last;p+=fSize) b<<*((UShort_t*)p);
91 for (p= pfirst; p<last;p+=fSize) b<<*((UInt_t*)p);
94 for (p= pfirst; p<last;p+=fSize) b<<*((Float_t*)p);
97 for (p= pfirst; p<last;p+=fSize) b<<*((Double_t*)p);
104 switch ((EDataType) fDataType->GetType()){
106 for (p= pfirst; p<last;p+=fSize) b>>*((Char_t*)p);
109 for (p= pfirst; p<last;p+=fSize) b>>*((Short_t*)p);
112 for (p= pfirst; p<last;p+=fSize) b>>*((Int_t*)p);
115 for (p= pfirst; p<last;p+=fSize) b>>*((Long_t*)p);
118 for (p= pfirst; p<last;p+=fSize) b>>*((UChar_t*)p);
121 for (p= pfirst; p<last;p+=fSize) b>>*((UShort_t*)p);
124 for (p= pfirst; p<last;p+=fSize) b>>*((UInt_t*)p);
127 for (p= pfirst; p<last;p+=fSize) b>>*((Float_t*)p);
130 for (p= pfirst; p<last;p+=fSize) b>>*((Double_t*)p);
138 void AliDataType::ObjectDump(void *p)
141 // dump object information
142 // assume that object p has type described by AliDataTYPE
143 switch ((EDataType) fDataType->GetType()){
145 cout<<*((Char_t*)p)<<"\n";
148 cout<<*((Short_t*)p)<<"\n";
151 cout<<*((Int_t*)p)<<"\n";
154 cout<<*((Long_t*)p)<<"\n";
157 cout<<*((UChar_t*)p)<<"\n";
160 cout<<*((UShort_t*)p)<<"\n";
163 cout<<*((UInt_t*)p)<<"\n";
166 cout<<*((Float_t*)p)<<"\n";
169 cout<<*((Double_t*)p)<<"\n";