CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
ora::ClassUtils Namespace Reference

Functions

void * constructObject (const Reflex::Type &typ)
 
Reflex::Type containerDataType (const Reflex::Type &typ)
 
Reflex::Type containerKeyType (const Reflex::Type &typ)
 
Reflex::Type containerSubType (const Reflex::Type &typ, const std::string &subTypeName)
 
Reflex::Type containerValueType (const Reflex::Type &typ)
 
std::string demangledName (const std::type_info &typeInfo)
 
bool findBaseType (Reflex::Type &type, Reflex::Type &baseType, Reflex::OffsetFunction &func)
 
bool isType (const Reflex::Type &type, const Reflex::Type &baseType)
 
bool isTypeAssociativeContainer (const Reflex::Type &typ)
 
bool isTypeContainer (const Reflex::Type &typ)
 
bool isTypeKeyedContainer (const Reflex::Type &typ)
 
bool isTypeNamedReference (const Reflex::Type &typ)
 
bool isTypeNonAssociativeContainer (const Reflex::Type &typ)
 
bool isTypeNonKeyedContainer (const Reflex::Type &typ)
 
bool isTypeObject (const Reflex::Type &typ)
 
bool isTypeOraPointer (const Reflex::Type &typ)
 
bool isTypeOraReference (const Reflex::Type &typ)
 
bool isTypePrimitive (const Reflex::Type &typ)
 
bool isTypePVector (const Reflex::Type &typ)
 
bool isTypeQueryableVector (const Reflex::Type &typ)
 
bool isTypeString (const Reflex::Type &typ)
 
bool isTypeUniqueReference (const Reflex::Type &typ)
 
void loadDictionary (const std::string &className)
 
Reflex::Type lookupDictionary (const std::type_info &typeInfo, bool throwFlag=true)
 
Reflex::Type lookupDictionary (const std::string &className, bool throwFlag=true)
 
Reflex::Type resolvedType (const Reflex::Type &typ)
 
void * upCast (const Reflex::Type &type, void *ptr, const Reflex::Type &asType)
 

Function Documentation

void * ora::ClassUtils::constructObject ( const Reflex::Type &  typ)

Definition at line 118 of file ClassUtils.cc.

Referenced by ora::OraPtrReadBuffer::read(), ora::DependentClassReader::read(), and ora::ReadBuffer::read().

118  {
119  void* ptr = 0;
120  if( typ.Name(Reflex::SCOPED)=="std::string"){
121  ptr = new std::string("");
122  } else {
123  ptr = typ.Construct().Address();
124  }
125  return ptr;
126 }
Reflex::Type ora::ClassUtils::containerDataType ( const Reflex::Type &  typ)

Definition at line 349 of file ClassUtils.cc.

References dtT0WireCalibration_cfg::dataType, and i.

Referenced by ora::STLContainerWriter::build(), ora::STLContainerReader::build(), and ora::ArrayMapping::process().

349  {
351  // find the iterator return type as the member value_type of the containers
352  size_t subTypeSize = typ.SubTypeSize();
353  size_t i=0;
354  while(i<subTypeSize){
355  Reflex::Type sti = typ.SubTypeAt(i);
356  if(sti.Name()=="mapped_type") {
357  dataType = sti;
358  break;
359  }
360  i++;
361  }
362  return dataType;
363 }
int i
Definition: DBlmapReader.cc:9
Reflex::Type ora::ClassUtils::containerKeyType ( const Reflex::Type &  typ)

Definition at line 333 of file ClassUtils.cc.

References i.

Referenced by ora::STLContainerWriter::build(), ora::STLContainerReader::build(), and ora::ArrayMapping::process().

333  {
334  Reflex::Type keyType;
335  // find the iterator return type as the member value_type of the containers
336  size_t subTypeSize = typ.SubTypeSize();
337  size_t i=0;
338  while(i<subTypeSize){
339  Reflex::Type sti = typ.SubTypeAt(i);
340  if(sti.Name()=="key_type") {
341  keyType = sti;
342  break;
343  }
344  i++;
345  }
346  return keyType;
347 }
int i
Definition: DBlmapReader.cc:9
Reflex::Type ora::ClassUtils::containerSubType ( const Reflex::Type &  typ,
const std::string &  subTypeName 
)

Definition at line 365 of file ClassUtils.cc.

References i, and resolvedType().

Referenced by ora::QueryableVectorWriter::build(), and ora::QVReader::build().

