예제 #1
0
  void
  SignalCaster::registerCast (const std::type_info& type,
			      SignalCaster::displayer_type displayer,
			      SignalCaster::caster_type caster,
			      SignalCaster::tracer_type tracer)
  {
    if (existsCast (type))
      {
	// If type name has already been registered for same type, do not throw.
	if (type_info_[type.name()] != &type)
	  {
	    std::string typeName(type.name());
	    std::ostringstream os;
	    os << "cast already registered for typename " << typeName << "\n"
	       << "and types differ: " << &type << " != "
	       << type_info_[type.name()]
	       << ".\n"
	       << "A possible reason is that the dynamic"
	       << " library defining this type\n"
	       << "has been loaded several times, defining different symbols"
	       << " for the same type.";
	    throw ExceptionSignal(ExceptionSignal::GENERIC,
				  os.str());
	  }
      }
    functions_[type.name()] = cast_functions_type(displayer,caster, tracer);
    type_info_[type.name()] = &type;
  }
예제 #2
0
/// Helper method to BaseClass::decode the type name
std::string BaseClass::decodeFullName(const std::type_info& t)
{
  std::string name;
#ifdef __GNUC__
  int status;
	/* size_t length; */ // although it should, length would not be filled in by the following call
  char* allocname = abi::__cxa_demangle(t.name(), 0, /*&length*/0, &status);
  if(allocname == 0)
  {
      std::cerr << "Unable to demangle symbol: " << t.name() << std::endl;
  }
  else
  {
		int length = 0;
		while(allocname[length] != '\0')
		{
			length++;
		}
		name.resize(length);
		for(int i=0; i<(int)length; i++)
			name[i] = allocname[i];
		free(allocname);
  }
#else
  name = t.name();
#endif
  return name;
}
예제 #3
0
/**
 * \retval true: if the given class has the given property
 */
bool RPropertyTypeId::hasPropertyType(const std::type_info& classInfo,
        RPropertyTypeId propertyTypeId) {
    if (!propertyTypeByObjectMap.contains(classInfo.name())) {
        return false;
    }
    return propertyTypeByObjectMap[classInfo.name()].contains(propertyTypeId);
}
예제 #4
0
// declared in src/base/types.h
string nameOfType(const std::type_info& type) {
  try {
    return TypeMap::instance()[type.name()];
  }
  catch (EssentiaException&) {
    return demangle(type.name());
  }
}
예제 #5
0
    bool
    IsEnabled( const std::type_info &tp, int id )
    {
#   ifdef NDEBUG // _table enables reports (Release)
        return ( _table.find( tp.name() ) != _table.end() );
#   else         // _table disables reports (Debug)
        return ( _table.find( tp.name() ) == _table.end() );
#   endif
    }
예제 #6
0
std::string class_name_from_typeinfo (const std::type_info & info)
{
  TypeInfo& ti = TypeInfo::instance();
  std::map<std::string, std::string>::const_iterator it =
      ti.portable_types.find(info.name());

  cf_assert_desc(Common::demangle(info.name()).c_str(), it != ti.portable_types.end() );

  return it->second;
}
예제 #7
0
파일: Plugins.cpp 프로젝트: vvolkl/DD4hep
void PluginService::addFactory(const std::string& id, stub_t stub,
                               const std::type_info&  signature_type,
                               const std::type_info&  return_type)
{
    if ( PluginService::debug() )  {
        printout(INFO,"PluginService","+++ Declared factory[%s] with signature %s type:%s.",
                 id.c_str(),signature_type.name(),return_type.name());
    }
    PluginInterface::instance().add(id.c_str(),stub,signature_type.name(),return_type.name());
}
예제 #8
0
/**
 * Gets all property type IDs that where registered for the given
 * class.
 *
 * \param classInfo The class info, e.g. typeid(ObjectA)
 *
 * \return a set of property type ID pointers or an empty set if
 * the class has no registered property types.
 */
QSet<RPropertyTypeId> RPropertyTypeId::getPropertyTypeIds(
        const std::type_info& classInfo) {
    if (propertyTypeByObjectMap.contains(classInfo.name())) {
        return propertyTypeByObjectMap[classInfo.name()];
    }

    qWarning() << QString("RPropertyIdRegistry::getPropertyTypeIds: "
                          "no properties registered for class %1")
                  .arg(classInfo.name());
    return QSet<RPropertyTypeId> ();
}
예제 #9
0
	Size Embeddable::countInstances_(const std::type_info& type) 
		throw()
	{
		// check whether we got a vector with that name
		if (instance_vectors_.has(type.name()))
		{
			// retrieve the size of the coresponding instance vector
			return (Size)instance_vectors_[type.name()].size();
		}

		return 0;
	}
