CMS 3D CMS Logo

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

Functions

bool checkMappedType (const Reflex::Type &type, const std::string &mappedTypeName)
 
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 isTypeNameOraVector (const std::string &typeName)
 
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 isTypeOraVector (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

bool ora::ClassUtils::checkMappedType ( const Reflex::Type &  type,
const std::string &  mappedTypeName 
)

Definition at line 54 of file ClassUtils.cc.

References isTypeNameOraVector(), isTypeOraVector(), and isTypeString().

Referenced by ora::ObjectStreamerBase::buildBaseDataMembers(), and ora::ObjectStreamerBase::buildDataMembers().

55  {
56  if( isTypeString( type ) ){
57  return (mappedTypeName=="std::basic_string<char>" || mappedTypeName=="basic_string<char>" || mappedTypeName=="std::string" || mappedTypeName=="string");
58  } else if ( type.IsEnum() ){
59  return mappedTypeName=="int";
60  } else if ( isTypeOraVector( type ) ){
61  return isTypeNameOraVector( mappedTypeName );
62  } else {
63  return type.Name(Reflex::SCOPED)==mappedTypeName;
64  }
65 }
type
Definition: HCALResponse.h:22
bool isTypeString(const Reflex::Type &typ)
Definition: ClassUtils.cc:137
bool isTypeNameOraVector(const std::string &typeName)
Definition: ClassUtils.cc:317
bool isTypeOraVector(const Reflex::Type &typ)
Definition: ClassUtils.cc:310
void * ora::ClassUtils::constructObject ( const Reflex::Type &  typ)

Definition at line 127 of file ClassUtils.cc.

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

127  {
128  void* ptr = 0;
129  if( typ.Name(Reflex::SCOPED)=="std::string"){
130  ptr = new std::string("");
131  } else {
132  ptr = typ.Construct().Address();
133  }
134  return ptr;
135 }
Reflex::Type ora::ClassUtils::containerDataType ( const Reflex::Type &  typ)

Definition at line 373 of file ClassUtils.cc.

References dtTPAnalyzer_cfg::dataType, and i.

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

373  {
375  // find the iterator return type as the member value_type of the containers
376  size_t subTypeSize = typ.SubTypeSize();
377  size_t i=0;
378  while(i<subTypeSize){
379  Reflex::Type sti = typ.SubTypeAt(i);
380  if(sti.Name()=="mapped_type") {
381  dataType = sti;
382  break;
383  }
384  i++;
385  }
386  return dataType;
387 }
int i
Definition: DBlmapReader.cc:9
Reflex::Type ora::ClassUtils::containerKeyType ( const Reflex::Type &  typ)

Definition at line 357 of file ClassUtils.cc.

References i.

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

357  {
358  Reflex::Type keyType;
359  // find the iterator return type as the member value_type of the containers
360  size_t subTypeSize = typ.SubTypeSize();
361  size_t i=0;
362  while(i<subTypeSize){
363  Reflex::Type sti = typ.SubTypeAt(i);
364  if(sti.Name()=="key_type") {
365  keyType = sti;
366  break;
367  }
368  i++;
369  }
370  return keyType;
371 }
int i
Definition: DBlmapReader.cc:9
Reflex::Type ora::ClassUtils::containerSubType ( const Reflex::Type &  typ,
const std::string &  subTypeName 
)

Definition at line 389 of file ClassUtils.cc.

References i, and resolvedType().

Referenced by ora::QVQueryMaker::build().

389  {
390  Reflex::Type subType;
391  size_t subTypeSize = typ.SubTypeSize();
392  size_t i=0;
393  while(i<subTypeSize){
394  Reflex::Type sti = typ.SubTypeAt(i);
395  if(sti.Name()==subTypeName) {
396  subType = sti;
397  break;
398  }
399  i++;
400  }
401  return resolvedType(subType);
402 }
int i
Definition: DBlmapReader.cc:9
Reflex::Type resolvedType(const Reflex::Type &typ)
Definition: ClassUtils.cc:404
Reflex::Type ora::ClassUtils::containerValueType ( const Reflex::Type &  typ)

Definition at line 341 of file ClassUtils.cc.

References i.

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

341  {
342  Reflex::Type valueType;
343  // find the iterator return type as the member value_type of the containers
344  size_t subTypeSize = typ.SubTypeSize();
345  size_t i=0;
346  while(i<subTypeSize){
347  Reflex::Type sti = typ.SubTypeAt(i);
348  if(sti.Name()=="value_type") {
349  valueType = sti;
350  break;
351  }
352  i++;
353  }
354  return valueType;
355 }
int i
Definition: DBlmapReader.cc:9
std::string ora::ClassUtils::demangledName ( const std::type_info &  typeInfo)

Definition at line 82 of file ClassUtils.cc.

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

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

82  {
83  int status = 0;
84  std::string ret("");
85  char* realname = abi::__cxa_demangle( typeInfo.name(), 0, 0, &status);
86  if( status == 0 && realname ){
87  ret = realname;
88  free(realname);
89  }
90  return ret;
91 }
tuple status
Definition: ntuplemaker.py:245
bool ora::ClassUtils::findBaseType ( Reflex::Type &  type,
Reflex::Type &  baseType,
Reflex::OffsetFunction &  func 
)

Definition at line 67 of file ClassUtils.cc.

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

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

67  {
68  bool found = false;
69  for ( unsigned int i=0;i<type.BaseSize() && !found; i++){
70  Reflex::Base base = type.BaseAt(i);
71  Reflex::Type bt = resolvedType( base.ToType() );
72  if( bt == baseType ){
73  func = base.OffsetFP();
74  found = true;
75  } else {
76  found = findBaseType( bt, baseType, func );
77  }
78  }
79  return found;
80 }
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:67
Reflex::Type resolvedType(const Reflex::Type &typ)
Definition: ClassUtils.cc:404
bool ora::ClassUtils::isType ( const Reflex::Type &  type,
const Reflex::Type &  baseType 
)

Definition at line 45 of file ClassUtils.cc.

References run_regression::ret.

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

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

Definition at line 211 of file ClassUtils.cc.

References groupFilesInBlocks::tt.

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

211  {
212  Reflex::TypeTemplate tt = typ.TemplateFamily();
213  if (! tt) {
214  return false;
215  } else {
216  std::string contName = tt.Name(Reflex::SCOPED|Reflex::FINAL);
217  if( contName == "std::map" ||
218  contName == "std::multimap" ||
219  contName == "__gnu_cxx::hash_map" ||
220  contName == "__gnu_cxx::hash_multimap" ){
221  return true;
222  }
223  }
224  return false;
225 }
bool ora::ClassUtils::isTypeContainer ( const Reflex::Type &  typ)

Definition at line 147 of file ClassUtils.cc.

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

147  {
148  Reflex::TypeTemplate templ = typ.TemplateFamily();
149  if (! templ) {
150  return false;
151  } else {
152  std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL);
153  if( contName == "std::vector" ||
154  contName == "std::list" ||
155  contName == "std::deque" ||
156  contName == "std::stack" ||
157  contName == "std::set" ||
158  contName == "std::multiset" ||
159  contName == "__gnu_cxx::hash_set" ||
160  contName == "__gnu_cxx::hash_multiset" ||
161  contName == "std::map" ||
162  contName == "std::multimap" ||
163  contName == "__gnu_cxx::hash_map" ||
164  contName == "__gnu_cxx::hash_multimap" ||
165  contName == "ora::PVector" ||
166  contName == "ora::QueryableVector" ){
167  return true;
168  }
169  }
170  return false;
171 }
bool ora::ClassUtils::isTypeKeyedContainer ( const Reflex::Type &  typ)