365  {
366  Reflex::Type subType;
367  size_t subTypeSize = typ.SubTypeSize();
368  size_t i=0;
369  while(i<subTypeSize){
370  Reflex::Type sti = typ.SubTypeAt(i);
371  if(sti.Name()==subTypeName) {
372  subType = sti;
373  break;
374  }
375  i++;
376  }
377  return resolvedType(subType);
378 }
int i
Definition: DBlmapReader.cc:9
Reflex::Type resolvedType(const Reflex::Type &typ)
Definition: ClassUtils.cc:380
Reflex::Type ora::ClassUtils::containerValueType ( const Reflex::Type &  typ)

Definition at line 317 of file ClassUtils.cc.

References i.

Referenced by ora::QueryableVectorWriter::build(), ora::STLContainerWriter::build(), ora::QVReader::build(), ora::STLContainerReader::build(), ora::ArrayMapping::process(), ora::PVectorHandler::PVectorHandler(), and ora::STLContainerHandler::STLContainerHandler().

317  {
318  Reflex::Type valueType;
319  // find the iterator return type as the member value_type of the containers
320  size_t subTypeSize = typ.SubTypeSize();
321  size_t i=0;
322  while(i<subTypeSize){
323  Reflex::Type sti = typ.SubTypeAt(i);
324  if(sti.Name()=="value_type") {
325  valueType = sti;
326  break;
327  }
328  i++;
329  }
330  return valueType;
331 }
int i
Definition: DBlmapReader.cc:9
std::string ora::ClassUtils::demangledName ( const std::type_info &  typeInfo)

Definition at line 73 of file ClassUtils.cc.

References runTheMatrix::ret, and ntuplemaker::status.

Referenced by lookupDictionary(), and ora::throwException().

73  {
74  int status = 0;
75  std::string ret("");
76  char* realname = abi::__cxa_demangle( typeInfo.name(), 0, 0, &status);
77  if( status == 0 && realname ){
78  ret = realname;
79  free(realname);
80  }
81  return ret;
82 }
tuple status
Definition: ntuplemaker.py:245
bool ora::ClassUtils::findBaseType ( Reflex::Type &  type,
Reflex::Type &  baseType,
Reflex::OffsetFunction &  func 
)

Definition at line 58 of file ClassUtils.cc.

References CustomConfigs::Base(), newFWLiteAna::base, newFWLiteAna::found, i, and resolvedType().

Referenced by ora::OraReferenceStreamerBase::buildDataElement().

58  {
59  bool found = false;
60  for ( unsigned int i=0;i<type.BaseSize() && !found; i++){
61  Reflex::Base base = type.BaseAt(i);
62  Reflex::Type bt = resolvedType( base.ToType() );
63  if( bt == baseType ){
64  func = base.OffsetFP();
65  found = true;
66  } else {
67  found = findBaseType( bt, baseType, func );
68  }
69  }
70  return found;
71 }
tuple base
Main Program
Definition: newFWLiteAna.py:92
type
Definition: HCALResponse.h:22
int i
Definition: DBlmapReader.cc:9
bool findBaseType(Reflex::Type &type, Reflex::Type &baseType, Reflex::OffsetFunction &func)
Definition: ClassUtils.cc:58
Reflex::Type resolvedType(const Reflex::Type &typ)
Definition: ClassUtils.cc:380
bool ora::ClassUtils::isType ( const Reflex::Type &  type,
const Reflex::Type &  baseType 
)

Definition at line 49 of file ClassUtils.cc.

References runTheMatrix::ret.

Referenced by ora::DatabaseContainer::fetchItemAsType(), and ora::IteratorBuffer::getItemAsType().

50  {
51  bool ret = false;
52  if( type == baseType || type.HasBase( baseType )){
53  ret = true;
54  }
55  return ret;
56 }
type
Definition: HCALResponse.h:22
bool ora::ClassUtils::isTypeAssociativeContainer ( const Reflex::Type &  typ)

Definition at line 202 of file ClassUtils.cc.

Referenced by ora::RelationalMapping::_sizeInColumns(), and ora::ArrayMapping::process().

202  {
203  Reflex::TypeTemplate tt = typ.TemplateFamily();
204  if (! tt) {
205  return false;
206  } else {
207  std::string contName = tt.Name(Reflex::SCOPED|Reflex::FINAL);
208  if( contName == "std::map" ||
209  contName == "std::multimap" ||
210  contName == "__gnu_cxx::hash_map" ||
211  contName == "__gnu_cxx::hash_multimap" ){
212  return true;
213  }
214  }
215  return false;
216 }
bool ora::ClassUtils::isTypeContainer ( const Reflex::Type &  typ)

