CMS 3D CMS Logo

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::DependentClassReader::read(), and ora::ReadBuffer::read().

                                                           {
  void* ptr = 0;
  if( typ.Name(Reflex::SCOPED)=="std::string"){
    ptr = new std::string("");
  } else {
    ptr = typ.Construct().Address();
  }
  return ptr;
}
Reflex::Type ora::ClassUtils::containerDataType ( const Reflex::Type &  typ)

Definition at line 349 of file ClassUtils.cc.

References ExpressReco_HICollisions_FallBack::dataType, and i.

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

                                                                {
  Reflex::Type dataType;
  // find the iterator return type as the member value_type of the containers  
  size_t subTypeSize = typ.SubTypeSize();
  size_t i=0;
  while(i<subTypeSize){
    Reflex::Type sti = typ.SubTypeAt(i);    
    if(sti.Name()=="mapped_type") {
      dataType = sti;
      break;
    }    
    i++;
  }
  return dataType;
}
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().

                                                               {
  Reflex::Type keyType;
  // find the iterator return type as the member value_type of the containers  
  size_t subTypeSize = typ.SubTypeSize();
  size_t i=0;
  while(i<subTypeSize){
    Reflex::Type sti = typ.SubTypeAt(i);    
    if(sti.Name()=="key_type") {
      keyType = sti;
      break;
    }    
    i++;
  }
  return keyType;
}
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().

                                                                                             {
  Reflex::Type subType;
  size_t subTypeSize = typ.SubTypeSize();
  size_t i=0;
  while(i<subTypeSize){
    Reflex::Type sti = typ.SubTypeAt(i);
    if(sti.Name()==subTypeName) {
      subType = sti;
      break;
    }
    i++;
  }
  return resolvedType(subType);
}
Reflex::Type ora::ClassUtils::containerValueType ( const Reflex::Type &  typ)

Definition at line 317 of file ClassUtils.cc.

References i.

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

                                                                 {
  Reflex::Type valueType;
  // find the iterator return type as the member value_type of the containers  
  size_t subTypeSize = typ.SubTypeSize();
  size_t i=0;
  while(i<subTypeSize){
    Reflex::Type sti = typ.SubTypeAt(i);    
    if(sti.Name()=="value_type") {
      valueType = sti;
      break;
    }    
    i++;
  }
  return valueType;
}
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().

                                                                    {
  int status = 0;
  std::string ret("");
  char* realname = abi::__cxa_demangle( typeInfo.name(), 0, 0, &status);
  if( status == 0 && realname ){
    ret  = realname;
    free(realname);
  }
  return ret;
}
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::found, i, and resolvedType().

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

                                                                                                    {
  bool found = false;
  for ( unsigned int i=0;i<type.BaseSize() && !found; i++){
     Reflex::Base base = type.BaseAt(i);
     Reflex::Type bt = resolvedType( base.ToType() );
     if( bt == baseType ){
       func = base.OffsetFP();
       found = true;
     } else {
       found = findBaseType( bt, baseType, func );
     }
  }
  return found;
}
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().

                                                          {
  bool ret = false;
  if( type == baseType || type.HasBase( baseType )){
    ret = true;
  }
  return ret;
}
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().

                                                                   {
  Reflex::TypeTemplate tt = typ.TemplateFamily();
  if (! tt) {
    return false;
  } else {
    std::string contName = tt.Name(Reflex::SCOPED|Reflex::FINAL); 
    if(  contName == "std::map"            ||
         contName == "std::multimap"       ||
         contName == "__gnu_cxx::hash_map" ||
         contName == "__gnu_cxx::hash_multimap" ){
      return true;
    }
  }  
  return false;
}
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().

                                                        {
  Reflex::TypeTemplate templ = typ.TemplateFamily();
  if (! templ) {
    return false;
  } else {
    std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL); 
    if(  contName == "std::vector"              ||
         contName == "std::list"                ||
         contName == "std::deque"               ||
         contName == "std::stack"               ||
         contName == "std::set"                 ||
         contName == "std::multiset"            ||
         contName == "__gnu_cxx::hash_set"      ||
         contName == "__gnu_cxx::hash_multiset" ||
         contName == "std::map"                 ||
         contName == "std::multimap"            ||
         contName == "__gnu_cxx::hash_map"      ||
         contName == "__gnu_cxx::hash_multimap" ||
         contName == "ora::PVector"            ||
         contName == "ora::QueryableVector" ){
       return true;
    }
  }
  return false;
}
bool ora::ClassUtils::isTypeKeyedContainer ( const Reflex::Type &  typ)

Definition at line 164 of file ClassUtils.cc.

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

                                                             {
  Reflex::TypeTemplate tt = typ.TemplateFamily();
  if (! tt) {
    return false;
  } else {
    std::string contName = tt.Name(Reflex::SCOPED|Reflex::FINAL); 
    if(  contName == "std::map"                 ||
         contName == "std::multimap"            ||
         contName == "std::set"                 ||
         contName == "std::multiset"            ||
         contName == "__gnu_cxx::hash_set"      ||
         contName == "__gnu_cxx::hash_multiset" ||
         contName == "__gnu_cxx::hash_map"      ||
         contName == "__gnu_cxx::hash_multimap" ){
      return true;
    }
  }  
  return false;
}
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().

                                                              {
  return typ.HasBase(Reflex::Type::ByTypeInfo(typeid(ora::NamedReference)));
}
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().

                                                                      {
  Reflex::TypeTemplate tt = typ.TemplateFamily();
  if (! tt) {
    return false;
  } else {
    std::string contName = tt.Name(Reflex::SCOPED|Reflex::FINAL); 
    if(  contName == "std::vector"              ||
         contName == "std::list"                ||
         contName == "std::deque"               ||
         contName == "std::stack"               ||
         contName == "std::set"                 ||
         contName == "std::multiset"            ||
         contName == "__gnu_cxx::hash_set"      ||
         contName == "__gnu_cxx::hash_multiset" ||
         contName == "ora::PVector"            ||
         contName == "ora::QueryableVector"){
       return true;
    }
  }
  return false;
}
bool ora::ClassUtils::isTypeNonKeyedContainer ( const Reflex::Type &  typ)

