CMS 3D CMS Logo

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().

                                                                        {
  if( isTypeString( type ) ){
    return (mappedTypeName=="std::basic_string<char>" || mappedTypeName=="basic_string<char>" || mappedTypeName=="std::string" || mappedTypeName=="string");
  } else if ( type.IsEnum() ){
    return mappedTypeName=="int";
  } else if ( isTypeOraVector( type ) ){
    return isTypeNameOraVector( mappedTypeName );
  } else {
    return type.Name(Reflex::SCOPED)==mappedTypeName;
  }
}
void * ora::ClassUtils::constructObject ( const Reflex::Type &  typ)

Definition at line 127 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 373 of file ClassUtils.cc.

References dtT0WireCalibration_cfg::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 357 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 389 of file ClassUtils.cc.

References i, and resolvedType().

                                                                                             {
  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 341 of file ClassUtils.cc.

References i.

Referenced by ora::STLContainerWriter::build(), ora::STLContainerReader::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 82 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 67 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 45 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 211 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 147 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 173 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 267 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::isTypeNameOraVector ( const std::string &  typeName)

Definition at line 317 of file ClassUtils.cc.

Referenced by checkMappedType().

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

Definition at line 227 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 193 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 326 of file ClassUtils.cc.

References isTypeContainer(), isTypeOraPointer(), isTypeOraVector(), isTypePrimitive(), 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( isTypeOraVector( resType ) ) return false;
  }
  return true;
}
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().

                                                          {
  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 263 of file ClassUtils.cc.

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

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

                                                         {
  if( isTypePVector( typ ) || isTypeQueryableVector( typ ) ){
    return true;
  }
  return false;
}
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().

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

                                                       {
  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 297 of file ClassUtils.cc.

Referenced by isTypeOraVector(), 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 137 of file ClassUtils.cc.

References mergeVDriftHistosByStation::name.

Referenced by ora::PrimitiveStreamerBase::buildDataElement(), checkMappedType(), 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 271 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(), and prof2calltree::prefix.

Referenced by lookupDictionary().

                                                              {
  static std::string const prefix("LCGReflex/");
  edmplugin::PluginCapabilities::get()->load(prefix + className);
}
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().

                                                                                        {
  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 110 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 32 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;
}