Definition at line 173 of file ClassUtils.cc.

References groupFilesInBlocks::tt.

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

173  {
174  Reflex::TypeTemplate tt = typ.TemplateFamily();
175  if (! tt) {
176  return false;
177  } else {
178  std::string contName = tt.Name(Reflex::SCOPED|Reflex::FINAL);
179  if( contName == "std::map" ||
180  contName == "std::multimap" ||
181  contName == "std::set" ||
182  contName == "std::multiset" ||
183  contName == "__gnu_cxx::hash_set" ||
184  contName == "__gnu_cxx::hash_multiset" ||
185  contName == "__gnu_cxx::hash_map" ||
186  contName == "__gnu_cxx::hash_multimap" ){
187  return true;
188  }
189  }
190  return false;
191 }
bool ora::ClassUtils::isTypeNamedReference ( const Reflex::Type &  typ)

Definition at line 267 of file ClassUtils.cc.

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

267  {
268  return typ.HasBase(Reflex::Type::ByTypeInfo(typeid(ora::NamedReference)));
269 }
bool ora::ClassUtils::isTypeNameOraVector ( const std::string &  typeName)

Definition at line 317 of file ClassUtils.cc.

Referenced by checkMappedType().

317  {
318  size_t idx = typeName.find('<');
319  if( idx != std::string::npos ){
320  std::string tname = typeName.substr( 0, idx );
321  return (tname == "ora::PVector" || tname == "ora::QueryableVector" || tname == "pool::PVector" );
322  }
323  return false;
324 }
bool ora::ClassUtils::isTypeNonAssociativeContainer ( const Reflex::Type &  typ)