예제 #10
0
std::string DefTagMetaData::GetTypeName(const std::type_info& typeInfo)
{
	// demangle typename
#ifndef _MSC_VER
	int status;
	char* ctname = abi::__cxa_demangle(typeInfo.name(), 0, 0, &status);
	const std::string tname = ctname;
	free(ctname);
#else
	const std::string tname(typeInfo.name()); // FIXME?
#endif
	return tname;
}
예제 #11
0
 bool ContextRead::query(void *ptr, const std::type_info &objType, void *&pObj)
 {
     if (type_ptr_obj_ptr_.get() &&
         (*type_ptr_obj_ptr_)[ objType.name() ].find(ptr) != (*type_ptr_obj_ptr_)[ objType.name() ].end() )
     {
         pObj = (*type_ptr_obj_ptr_)[ objType.name() ][ ptr ];
         return true;
     }
     else
     {
         return false;
     }
 }
예제 #12
0
파일: Log.hpp 프로젝트: podusowski/CakeDi
inline std::string demangle(const std::type_info & type)
{
#ifdef __GNUG__
    int status;
    char * realname = abi::__cxa_demangle(type.name(), 0, 0, &status);
    std::string result(realname);
    free(realname);

    return result;
#else
    return std::string("<") + type.name() + std::string(">");
#endif
}
예제 #13
0
void Variant::convert_to(const std::type_info& info, void* p) const
{
    try
    {
        TRY_CONVERT_TO(std::string);

        TRY_CONVERT_TO(long);

        TRY_CONVERT_TO(bool);

        TRY_CONVERT_TO(float);

        TRY_CONVERT_TO(double);

        TRY_CONVERT_TO(unsigned long);

        TRY_CONVERT_TO(int);

        TRY_CONVERT_TO(unsigned int);

        TRY_CONVERT_TO(char);

        TRY_CONVERT_TO(unsigned char);

        TRY_CONVERT_TO(int32_t);

        TRY_CONVERT_TO(uint32_t);

    }
    catch(Poco::SyntaxException& ex)
    {
        string msg = "Could not convert variant with typeid ";
        msg += self->var.type().name();
        msg += " to type";
        msg += info.name();
        msg += "error: ";
        msg += ex.what();
        msg += ", string value: " + self->var.toString();

        throw std::logic_error(msg);
    }


    string msg = "Could not convert variant with typeid ";
    msg += self->var.type().name();
    msg += " to type";
    msg += info.name();

    throw invalid_argument(msg);
}
예제 #14
0
 bool ContextRead::query(void *ptr, const std::type_info &objType, void *&pObj)
 {
     RCF_ASSERT(mEnabled);
     if (mTypeToObjMap.get() &&
         (*mTypeToObjMap)[ objType.name() ].find(ptr) != (*mTypeToObjMap)[ objType.name() ].end() )
     {
         pObj = (*mTypeToObjMap)[ objType.name() ][ ptr ];
         return true;
     }
     else
     {
         return false;
     }
 }
예제 #15
0
[[noreturn]] void JSONProtocolReaderCommon::throwUnrecognizableAsIntegral(
    folly::StringPiece s,
    std::type_info const& type) {
  throw TProtocolException(
      TProtocolException::INVALID_DATA,
      folly::to<std::string>(s, " is not a valid ", type.name()));
}
예제 #16
0
 bool Registry::isTypeRegistered(const std::type_info &ti)
 {
     ReadLock lock(mReadWriteMutex); 
     RCF_UNUSED_VARIABLE(lock);
     Rtti typeRtti = ti.name();
     return mRttiToTypename.find(typeRtti) != mRttiToTypename.end();
 }
예제 #17
0
bool TypeRegistry::Register( const std::type_info& theTypeInfo, const std::type_info& baseTypeInfo,
                             Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit )
{
  std::string uniqueTypeName  = DemangleClassName(theTypeInfo.name());

  return Register( uniqueTypeName, baseTypeInfo, createInstance, callCreateOnInit );
}
예제 #18
0
void SingletonService::Register( const std::type_info& info, BaseHandle singleton )
{
  if( singleton )
  {
    mSingletonContainer.insert( SingletonPair( info.name(), singleton ) );
  }
}
예제 #19
0
bool TypeRegistry::Register( const std::string& uniqueTypeName, const std::type_info& baseTypeInfo,
                             Dali::TypeInfo::CreateFunction createInstance, bool callCreateOnInit )
{
  bool ret = false;

  std::string baseTypeName    = DemangleClassName(baseTypeInfo.name());

  RegistryMap::iterator iter = mRegistryLut.find(uniqueTypeName);

  if( iter == mRegistryLut.end() )
  {
    mRegistryLut[uniqueTypeName] = Dali::TypeInfo(new Internal::TypeInfo(uniqueTypeName, baseTypeName, createInstance));
    ret = true;
    DALI_LOG_INFO( gLogFilter, Debug::Concise, "Type Registration %s(%s)\n", uniqueTypeName.c_str(), baseTypeName.c_str());
  }
  else
  {
    DALI_LOG_WARNING("Duplicate name for TypeRegistry for '%s'\n", + uniqueTypeName.c_str());
    DALI_ASSERT_ALWAYS(!"Duplicate type name for Type Registation");
  }

  if( callCreateOnInit )
  {
    mInitFunctions.push_back(createInstance);
  }

  return ret;
}
예제 #20
0
		void connection::connection_specific_reset(std::type_info const &type, connection_specific_data *ptr)
		{
			std::auto_ptr<connection_specific_data> tmp(ptr);
			if(ptr && typeid(*ptr)!=type) {
				throw cppdb_error(
					std::string("cppdb::connection_specific::Inconsistent pointer type")
					+ typeid(*ptr).name() 
					+ " and std::type_info reference:"
					+ type.name()
				);
			}
			for(data::conn_specific_type::iterator p=d->conn_specific.begin();p!=d->conn_specific.end();++p) {
				if(typeid(**p) == type) {
					delete *p;
					if(ptr)
						*p = tmp.release();
					else
						d->conn_specific.erase(p);
					return;
				}
			}
			if(ptr) {
				d->conn_specific.push_back(0);
				d->conn_specific.back() = tmp.release();
			}
		}