Definition at line 138 of file ClassUtils.cc.

Referenced by isTypeObject(), ora::RelationalMappingFactory::newProcessor(), ora::RelationalStreamerFactory::newStreamer(), and ora::SpecialSTLContainerHandler::SpecialSTLContainerHandler().

138  {
139  Reflex::TypeTemplate templ = typ.TemplateFamily();
140  if (! templ) {
141  return false;
142  } else {
143  std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL);
144  if( contName == "std::vector" ||
145  contName == "std::list" ||
146  contName == "std::deque" ||
147  contName == "std::stack" ||
148  contName == "std::set" ||
149  contName == "std::multiset" ||
150  contName == "__gnu_cxx::hash_set" ||
151  contName == "__gnu_cxx::hash_multiset" ||
152  contName == "std::map" ||
153  contName == "std::multimap" ||
154  contName == "__gnu_cxx::hash_map" ||
155  contName == "__gnu_cxx::hash_multimap" ||
156  contName == "ora::PVector" ||
157  contName == "ora::QueryableVector" ){
158  return true;
159  }
160  }
161  return false;
162 }
bool ora::ClassUtils::isTypeKeyedContainer ( const Reflex::Type &  typ)

Definition at line 164 of file ClassUtils.cc.

Referenced by ora::STLContainerHandler::STLContainerHandler().

164  {
165  Reflex::TypeTemplate tt = typ.TemplateFamily();
166  if (! tt) {
167  return false;
168  } else {
169  std::string contName = tt.Name(Reflex::SCOPED|Reflex::FINAL);
170  if( contName == "std::map" ||
171  contName == "std::multimap" ||
172  contName == "std::set" ||
173  contName == "std::multiset" ||
174  contName == "__gnu_cxx::hash_set" ||
175  contName == "__gnu_cxx::hash_multiset" ||
176  contName == "__gnu_cxx::hash_map" ||
177  contName == "__gnu_cxx::hash_multimap" ){
178  return true;
179  }
180  }
181  return false;
182 }
bool ora::ClassUtils::isTypeNamedReference ( const Reflex::Type &  typ)

Definition at line 258 of file ClassUtils.cc.

Referenced by ora::RelationalMapping::_sizeInColumns(), and ora::RelationalStreamerFactory::newStreamer().

258  {
259  return typ.HasBase(Reflex::Type::ByTypeInfo(typeid(ora::NamedReference)));
260 }
bool ora::ClassUtils::isTypeNonAssociativeContainer ( const Reflex::Type &  typ)

Definition at line 218 of file ClassUtils.cc.

Referenced by ora::RelationalMapping::_sizeInColumns(), and ora::ArrayMapping::process().

218  {
219  Reflex::TypeTemplate tt = typ.TemplateFamily();
220  if (! tt) {
221  return false;
222  } else {
223  std::string contName = tt.Name(Reflex::SCOPED|Reflex::FINAL);
224  if( contName == "std::vector" ||
225  contName == "std::list" ||
226  contName == "std::deque" ||
227  contName == "std::stack" ||
228  contName == "std::set" ||
229  contName == "std::multiset" ||
230  contName == "__gnu_cxx::hash_set" ||
231  contName == "__gnu_cxx::hash_multiset" ||
232  contName == "ora::PVector" ||
233  contName == "ora::QueryableVector"){
234  return true;
235  }
236  }
237  return false;
238 }
bool ora::ClassUtils::isTypeNonKeyedContainer ( const Reflex::Type &  typ)

Definition at line 184 of file ClassUtils.cc.

184  {
185  Reflex::TypeTemplate templ = typ.TemplateFamily();
186  if (! templ) {
187  return false;
188  } else {
189  std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL);
190  if( contName == "std::vector" ||
191  contName == "std::list" ||
192  contName == "std::deque" ||
193  contName == "std::stack" ||
194  contName == "ora::PVector" ||
195  contName == "ora::QueryableVector" ){
196  return true;
197  }
198  }
199  return false;
200 }
bool ora::ClassUtils::isTypeObject ( const Reflex::Type &  typ)

Definition at line 301 of file ClassUtils.cc.

References isTypeContainer(), isTypeOraPointer(), isTypePrimitive(), isTypePVector(), isTypeQueryableVector(), isTypeUniqueReference(), and resolvedType().

