11 #ifndef _GAUDI_PLUGIN_SERVICE_V2_H_
12 #define _GAUDI_PLUGIN_SERVICE_V2_H_
20 #include <string_view>
23 #if __has_include( <source_location> ) && !defined (__CLING__)
24 # include <source_location>
26 using std::source_location;
29 #elif !defined( __clang__ ) && __GNUC__ >= 8
30 # include <experimental/source_location>
32 using std::experimental::source_location;
41 const char* __func = __builtin_FUNCTION(),
int __line = __builtin_LINE(),
42 int __col = 0 ) noexcept {
54 constexpr uint_least32_t
line() const noexcept {
return _M_line; }
55 constexpr uint_least32_t
column() const noexcept {
return _M_col; }
71 namespace PluginService {
81 template <
typename R,
typename... Args>
82 struct Factory<R( Args... )> {
83 using Traits = Details::Traits<R( Args... )>;
92 return Details::Registry::instance().get<
FactoryType>( Details::stringify_id(
id ) )(
93 std::forward<Args>(
args )... );
94 }
catch ( std::bad_any_cast& ) {
130 template <
typename T,
typename F =
typename T::Factory>
139 Details::Registry::Properties
props = {},
141 using Details::Registry;
143 if (
props.find(
"ClassName" ) ==
end(
props ) )
props.emplace(
"ClassName", Details::demangle<T>() );
145 std::string_view fn = src_loc.file_name();
146 auto pos = fn.rfind(
'/' );
147 if ( pos != std::string_view::npos ) { fn.remove_prefix( pos + 1 ); }
149 s << fn <<
':' << src_loc.line();
150 props[
"declaration_location"] =
s.str();
165 #define _PS_V2_DECLARE_COMPONENT( type ) \
167 ::Gaudi::PluginService::v2::DeclareFactory<type> _PS_V2_INTERNAL_FACTORY_REGISTER_CNAME{}; \
170 #define _PS_V2_DECLARE_COMPONENT_WITH_ID( type, id ) \
172 ::Gaudi::PluginService::v2::DeclareFactory<type> _PS_V2_INTERNAL_FACTORY_REGISTER_CNAME{ \
173 ::Gaudi::PluginService::v2::Details::stringify_id( id ) }; \
176 #define _PS_V2_DECLARE_FACTORY( type, factory ) \
178 ::Gaudi::PluginService::v2::DeclareFactory<type, factory> _PS_V2_INTERNAL_FACTORY_REGISTER_CNAME{}; \
181 #define _PS_V2_DECLARE_FACTORY_WITH_ID( type, id, factory ) \
183 ::Gaudi::PluginService::v2::DeclareFactory<type, factory> _PS_V2_INTERNAL_FACTORY_REGISTER_CNAME{ \
184 ::Gaudi::PluginService::v2::Details::stringify_id( id ) }; \
187 #define _PS_V2_DECLARE_COMPONENT_PROPERTY( id, name, value ) \
189 struct _PS_V2_INTERNAL_SET_PROPERTY { \
190 _PS_V2_INTERNAL_SET_PROPERTY() { \
191 ::Gaudi::PluginService::v2::Details::Registry::instance().addProperty( #id, name, value ); \
193 } _ps_v2_internal_set_property; \
196 #if GAUDI_PLUGIN_SERVICE_USE_V2
197 # define DECLARE_COMPONENT( type ) _PS_V2_DECLARE_COMPONENT( type )
198 # define DECLARE_COMPONENT_WITH_ID( type, id ) _PS_V2_DECLARE_COMPONENT_WITH_ID( type, id )
199 # define DECLARE_FACTORY( type, factory ) _PS_V2_DECLARE_FACTORY( type, factory )
200 # define DECLARE_FACTORY_WITH_ID( type, id, factory ) _PS_V2_DECLARE_FACTORY_WITH_ID( type, id, factory )
201 # define DECLARE_COMPONENT_PROPERTY( id, name, value ) _PS_V2_DECLARE_COMPONENT_PROPERTY( id, name, value )
204 #endif //_GAUDI_PLUGIN_SERVICE_H_