| The Gaudi Framework v32r1 (f65d50dc)

capi_pluginservice.cpp
Go to the documentation of this file.
1 #include "capi_pluginservice.h"
2
3 #define GAUDI_PLUGIN_SERVICE_V2
4 #include <Gaudi/PluginService.h>
5
6 #include <algorithm>
7 #include <vector>
8
9 #include <iostream>
10
11 using namespace Gaudi::PluginService::v2::Details;
12
13 cgaudi_pluginsvc_t cgaudi_pluginsvc_instance() {
14 static Registry& cxxreg = Registry::instance();
15 return {&cxxreg};
16 }
17
18 int cgaudi_pluginsvc_get_factory_size( cgaudi_pluginsvc_t self ) {
19 const Registry::FactoryMap& fmap = static_cast<const Registry*>( self.registry )->factories();
20 return int( fmap.size() );
21 }
22
23 cgaudi_factory_t cgaudi_pluginsvc_get_factory_at( cgaudi_pluginsvc_t self, int n ) {
24 const Registry* reg = static_cast<const Registry*>( self.registry );
25 const auto& factories = reg->factories();
26 if ( n >= static_cast<int>( factories.size() ) ) return {self, nullptr};
27 return {self, next( begin( factories ), n )->first.c_str()};
28 }
29
30 const char* cgaudi_factory_get_library( cgaudi_factory_t self ) {
31 Registry& reg = Registry::instance();
32 return reg.getInfo( self.id ).library.c_str();
33 }
34
35 const char* cgaudi_factory_get_type( cgaudi_factory_t self ) {
36 Registry& reg = Registry::instance();
37 static std::string cache;
38 cache = demangle( reg.getInfo( self.id ).factory.type() );
39 return cache.c_str();
40 }
41
42 const char* cgaudi_factory_get_classname( cgaudi_factory_t self ) {
43 Registry& reg = Registry::instance();
44 static std::string cache;
45 cache = reg.getInfo( self.id ).getprop( "ClassName" );
46 return cache.c_str();
47 }
48
49 int cgaudi_factory_get_property_size( cgaudi_factory_t self ) {
50 Registry& reg = Registry::instance();
51 const Registry::FactoryInfo& fi = reg.getInfo( self.id );
52 return int( fi.properties.size() );
53 }
54
55 cgaudi_property_t cgaudi_factory_get_property_at( cgaudi_factory_t self, int n ) {
56 cgaudi_property_t cprop{self.registry, self.id, nullptr};
57 Registry& reg = Registry::instance();
58 const Registry::FactoryInfo& fi = reg.getInfo( cprop.id );
59 if ( n < static_cast<int>( fi.properties.size() ) ) cprop.key = next( begin( fi.properties ), n )->first.c_str();
60 return cprop;
61 }
62
63 const char* cgaudi_property_get_key( cgaudi_property_t self ) { return self.key; }
64
65 const char* cgaudi_property_get_value( cgaudi_property_t self ) {
66 Registry& reg = Registry::instance();
67 const Registry::FactoryInfo& fi = reg.getInfo( self.id );
68 auto prop = fi.properties.find( self.key );
69 return prop != fi.properties.end() ? prop->second.c_str() : nullptr;
70 }
cgaudi_factory_get_property_at
cgaudi_property_t cgaudi_factory_get_property_at(cgaudi_factory_t self, int n)
Definition: capi_pluginservice.cpp:55
cgaudi_pluginsvc_t
Definition: capi_pluginservice.h:38
cgaudi_factory_get_classname
const char * cgaudi_factory_get_classname(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:42
cgaudi_pluginsvc_instance
cgaudi_pluginsvc_t cgaudi_pluginsvc_instance()
Definition: capi_pluginservice.cpp:13
capi_pluginservice.h
std::string
STL class.
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:210
cgaudi_property_get_value
const char * cgaudi_property_get_value(cgaudi_property_t self)
Definition: capi_pluginservice.cpp:65
cgaudi_property_get_key
const char * cgaudi_property_get_key(cgaudi_property_t self)
Definition: capi_pluginservice.cpp:63
cgaudi_pluginsvc_get_factory_size
int cgaudi_pluginsvc_get_factory_size(cgaudi_pluginsvc_t self)
Definition: capi_pluginservice.cpp:18
cgaudi_factory_t
Definition: capi_pluginservice.h:42
cgaudi_property_t::registry
cgaudi_pluginsvc_t registry
Definition: capi_pluginservice.h:48
GaudiPluginService.cpluginsvc.registry
def registry()
Definition: cpluginsvc.py:71
cgaudi_factory_get_property_size
int cgaudi_factory_get_property_size(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:49
cgaudi_property_t
Definition: capi_pluginservice.h:47
PluginService.h
cgaudi_pluginsvc_get_factory_at
cgaudi_factory_t cgaudi_pluginsvc_get_factory_at(cgaudi_pluginsvc_t self, int n)
Definition: capi_pluginservice.cpp:23
std::string::c_str
T c_str(T... args)
cgaudi_factory_get_type
const char * cgaudi_factory_get_type(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:35
GaudiPluginService.cpluginsvc.factories
def factories()
Definition: cpluginsvc.py:81
Gaudi::PluginService::v2::Details::demangle
std::string demangle(const std::string &id)
Definition: PluginServiceV2.cpp:98
Gaudi::PluginService::v2::Details
Definition: PluginServiceV2.cpp:97
Gaudi::Utils::begin
AttribStringParser::Iterator begin(const AttribStringParser &parser)
Definition: AttribStringParser.h:120
cgaudi_factory_get_library
const char * cgaudi_factory_get_library(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:30