301  {
302  Reflex::Type resType = ClassUtils::resolvedType( typ );
303  if( isTypePrimitive( resType ) ) {
304  //if ( resType.IsFundamental() || resType.IsEnum() || isTypeString(resType) ) {
305  return false;
306  } else {
307  if( resType.IsArray() ) return false;
308  if( isTypeContainer( resType ) ) return false;
309  if( isTypeOraPointer( resType ) ) return false;
310  if( isTypeUniqueReference( resType ) ) return false;
311  if( isTypePVector( resType ) ) return false;
312  if( isTypeQueryableVector( resType ) ) return false;
313  }
314  return true;
315 }
bool isTypeOraPointer(const Reflex::Type &typ)
Definition: ClassUtils.cc:241
bool isTypePVector(const Reflex::Type &typ)
Definition: ClassUtils.cc:275
bool isTypeUniqueReference(const Reflex::Type &typ)
Definition: ClassUtils.cc:262
bool isTypeContainer(const Reflex::Type &typ)
Definition: ClassUtils.cc:138
Reflex::Type resolvedType(const Reflex::Type &typ)
Definition: ClassUtils.cc:380
bool isTypePrimitive(const Reflex::Type &typ)
Definition: ClassUtils.cc:134
bool isTypeQueryableVector(const Reflex::Type &typ)
Definition: ClassUtils.cc:288
bool ora::ClassUtils::isTypeOraPointer ( const Reflex::Type &  typ)

Definition at line 241 of file ClassUtils.cc.

Referenced by ora::RelationalMapping::_sizeInColumns(), isTypeObject(), ora::RelationalMappingFactory::newProcessor(), and ora::RelationalStreamerFactory::newStreamer().

241  {
242  Reflex::TypeTemplate templ = typ.TemplateFamily();
243  if (! templ) {
244  return false;
245  } else {
246  std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL);
247  if( contName == "ora::Ptr" ){
248  return true;
249  }
250  }
251  return false;
252 }
bool ora::ClassUtils::isTypeOraReference ( const Reflex::Type &  typ)

Definition at line 254 of file ClassUtils.cc.

Referenced by ora::RelationalStreamerFactory::newStreamer().

254  {
255  return typ.HasBase(Reflex::Type::ByTypeInfo(typeid(ora::Reference)));
256 }
bool ora::ClassUtils::isTypePrimitive ( const Reflex::Type &  typ)

Definition at line 134 of file ClassUtils.cc.

References isTypeString().

Referenced by ora::RelationalMapping::_sizeInColumns(), isTypeObject(), ora::RelationalMappingFactory::newProcessor(), and ora::RelationalStreamerFactory::newStreamer().

134  {
135  return ( typ.IsFundamental() || typ.IsEnum() || isTypeString( typ ) );
136 }
bool isTypeString(const Reflex::Type &typ)
Definition: ClassUtils.cc:128
bool ora::ClassUtils::isTypePVector ( const Reflex::Type &  typ)

Definition at line 275 of file ClassUtils.cc.

Referenced by isTypeObject(), ora::RelationalStreamerFactory::newStreamer(), and ora::ArrayMapping::process().

275  {
276  Reflex::TypeTemplate templ = typ.TemplateFamily();
277  if (! templ) {
278  return false;
279  } else {
280  std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL);
281  if( contName == "ora::PVector" ){
282  return true;
283  }
284  }
285  return false;
286 }
bool ora::ClassUtils::isTypeQueryableVector ( const Reflex::Type &  typ)

Definition at line 288 of file ClassUtils.cc.

Referenced by isTypeObject(), ora::RelationalStreamerFactory::newStreamer(), and ora::ArrayMapping::process().

288  {
289  Reflex::TypeTemplate templ = typ.TemplateFamily();
290  if (! templ) {
291  return false;
292  } else {
293  std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL);
294  if( contName == "ora::QueryableVector" ){
295  return true;
296  }
297  }
298  return false;
299 }
bool ora::ClassUtils::isTypeString ( const Reflex::Type &  typ)

Definition at line 128 of file ClassUtils.cc.

References mergeVDriftHistosByStation::name.

Referenced by ora::PrimitiveStreamerBase::buildDataElement(), isTypePrimitive(), and ora::PrimitiveMapping::process().

128  {
129  std::string name = typ.Name(Reflex::SCOPED|Reflex::FINAL);
130  return ( name == "std::string" ||
131  name == "std::basic_string<char>" );
132 }
bool ora::ClassUtils::isTypeUniqueReference ( const Reflex::Type &  typ)

Definition at line 262 of file ClassUtils.cc.