Definition at line 184 of file ClassUtils.cc.

                                                                {
  Reflex::TypeTemplate templ = typ.TemplateFamily();
  if (! templ) {
    return false;
  } else {
    std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL); 
    if(  contName == "std::vector"              ||
         contName == "std::list"                ||
         contName == "std::deque"               ||
         contName == "std::stack"               ||
         contName == "ora::PVector"            ||
         contName == "ora::QueryableVector" ){
       return true;
    }
  }
  return false;
}
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().

                                                      {
  Reflex::Type resType = ClassUtils::resolvedType( typ );
  if( isTypePrimitive( resType ) ) {
    //if ( resType.IsFundamental() || resType.IsEnum() || isTypeString(resType) ) {
    return false;
  } else {
    if( resType.IsArray() ) return false;
    if( isTypeContainer( resType ) ) return false;
    if( isTypeOraPointer( resType ) ) return false;
    if( isTypeUniqueReference( resType ) ) return false;
    if( isTypePVector( resType ) ) return false;
    if( isTypeQueryableVector( resType ) ) return false;
  }
  return true;
}
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().

                                                          {
  Reflex::TypeTemplate templ = typ.TemplateFamily();
  if (! templ) {
    return false;
  } else {
    std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL); 
    if(  contName == "ora::Ptr" ){
       return true;
    }
  }
  return false;  
}
bool ora::ClassUtils::isTypeOraReference ( const Reflex::Type &  typ)

Definition at line 254 of file ClassUtils.cc.

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

                                                            {
  return typ.HasBase(Reflex::Type::ByTypeInfo(typeid(ora::Reference)));
}
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().

                                                        {
  return ( typ.IsFundamental() || typ.IsEnum() || isTypeString( typ ) );
}
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().

                                                       {
  Reflex::TypeTemplate templ = typ.TemplateFamily();
  if (! templ) {
    return false;
  } else {
    std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL); 
    if(  contName == "ora::PVector" ){
       return true;
    }
  }
  return false;  
}
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().

                                                               {
  Reflex::TypeTemplate templ = typ.TemplateFamily();
  if (! templ) {
    return false;
  } else {
    std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL); 
    if(  contName == "ora::QueryableVector" ){
       return true;
    }
  }
  return false;  
}
bool ora::ClassUtils::isTypeString ( const Reflex::Type &  typ)

Definition at line 128 of file ClassUtils.cc.

References AlCaRecoCosmics_cfg::name.

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

                                                     {
  std::string name = typ.Name(Reflex::SCOPED|Reflex::FINAL);
  return ( name == "std::string" ||
           name == "std::basic_string<char>" );
}
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().

                                                               {
  Reflex::TypeTemplate templ = typ.TemplateFamily();
  if (! templ) {
    return false;
  } else {
    std::string contName = templ.Name(Reflex::SCOPED|Reflex::FINAL); 
    if(  contName == "ora::UniqueRef" ){
       return true;
    }
  }
  return false;  
}
void ora::ClassUtils::loadDictionary ( const std::string &  className)

Definition at line 27 of file ClassUtils.cc.

References reco::get(), prof2calltree::prefix, and ora::throwException().

Referenced by lookupDictionary().

                                                              {
  try {
    static std::string const prefix("LCGReflex/");
    edmplugin::PluginCapabilities::get()->load(prefix + className);
  } catch (...){
    throwException( "Failure while loading dictionary for class \""+className+"\".","ClassUtils::loadDictionary" );
  }
}
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().

                                                                                        {
  Reflex::Type type = Reflex::Type::ByTypeInfo( typeInfo );
  if( typeInfo == typeid(std::string) ){
    // ugly, but no other way with Reflex...
    type = Reflex::Type::ByName("std::string");
  }
  if( !type ){
    loadDictionary( demangledName(typeInfo) );
    type = Reflex::Type::ByTypeInfo( typeInfo );
  }
  if( !type && throwFlag ){
    throwException( "Class \""+demangledName(typeInfo)+"\" has not been found in the dictionary.",
                    "ClassUtils::lookupDictionary" );
  }
  return type;
}
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().

                                                                                        {
  Reflex::Type type = Reflex::Type::ByName( className );
  if( className == "std::basic_string<char>" ){
    // ugly, but no other way with Reflex...
    type = Reflex::Type::ByName("std::string");
  }
  if( !type ){
    loadDictionary( className );
    type = Reflex::Type::ByName( className );
  }
  if( !type && throwFlag ){
    throwException( "Class \""+className+"\" has not been found in the dictionary.",
                    "ClassUtils::lookupDictionary" );
  }
  return type;
}
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().

                                                           {
  void* ret = 0;
  if( type == castType ){
    ret = ptr;
  } else if( type.HasBase( castType )){
    Reflex::Object theObj( type, ptr );
    ret = theObj.CastObject( castType ).Address();
  }
  return ret;
}