예제 #21
0
void Adaptor::RegisterSingleton(const std::type_info& info, BaseHandle singleton)
{
  if(singleton)
  {
    mSingletonContainer.insert(SingletonPair(info.name(), singleton));
  }
}
예제 #22
0
파일: demangle.hpp 프로젝트: DominikMS/sol
std::string demangle(const std::type_info& id) {
    int status;
    char* unmangled = abi::__cxa_demangle(id.name(), 0, 0, &status);
    std::string realname = unmangled;
    free(unmangled);
    return realname;
}
예제 #23
0
 unsigned register_interface(const std::type_info& info)
   {
     std::string key = info.name();
     unsigned data = ++m_max_key;
     m_interfaces[key] = data;
     return data;
   }
예제 #24
0
 unsigned register_callback(const std::type_info& info, dump_context::dump_callback callback)
   {
     std::string key = info.name();
     unsigned data = ++m_max_key;
     m_callbacks[key] = std::make_pair(data,callback);
     return data;
   }
예제 #25
0
  std::string
  name_of(const std::type_info &ti)
  {
    const static std::string typename_notavailable = "N/A";

    const char* mangled = ti.name();

    if (!mangled)
    {
      return typename_notavailable;
    }

    int status;

    char* demangled = abi::__cxa_demangle(mangled, 0, 0, &status);

    std::string rv;

    if (status != 0)
      rv = mangled;
    else
      rv = demangled ? demangled : typename_notavailable;

    std::free(demangled);
    return rv;
  }
예제 #26
0
/// Decode the template name (removing namespaces and class name)
std::string Base::decodeTemplateName(const std::type_info& t)
{
    std::string name = t.name();
    const char* realname = NULL;
    char* allocname = strdup(name.c_str());
#ifdef __GNUC__
    int status;
    realname = allocname = abi::__cxa_demangle(allocname, 0, 0, &status);
    if (realname==NULL)
#endif
        realname = allocname;
    int len = strlen(realname);
    char* newname = (char*)malloc(len+1);
    newname[0] = '\0';
    int start = 0;
    int dest = 0;
    int i = 0;
    char cprev = '\0';
    //std::cout << "name = "<<realname<<std::endl;
    while (i < len && realname[i]!='<')
        ++i;
    start = i+1; ++i;
    for (; i<len; i++)
    {
        char c = realname[i];
        //if (c == '<') break;
        if (c == ':') // && cprev == ':')
        {
            start = i+1;
        }
        else if (c == ' ' && i >= 5 && realname[i-5] == 'c' && realname[i-4] == 'l' && realname[i-3] == 'a' && realname[i-2] == 's' && realname[i-1] == 's')
        {
            start = i+1;
        }
        else if (c != ':' && c != '_' && (c < 'a' || c > 'z') && (c < 'A' || c > 'Z'))
        {
            // write result
            while (start <= i)
            {
                newname[dest++] = realname[start++];
                newname[dest] = 0;
            }
        }
        cprev = c;
        //std::cout << "i = "<<i<<" start = "<<start<<" dest = "<<dest<<" newname = "<<newname<<std::endl;
    }
    while (start < i)
    {
        newname[dest++] = realname[start++];
        newname[dest] = 0;
    }
    newname[dest] = '\0';
    //std::cout << "newname = "<<newname<<std::endl;
    name = newname;
    free(newname);
    //if (allocname)
    //    free(allocname);
    return name;
}
예제 #27
0
 void
 SignalCaster::unregisterCast (const std::type_info& type)
 {
   size_t n = functions_.erase(type.name ());
   if (0 == n) // erase did not find element
     // TODO: throw Cast not registered exception
     throw ExceptionSignal(ExceptionSignal::GENERIC);
 }
예제 #28
0
 unsigned lookup_interface(const std::type_info& info) const
   {
     std::string key = info.name();
     interface_map::const_iterator found = m_interfaces.find(key);
     if (found == m_interfaces.end())
       throw persistent_illegal_type(key);
     return found->second;
   }
예제 #29
0
 dump_context::callback_data lookup_callback(const std::type_info& info) const
   {
     std::string key = info.name();
     callback_map::const_iterator found = m_callbacks.find(key);
     if (found == m_callbacks.end())
       throw persistent_illegal_type(key);
     return found->second;
   }
예제 #30
0
static String getTypeInfoName (const std::type_info& info)
{
   #if JUCE_MSVC
    return info.raw_name();
   #else
    return info.name();
   #endif
}