1 #ifndef _GAUDI_PLUGIN_SERVICE_DETAILS_V2_H_ 2 #define _GAUDI_PLUGIN_SERVICE_DETAILS_V2_H_ 18 #if __cplusplus >= 201703 21 # include <boost/any.hpp> 24 using boost::any_cast;
25 using boost::bad_any_cast;
40 namespace PluginService {
52 template <
typename R,
typename... Args>
53 struct Traits<R( Args... )> {
70 template <
typename ID>
88 enum Level {
Debug = 0, Info = 1, Warning = 2, Error = 3 };
93 inline void info(
const std::string&
msg ) { report( Info, msg ); }
95 inline void warning(
const std::string&
msg ) { report( Warning, msg ); }
96 inline void error(
const std::string&
msg ) { report( Error, msg ); }
122 inline bool is_set()
const {
123 #if __cplusplus >= 201703 124 return factory.has_value();
126 return !factory.empty();
129 Properties::mapped_type getprop(
const Properties::key_type&
name )
const;
136 template <
typename F>
137 F
get(
const KeyType& id ) {
138 const FactoryInfo& info = Registry::instance().getInfo(
id,
true );
139 #ifdef GAUDI_REFLEX_COMPONENT_ALIASES 140 if ( !info.getprop(
"ReflexName" ).empty() ) {
141 const std::string real_name = info.getprop(
"ClassName" );
142 logger().
warning(
"requesting factory via old name '" +
id +
"' use '" +
143 ( real_name.
empty() ?
"<undefined>" : real_name ) +
"' instead" );
146 return std::any_cast<F>( info.factory );
150 static Registry& instance();
153 FactoryInfo&
add(
const KeyType&
id, FactoryInfo info );
156 const FactoryInfo& getInfo(
const KeyType&
id,
const bool load =
false )
const;
159 Registry& addProperty(
const KeyType&
id,
const KeyType& k,
const std::string& v );
176 Registry(
const Registry& ) =
delete;
189 FactoryMap m_factories;
199 template <
typename,
typename>
200 struct DefaultFactory;
201 template <
typename T,
typename R,
typename... Args>
202 struct DefaultFactory<T, Factory<R( Args... )>> {
203 inline typename Factory<R( Args... )>::ReturnType
operator()( Args...
args ) {
222 #define _PS_V2_INTERNAL_FACTORY_MAKE_REGISTER_CNAME_TOKEN( serial ) _register_##serial 223 #define _PS_V2_INTERNAL_FACTORY_MAKE_REGISTER_CNAME( serial ) \ 224 _PS_V2_INTERNAL_FACTORY_MAKE_REGISTER_CNAME_TOKEN( serial ) 225 #define _PS_V2_INTERNAL_FACTORY_REGISTER_CNAME _PS_V2_INTERNAL_FACTORY_MAKE_REGISTER_CNAME( __LINE__ ) 227 #endif //_GAUDI_PLUGIN_SERVICE_DETAILS_H_
#define GAUDI_PLUGIN_SERVICE_V2_INLINE
GAUDIPS_API void setLogger(Logger *logger)
Set the logger instance to use.
void warning(const std::string &msg)
std::string getDSONameFor(void *fptr)
void reportBadAnyCast(const std::type_info &factory_type, const std::string &id)
GAUDIPS_API Logger & logger()
Return the current logger instance.
GAUDIPS_API int Debug()
Backward compatibility with Reflex.
GAUDIPS_API std::string demangle(const std::type_info &id)
Return a canonical name for type_info object (implementation borrowed from GaudiKernel/System).
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
GAUDIPS_API void SetDebug(int debugLevel)
Backward compatibility with Reflex.
Helper functions to set/get the application return code.