Definition at line 227 of file ClassUtils.cc.

References groupFilesInBlocks::tt.

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

227  {
228  Reflex::TypeTemplate tt = typ.TemplateFamily();
229  if (! tt) {
230  return false;
231  } else {
232  std::string contName = tt.Name(Reflex::SCOPED|Reflex::FINAL);
233  if( contName == "std::vector" ||
234  contName == "std::list" ||
235  contName == "std::deque" ||
236  contName == "std::stack" ||
237  contName == "std::set" ||
238  contName == "std::multiset" ||
239  contName == "__gnu_cxx::hash_set" ||
240  contName == "__gnu_cxx::hash_multiset" ||
241  contName == "ora::PVector" ||
242  contName == "ora::QueryableVector"){
243  return true;
244  }
245  }
246  return false;
247 }
bool ora::ClassUtils::isTypeNonKeyedContainer ( const Reflex::Type &  typ)

Definition at line 193 of file ClassUtils.cc.

193  {
194  Reflex::TypeTemplate templ = typ.TemplateFamily();
195  if (! templ) {
196  return false;
197  } else {
198  std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL);
199  if( contName == "std::vector" ||
200  contName == "std::list" ||
201  contName == "std::deque" ||
202  contName == "std::stack" ||
203  contName == "ora::PVector" ||
204  contName == "ora::QueryableVector" ){
205  return true;
206  }
207  }
208  return false;
209 }
bool ora::ClassUtils::isTypeObject ( const Reflex::Type &  typ)

Definition at line 326 of file ClassUtils.cc.

References isTypeContainer(), isTypeOraPointer(), isTypeOraVector(), isTypePrimitive(), isTypeUniqueReference(), and resolvedType().

326  {
327  Reflex::Type resType = ClassUtils::resolvedType( typ );
328  if( isTypePrimitive( resType ) ) {
329  //if ( resType.IsFundamental() || resType.IsEnum() || isTypeString(resType) ) {
330  return false;
331  } else {
332  if( resType.IsArray() ) return false;
333  if( isTypeContainer( resType ) ) return false;
334  if( isTypeOraPointer( resType ) ) return false;
335  if( isTypeUniqueReference( resType ) ) return false;
336  if( isTypeOraVector( resType ) ) return false;
337  }
338  return true;
339 }
bool isTypeOraPointer(const Reflex::Type &typ)
Definition: ClassUtils.cc:250
bool isTypeUniqueReference(const Reflex::Type &typ)
Definition: ClassUtils.cc:271
bool isTypeContainer(const Reflex::Type &typ)
Definition: ClassUtils.cc:147
Reflex::Type resolvedType(const Reflex::Type &typ)
Definition: ClassUtils.cc:404
bool isTypePrimitive(const Reflex::Type &typ)
Definition: ClassUtils.cc:143
bool isTypeOraVector(const Reflex::Type &typ)
Definition: ClassUtils.cc:310
bool ora::ClassUtils::isTypeOraPointer ( const Reflex::Type &  typ)

Definition at line 250 of file ClassUtils.cc.

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

250  {
251  Reflex::TypeTemplate templ = typ.TemplateFamily();
252  if (! templ) {
253  return false;
254  } else {
255  std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL);
256  if( contName == "ora::Ptr" ){
257  return true;
258  }
259  }
260  return false;
261 }
bool ora::ClassUtils::isTypeOraReference ( const Reflex::Type &  typ)

Definition at line 263 of file ClassUtils.cc.

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

