| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

capi_pluginservice.cpp
Go to the documentation of this file.
1 #include "capi_pluginservice.h"
2 #include <Gaudi/PluginService.h>
3 #include <algorithm>
4 #include <vector>
5
6 #include <iostream>
7 using namespace Gaudi::PluginService::Details;
8
9 cgaudi_pluginsvc_t cgaudi_pluginsvc_instance()
10 {
11 static Registry& cxxreg = Registry::instance();
12 return {(void*)( &cxxreg )};
13 }
14
15 int cgaudi_pluginsvc_get_factory_size( cgaudi_pluginsvc_t self )
16 {
17 const Registry::FactoryMap& fmap = ( (const Registry*)self.registry )->factories();
18 return int( fmap.size() );
19 }
20
21 cgaudi_factory_t cgaudi_pluginsvc_get_factory_at( cgaudi_pluginsvc_t self, int n )
22 {
23 const Registry* reg = ( (const Registry*)self.registry );
24 const auto& factories = reg->factories();
25 if ( n >= (int)factories.size() ) return {self, nullptr};
26 return {self, next( begin( factories ), n )->first.c_str()};
27 }
28
29 const char* cgaudi_factory_get_library( cgaudi_factory_t self )
30 {
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 {
37 Registry& reg = Registry::instance();
38 return reg.getInfo( self.id ).type.c_str();
39 }
40
41 const char* cgaudi_factory_get_rtype( cgaudi_factory_t self )
42 {
43 Registry& reg = Registry::instance();
44 return reg.getInfo( self.id ).rtype.c_str();
45 }
46
47 const char* cgaudi_factory_get_classname( cgaudi_factory_t self )
48 {
49 Registry& reg = Registry::instance();
50 return reg.getInfo( self.id ).className.c_str();
51 }
52
53 int cgaudi_factory_get_property_size( cgaudi_factory_t self )
54 {
55 Registry& reg = Registry::instance();
56 const Registry::FactoryInfo& fi = reg.getInfo( self.id );
57 return int( fi.properties.size() );
58 }
59
60 cgaudi_property_t cgaudi_factory_get_property_at( cgaudi_factory_t self, int n )
61 {
62 cgaudi_property_t cprop{self.registry, self.id, nullptr};
63 Registry& reg = Registry::instance();
64 const Registry::FactoryInfo& fi = reg.getInfo( cprop.id );
65 if ( n < (int)fi.properties.size() ) cprop.key = next( begin( fi.properties ), n )->first.c_str();
66 return cprop;
67 }
68
69 const char* cgaudi_property_get_key( cgaudi_property_t self ) { return self.key; }
70
71 const char* cgaudi_property_get_value( cgaudi_property_t self )
72 {
73 Registry& reg = Registry::instance();
74 const Registry::FactoryInfo& fi = reg.getInfo( self.id );
75 auto prop = fi.properties.find( self.key );
76 return prop != fi.properties.end() ? prop->second.c_str() : nullptr;
77 }
cgaudi_factory_get_property_at
cgaudi_property_t cgaudi_factory_get_property_at(cgaudi_factory_t self, int n)
Definition: capi_pluginservice.cpp:60
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:47
Gaudi::PluginService::Details::Registry::getInfo
const FactoryInfo & getInfo(const std::string &id) const
Retrieve the FactoryInfo object for an id.
Definition: PluginService.cpp:307
std::map::end
T end(T...args)
Gaudi::PluginService::Details::Registry::FactoryInfo
Definition: PluginServiceDetails.h:120
std::map< KeyType, FactoryInfo >
Gaudi::PluginService::Details::Registry::FactoryInfo::properties
Properties properties
Definition: PluginServiceDetails.h:137
cgaudi_pluginsvc_instance
cgaudi_pluginsvc_t cgaudi_pluginsvc_instance()
Definition: capi_pluginservice.cpp:9
begin
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:58
capi_pluginservice.h
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:228
cgaudi_property_get_value
const char * cgaudi_property_get_value(cgaudi_property_t self)
Definition: capi_pluginservice.cpp:71
cgaudi_property_get_key
const char * cgaudi_property_get_key(cgaudi_property_t self)
Definition: capi_pluginservice.cpp:69
cgaudi_pluginsvc_get_factory_size
int cgaudi_pluginsvc_get_factory_size(cgaudi_pluginsvc_t self)
Definition: capi_pluginservice.cpp:15
cgaudi_factory_get_rtype
const char * cgaudi_factory_get_rtype(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:41
cgaudi_factory_t
Definition: capi_pluginservice.h:42
Gaudi::PluginService::Details::Registry::factories
const FactoryMap & factories() const
Return the known factories (loading the list if not yet done).
Definition: PluginServiceDetails.h:180
cgaudi_property_t::registry
cgaudi_pluginsvc_t registry
Definition: capi_pluginservice.h:48
GaudiPluginService.cpluginsvc.registry
def registry()
Definition: cpluginsvc.py:70
cgaudi_factory_get_property_size
int cgaudi_factory_get_property_size(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:53
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:21
Gaudi::PluginService::Details::Registry::FactoryInfo::library
std::string library
Definition: PluginServiceDetails.h:132
std::map::find
T find(T...args)
std::map::size
T size(T...args)
std::string::c_str
T c_str(T...args)
Gaudi::PluginService::Details::Registry::instance
static Registry & instance()
Retrieve the singleton instance of Registry.
Definition: PluginService.cpp:153
cgaudi_factory_get_type
const char * cgaudi_factory_get_type(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:35
Gaudi::PluginService::Details::Registry::FactoryInfo::rtype
std::string rtype
Definition: PluginServiceDetails.h:135
Gaudi::PluginService::Details::Registry
In-memory database of the loaded factories.
Definition: PluginServiceDetails.h:112
GaudiPluginService.cpluginsvc.factories
def factories()
Definition: cpluginsvc.py:80
Gaudi::PluginService::Details
Definition: PluginServiceDetails.h:52
Gaudi::PluginService::Details::Registry::FactoryInfo::className
std::string className
Definition: PluginServiceDetails.h:136
Gaudi::PluginService::Details::Registry::FactoryInfo::type
std::string type
Definition: PluginServiceDetails.h:134
cgaudi_factory_get_library
const char * cgaudi_factory_get_library(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:29