The Gaudi Framework  v41r0 (bdbe7744)
Loading...
Searching...
No Matches
Gaudi::PluginService::v1::Details Namespace Reference

Classes

class  Factory
 Class providing default factory functions. More...
class  Registry
 In-memory database of the loaded factories. More...
class  Logger
 Simple logging class, just to provide a default implementation. More...

Functions

GAUDIPS_API void * getCreator (const std::string &id, const std::string &type)
 Function used to load a specific factory function.
template<typename F>
F getCreator (const std::string &id)
 Convoluted implementation of getCreator with an embedded reinterpret_cast, used to avoid the warning.
GAUDIPS_API std::string demangle (const std::type_info &id)
 Return a canonical name for type_info object (implementation borrowed from GaudiKernel/System).
template<typename T>
std::string demangle ()
 Return a canonical name for the template argument.
GAUDIPS_API Logger & logger ()
 Return the current logger instance.
GAUDIPS_API void setLogger (Logger *logger)
 Set the logger instance to use.
std::string demangle (const std::string &id)

Function Documentation

◆ demangle() [1/3]

template<typename T>
std::string Gaudi::PluginService::v1::Details::demangle ( )
inline

Return a canonical name for the template argument.

Definition at line 78 of file PluginServiceDetailsV1.h.

78 {
79 return demangle( typeid( T ) );
80 }
std::string demangle()
Return a canonical name for the template argument.

◆ demangle() [2/3]

std::string Gaudi::PluginService::v1::Details::demangle ( const std::string & id)

Definition at line 119 of file PluginServiceV1.cpp.

119 {
120 int status;
121 auto realname = std::unique_ptr<char, decltype( free )*>(
122 abi::__cxa_demangle( id.c_str(), nullptr, nullptr, &status ), free );
123 if ( !realname ) return id;
124 return std::regex_replace(
125 realname.get(),
126 std::regex{ "std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >( (?=>))?" },
127 "std::string" );
128 }

◆ demangle() [3/3]

std::string Gaudi::PluginService::v1::Details::demangle ( const std::type_info & id)

Return a canonical name for type_info object (implementation borrowed from GaudiKernel/System).

Definition at line 129 of file PluginServiceV1.cpp.

129{ return demangle( id.name() ); }

◆ getCreator() [1/2]

template<typename F>
F Gaudi::PluginService::v1::Details::getCreator ( const std::string & id)
inline

Convoluted implementation of getCreator with an embedded reinterpret_cast, used to avoid the warning.

warning: ISO C++ forbids casting between pointer-to-function and pointer-to-object

It is an ugly trick but works.
See:

Definition at line 62 of file PluginServiceDetailsV1.h.

62 {
63 union {
64 void* src;
65 F dst;
66 } p2p;
67 p2p.src = getCreator( id, typeid( F ).name() );
68 return p2p.dst;
69 }
GAUDIPS_API void * getCreator(const std::string &id, const std::string &type)
Function used to load a specific factory function.

◆ getCreator() [2/2]

void * Gaudi::PluginService::v1::Details::getCreator ( const std::string & id,
const std::string & type )

Function used to load a specific factory function.

Returns
the pointer to the factory function.

Definition at line 115 of file PluginServiceV1.cpp.

115 {
116 return Registry::instance().get( id, type );
117 }
void * get(const std::string &id, const std::string &type) const
Retrieve the factory for the given id.
static Registry & instance()
Retrieve the singleton instance of Registry.

◆ logger()

Logger & Gaudi::PluginService::v1::Details::logger ( )

Return the current logger instance.

Definition at line 293 of file PluginServiceV1.cpp.

293{ return *s_logger; }

◆ setLogger()

void Gaudi::PluginService::v1::Details::setLogger ( Logger * logger)

Set the logger instance to use.

It must be a new instance and the ownership is passed to the function.

Definition at line 294 of file PluginServiceV1.cpp.

294{ s_logger.reset( logger ); }
GAUDIPS_API Logger & logger()
Return the current logger instance.