263  {
264  return typ.HasBase(Reflex::Type::ByTypeInfo(typeid(ora::Reference)));
265 }
bool ora::ClassUtils::isTypeOraVector ( const Reflex::Type &  typ)

Definition at line 310 of file ClassUtils.cc.

References isTypePVector(), and isTypeQueryableVector().

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

310  {
311  if( isTypePVector( typ ) || isTypeQueryableVector( typ ) ){
312  return true;
313  }
314  return false;
315 }
bool isTypePVector(const Reflex::Type &typ)
Definition: ClassUtils.cc:284
bool isTypeQueryableVector(const Reflex::Type &typ)
Definition: ClassUtils.cc:297
bool ora::ClassUtils::isTypePrimitive ( const Reflex::Type &  typ)

Definition at line 143 of file ClassUtils.cc.

References isTypeString().

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

143  {
144  return ( typ.IsFundamental() || typ.IsEnum() || isTypeString( typ ) );
145 }
bool isTypeString(const Reflex::Type &typ)
Definition: ClassUtils.cc:137
bool ora::ClassUtils::isTypePVector ( const Reflex::Type &  typ)

Definition at line 284 of file ClassUtils.cc.

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

284  {
285  Reflex::TypeTemplate templ = typ.TemplateFamily();
286  if (! templ) {
287  return false;
288  } else {
289  std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL);
290  if( contName == "ora::PVector" ){
291  return true;
292  }
293  }
294  return false;
295 }
bool ora::ClassUtils::isTypeQueryableVector ( const Reflex::Type &  typ)

Definition at line 297 of file ClassUtils.cc.

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

297  {
298  Reflex::TypeTemplate templ = typ.TemplateFamily();
299  if (! templ) {
300  return false;
301  } else {
302  std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL);
303  if( contName == "ora::QueryableVector" ){
304  return true;
305  }
306  }
307  return false;
308 }
bool ora::ClassUtils::isTypeString ( const Reflex::Type &  typ)

Definition at line 137 of file ClassUtils.cc.

References mergeVDriftHistosByStation::name.

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

137  {
138  std::string name = typ.Name(Reflex::SCOPED|Reflex::FINAL);
139  return ( name == "std::string" ||
140  name == "std::basic_string<char>" );
141 }
bool ora::ClassUtils::isTypeUniqueReference ( const Reflex::Type &  typ)

Definition at line 271 of file ClassUtils.cc.

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

271  {
272  Reflex::TypeTemplate templ = typ.TemplateFamily();
273  if (! templ) {
274  return false;
275  } else {
276  std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL);
277  if( contName == "ora::UniqueRef" ){
278  return true;
279  }
280  }
281  return false;
282 }
void ora::ClassUtils::loadDictionary ( const std::string &  className)

Definition at line 27 of file ClassUtils.cc.

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

Referenced by lookupDictionary().

27  {
28  static std::string const prefix("LCGReflex/");
30 }
static PluginCapabilities * get()
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 93 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().

93  {
94  Reflex::Type type = Reflex::Type::ByTypeInfo( typeInfo );
95  if( typeInfo == typeid(std::string) ){
96  // ugly, but no other way with Reflex...
97  type = Reflex::Type::ByName("std::string");
98  }
99  if( !type ){
100  loadDictionary( demangledName(typeInfo) );
101  type = Reflex::Type::ByTypeInfo( typeInfo );
102  }
103  if( !type && throwFlag ){
104  throwException( "Class \""+demangledName(typeInfo)+"\" has not been found in the dictionary.",
105  "ClassUtils::lookupDictionary" );
106  }
107  return type;
108 }
type
Definition: HCALResponse.h:22
std::string demangledName(const std::type_info &typeInfo)
Definition: ClassUtils.cc:82
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 110 of file ClassUtils.cc.

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

110  {
111  Reflex::Type type = Reflex::Type::ByName( className );
112  if( className == "std::basic_string<char>" ){
113  // ugly, but no other way with Reflex...
114  type = Reflex::Type::ByName("std::string");
115  }
116  if( !type ){
118  type = Reflex::Type::ByName( className );
119  }
120  if( !type && throwFlag ){
121  throwException( "Class \""+className+"\" has not been found in the dictionary.",
122  "ClassUtils::lookupDictionary" );
123  }
124  return type;
125 }
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 32 of file ClassUtils.cc.

References run_regression::ret.

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

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