19 #include <string_view>
22 #if __has_include( <source_location> ) && !defined (__CLING__)
23 # include <source_location>
25 using std::source_location;
28 #elif !defined( __clang__ ) && __GNUC__ >= 8
29 # include <experimental/source_location>
31 using std::experimental::source_location;
40 const char* __func = __builtin_FUNCTION(),
int __line = __builtin_LINE(),
41 int __col = 0 ) noexcept {
53 constexpr uint_least32_t
line() const noexcept {
return _M_line; }
54 constexpr uint_least32_t
column() const noexcept {
return _M_col; }
70 namespace PluginService {
80 template <
typename R,
typename... Args>
81 struct Factory<R( Args... )> {
82 using Traits = Details::Traits<R( Args... )>;
91 return Details::Registry::instance().get<
FactoryType>( Details::stringify_id(
id ) )(
92 std::forward<Args>(
args )... );
93 }
catch ( std::bad_any_cast& ) {
129 template <
typename T,
typename F =
typename T::Factory>
138 Details::Registry::Properties
props = {},
140 using Details::Registry;
142 if (
props.find(
"ClassName" ) ==
end(
props ) )
props.emplace(
"ClassName", Details::demangle<T>() );
144 std::string_view fn = src_loc.file_name();
145 auto pos = fn.rfind(
'/' );
146 if ( pos != std::string_view::npos ) { fn.remove_prefix( pos + 1 ); }
148 s << fn <<
':' << src_loc.line();
149 props[
"declaration_location"] =
s.str();
150 Registry::instance().add(
id, {
libraryName(), std::move( f ), std::move(
props ) } );
164 #define _PS_V2_DECLARE_COMPONENT( type ) \
166 ::Gaudi::PluginService::v2::DeclareFactory<type> _PS_V2_INTERNAL_FACTORY_REGISTER_CNAME{}; \
169 #define _PS_V2_DECLARE_COMPONENT_WITH_ID( type, id ) \
171 ::Gaudi::PluginService::v2::DeclareFactory<type> _PS_V2_INTERNAL_FACTORY_REGISTER_CNAME{ \
172 ::Gaudi::PluginService::v2::Details::stringify_id( id ) }; \
175 #define _PS_V2_DECLARE_FACTORY( type, factory ) \
177 ::Gaudi::PluginService::v2::DeclareFactory<type, factory> _PS_V2_INTERNAL_FACTORY_REGISTER_CNAME{}; \
180 #define _PS_V2_DECLARE_FACTORY_WITH_ID( type, id, factory ) \
182 ::Gaudi::PluginService::v2::DeclareFactory<type, factory> _PS_V2_INTERNAL_FACTORY_REGISTER_CNAME{ \
183 ::Gaudi::PluginService::v2::Details::stringify_id( id ) }; \
186 #define _PS_V2_DECLARE_COMPONENT_PROPERTY( id, name, value ) \
188 struct _PS_V2_INTERNAL_SET_PROPERTY { \
189 _PS_V2_INTERNAL_SET_PROPERTY() { \
190 ::Gaudi::PluginService::v2::Details::Registry::instance().addProperty( #id, name, value ); \
192 } _ps_v2_internal_set_property; \
195 #if GAUDI_PLUGIN_SERVICE_USE_V2
196 # define DECLARE_COMPONENT( type ) _PS_V2_DECLARE_COMPONENT( type )
197 # define DECLARE_COMPONENT_WITH_ID( type, id ) _PS_V2_DECLARE_COMPONENT_WITH_ID( type, id )
198 # define DECLARE_FACTORY( type, factory ) _PS_V2_DECLARE_FACTORY( type, factory )
199 # define DECLARE_FACTORY_WITH_ID( type, id, factory ) _PS_V2_DECLARE_FACTORY_WITH_ID( type, id, factory )
200 # define DECLARE_COMPONENT_PROPERTY( id, name, value ) _PS_V2_DECLARE_COMPONENT_PROPERTY( id, name, value )