38 template <
typename S,
typename... Args>
39 static typename S::ReturnType
create( Args&&... args ) {
40 return new T( std::forward<Args>( args )... );
47 void*
getCreator(
const std::string&
id,
const std::string& type );
67 p2p.src =
getCreator(
id,
typeid( F ).name() );
74 std::string
demangle(
const std::type_info&
id );
91 FactoryInfo( std::string lib,
void* p =
nullptr, std::string t =
"", std::string rt =
"",
120 template <
typename F,
typename T,
typename I>
123 typename F::FuncType src;
127 std::ostringstream o;
129 return add( o.str(), p2p.dst,
typeid(
typename F::FuncType ).name(),
130 typeid(
typename F::ReturnType ).name(),
demangle<T>() );
134 void* get(
const std::string&
id,
const std::string& type )
const;
137 const FactoryInfo& getInfo(
const std::string&
id )
const;
140 Registry& addProperty(
const std::string&
id,
const std::string& k,
const std::string& v );
143 std::set<KeyType> loadedFactoryNames()
const;
162 FactoryInfo& add(
const std::string&
id,
void* factory,
const std::string& type,
const std::string& rtype,
199 virtual void report( Level lvl,
const std::string& msg );
218#define _PS_V1_INTERNAL_FACTORY_REGISTER_CNAME( name, serial ) _register_##_##serial
220#define _PS_V1_INTERNAL_DECLARE_FACTORY_WITH_CREATOR( type, typecreator, id, factory, serial ) \
222 class _PS_V1_INTERNAL_FACTORY_REGISTER_CNAME( type, serial ) { \
224 typedef factory s_t; \
225 typedef typecreator f_t; \
226 static s_t::FuncType creator() { return &f_t::create<s_t>; } \
227 _PS_V1_INTERNAL_FACTORY_REGISTER_CNAME( type, serial )() { \
228 using ::Gaudi::PluginService::v1::Details::Registry; \
229 Registry::instance().add<s_t, type>( id, creator() ); \
231 } _PS_V1_INTERNAL_FACTORY_REGISTER_CNAME( s_##type, serial ); \
234#define _PS_V1_INTERNAL_DECLARE_FACTORY( type, id, factory, serial ) \
235 _PS_V1_INTERNAL_DECLARE_FACTORY_WITH_CREATOR( type, ::Gaudi::PluginService::v1::Details::Factory<type>, id, factory, \
#define GAUDI_PLUGIN_SERVICE_V1_INLINE
Class providing default factory functions.
static S::ReturnType create(Args &&... args)
Simple logging class, just to provide a default implementation.
Logger(Level level=Warning)
void setLevel(Level level)
void debug(const std::string &msg)
void info(const std::string &msg)
void warning(const std::string &msg)
void error(const std::string &msg)
virtual void report(Level lvl, const std::string &msg)
In-memory database of the loaded factories.
bool m_initialized
Flag recording if the registry has been initialized or not.
static Registry & instance()
Retrieve the singleton instance of Registry.
std::map< KeyType, FactoryInfo > FactoryMap
Type used for the database implementation.
std::recursive_mutex m_mutex
Mutex used to control concurrent access to the internal data.
FactoryInfo & add(const I &id, typename F::FuncType ptr)
Add a factory to the database.
Registry(const Registry &)
Private copy constructor for the singleton pattern.
void initialize()
Initialize the registry loading the list of factories from the .component files in the library search...
Registry()
Private constructor for the singleton pattern.
const FactoryMap & factories() const
Return the known factories (loading the list if not yet done).
FactoryMap & factories()
Return the known factories (loading the list if not yet done).
FactoryMap m_factories
Internal storage for factories.
GAUDIPS_API void setLogger(Logger *logger)
Set the logger instance to use.
GAUDIPS_API Logger & logger()
Return the current logger instance.
std::string demangle()
Return a canonical name for the template argument.
GAUDIPS_API std::string demangle(const std::type_info &id)
Return a canonical name for type_info object (implementation borrowed from GaudiKernel/System).
GAUDIPS_API void * getCreator(const std::string &id, const std::string &type)
Function used to load a specific factory function.
GAUDIPS_API void SetDebug(int debugLevel)
Backward compatibility with Reflex.
GAUDIPS_API int Debug()
Backward compatibility with Reflex.
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
FactoryInfo(std::string lib, void *p=nullptr, std::string t="", std::string rt="", std::string cn="", Properties props=Properties())
FactoryInfo & addProperty(const KeyType &k, std::string v)