1 #ifndef _GAUDI_PLUGIN_SERVICE_DETAILS_V1_H_ 2 #define _GAUDI_PLUGIN_SERVICE_DETAILS_V1_H_ 29 namespace PluginService
43 template <
typename S,
typename... Args>
46 return new T( std::forward<Args>(
args )... );
102 : library(
std::move( lib ) )
104 , type(
std::move( t ) )
105 , rtype(
std::move( rt ) )
106 , className(
std::move( cn ) )
132 template <
typename F,
typename T,
typename I>
136 typename F::FuncType src;
142 return add( o.
str(), p2p.dst,
typeid(
typename F::FuncType ).
name(),
143 typeid(
typename F::ReturnType ).
name(), demangle<T>() );
161 if ( !m_initialized )
const_cast<Registry*
>( this )->initialize();
182 if ( !m_initialized ) initialize();
234 #define _PS_V1_INTERNAL_FACTORY_REGISTER_CNAME( name, serial ) _register_##_##serial 236 #define _PS_V1_INTERNAL_DECLARE_FACTORY_WITH_CREATOR( type, typecreator, id, factory, serial ) \ 239 class _PS_V1_INTERNAL_FACTORY_REGISTER_CNAME( type, serial ) \ 242 typedef factory s_t; \ 243 typedef typecreator f_t; \ 244 static s_t::FuncType creator() { return &f_t::create<s_t>; } \ 245 _PS_V1_INTERNAL_FACTORY_REGISTER_CNAME( type, serial )() \ 247 using ::Gaudi::PluginService::v1::Details::Registry; \ 248 Registry::instance().add<s_t, type>( id, creator() ); \ 250 } _PS_V1_INTERNAL_FACTORY_REGISTER_CNAME( s_##type, serial ); \ 253 #define _PS_V1_INTERNAL_DECLARE_FACTORY( type, id, factory, serial ) \ 254 _PS_V1_INTERNAL_DECLARE_FACTORY_WITH_CREATOR( type, ::Gaudi::PluginService::v1::Details::Factory<type>, id, factory, \ 257 #endif //_GAUDI_PLUGIN_SERVICE_DETAILS_H_ std::map< KeyType, std::string > Properties
Type used for the properties implementation.
Logger(Level level=Warning)
FactoryInfo & add(const I &id, typename F::FuncType ptr)
Add a factory to the database.
GAUDIPS_API void * getCreator(const std::string &id, const std::string &type)
Function used to load a specific factory function.
Simple logging class, just to provide a default implementation.
FactoryMap m_factories
Internal storage for factories.
GAUDIPS_API void setLogger(Logger *logger)
Set the logger instance to use.
void debug(const std::string &msg)
void error(const std::string &msg)
std::vector< Gaudi::Details::PropertyBase * > Properties
Registry(const Registry &)
Private copy constructor for the singleton pattern.
#define GAUDI_PLUGIN_SERVICE_V1_INLINE
FactoryMap & factories()
Return the known factories (loading the list if not yet done).
void warning(const std::string &msg)
const FactoryMap & factories() const
Return the known factories (loading the list if not yet done).
GAUDIPS_API Logger & logger()
Return the current logger instance.
In-memory database of the loaded factories.
std::map< KeyType, FactoryInfo > FactoryMap
Type used for the database implementation.
void info(const std::string &msg)
FactoryInfo & addProperty(const KeyType &k, std::string v)
GAUDIPS_API int Debug()
Backward compatibility with Reflex.
std::recursive_mutex m_mutex
Mutex used to control concurrent access to the internal data.
void setLevel(Level level)
static S::ReturnType create(Args &&...args)
GAUDIPS_API std::string demangle(const std::type_info &id)
Return a canonical name for type_info object (implementation borrowed from GaudiKernel/System).
Class providing default factory functions.
FactoryInfo(std::string lib, void *p=nullptr, std::string t="", std::string rt="", std::string cn="", Properties props=Properties())
GAUDIPS_API void SetDebug(int debugLevel)
Backward compatibility with Reflex.
Helper functions to set/get the application return code.
bool m_initialized
Flag recording if the registry has been initialized or not.