Referenced by ora::RelationalMapping::_sizeInColumns(), isTypeObject(), ora::RelationalMappingFactory::newProcessor(), and ora::RelationalStreamerFactory::newStreamer().

262  {
263  Reflex::TypeTemplate templ = typ.TemplateFamily();
264  if (! templ) {
265  return false;
266  } else {
267  std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL);
268  if( contName == "ora::UniqueRef" ){
269  return true;
270  }
271  }
272  return false;
273 }
void ora::ClassUtils::loadDictionary ( const std::string &  className)

Definition at line 27 of file ClassUtils.cc.

References edmplugin::PluginCapabilities::get(), edmplugin::PluginCapabilities::load(), prof2calltree::prefix, and ora::throwException().

Referenced by lookupDictionary().

27  {
28  try {
29  static std::string const prefix("LCGReflex/");
31  } catch (...){
32  throwException( "Failure while loading dictionary for class \""+className+"\".","ClassUtils::loadDictionary" );
33  }
34 }
static PluginCapabilities * get()
void throwException(std::string const &message, std::string const &methodName)
Definition: Exception.cc:17
void load(const std::string &iName)
std::string className(const T &t)
Definition: ClassName.h:30
Reflex::Type ora::ClassUtils::lookupDictionary ( const std::type_info &  typeInfo,
bool  throwFlag = true 
)

Definition at line 84 of file ClassUtils.cc.

References demangledName(), loadDictionary(), and ora::throwException().

Referenced by ora::Object::cast(), ora::Database::createContainer(), ora::Container::extendSchema(), ora::Container::fetchItemAsType(), ora::Database::getContainer(), ora::ContainerIterator::getItemAsType(), ora::Database::getTypedObjectByName(), ora::ContainerSchema::initClassDict(), ora::Container::insertItem(), ora::Database::nameForContainer(), ora::UniqueRefReader::read(), ora::Container::updateItem(), and ora::UniqueRefWriter::write().

84  {
85  Reflex::Type type = Reflex::Type::ByTypeInfo( typeInfo );
86  if( typeInfo == typeid(std::string) ){
87  // ugly, but no other way with Reflex...
88  type = Reflex::Type::ByName("std::string");
89  }
90  if( !type ){
91  loadDictionary( demangledName(typeInfo) );
92  type = Reflex::Type::ByTypeInfo( typeInfo );
93  }
94  if( !type && throwFlag ){
95  throwException( "Class \""+demangledName(typeInfo)+"\" has not been found in the dictionary.",
96  "ClassUtils::lookupDictionary" );
97  }
98  return type;
99 }
type
Definition: HCALResponse.h:22
std::string demangledName(const std::type_info &typeInfo)
Definition: ClassUtils.cc:73
void loadDictionary(const std::string &className)
Definition: ClassUtils.cc:27
void throwException(std::string const &message, std::string const &methodName)
Definition: Exception.cc:17
Reflex::Type ora::ClassUtils::lookupDictionary ( const std::string &  className,
bool  throwFlag = true 
)

Definition at line 101 of file ClassUtils.cc.

References loadDictionary(), and ora::throwException().

101  {
102  Reflex::Type type = Reflex::Type::ByName( className );
103  if( className == "std::basic_string<char>" ){
104  // ugly, but no other way with Reflex...
105  type = Reflex::Type::ByName("std::string");
106  }
107  if( !type ){
109  type = Reflex::Type::ByName( className );
110  }
111  if( !type && throwFlag ){
112  throwException( "Class \""+className+"\" has not been found in the dictionary.",
113  "ClassUtils::lookupDictionary" );
114  }
115  return type;
116 }
type
Definition: HCALResponse.h:22
void loadDictionary(const std::string &className)
Definition: ClassUtils.cc:27
void throwException(std::string const &message, std::string const &methodName)
Definition: Exception.cc:17
std::string className(const T &t)
Definition: ClassName.h:30
Reflex::Type ora::ClassUtils::resolvedType ( const Reflex::Type &  typ)
void * ora::ClassUtils::upCast ( const Reflex::Type &  type,
void *  ptr,
const Reflex::Type &  asType 
)

Definition at line 36 of file ClassUtils.cc.

References runTheMatrix::ret.

Referenced by ora::Object::cast().

38  {
39  void* ret = 0;
40  if( type == castType ){
41  ret = ptr;
42  } else if( type.HasBase( castType )){
43  Reflex::Object theObj( type, ptr );
44  ret = theObj.CastObject( castType ).Address();
45  }
46  return ret;
47 }
type
Definition: HCALResponse.h:22