| The Gaudi Framework v28r2p1 (f1a77ff4)

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

- File List
- File Members

capi_pluginservice.cpp
Go to the documentation of this file.
1 #include <vector>
2 #include <algorithm>
3 #include "capi_pluginservice.h"
4 #include <Gaudi/PluginService.h>
5
6 #include <iostream>
7 using namespace Gaudi::PluginService::Details;
8
9 cgaudi_pluginsvc_t
10 cgaudi_pluginsvc_instance()
11 {
12 static Registry& cxxreg = Registry::instance();
13 return { (void*)(&cxxreg) };
14 }
15
16 int
17 cgaudi_pluginsvc_get_factory_size(cgaudi_pluginsvc_t self)
18 {
19 const Registry::FactoryMap &fmap = ((const Registry*)self.registry)->factories();
20 return int(fmap.size());
21 }
22
23 cgaudi_factory_t
24 cgaudi_pluginsvc_get_factory_at(cgaudi_pluginsvc_t self, int n)
25 {
26 const Registry *reg = ((const Registry*)self.registry);
27 const auto& factories = reg->factories();
28 if ( n >= (int)factories.size() )
29 return {self, nullptr};
30 return {self, next( begin( factories ), n)->first.c_str()};
31 }
32
33 const char*
34 cgaudi_factory_get_library(cgaudi_factory_t self)
35 {
36 Registry &reg = Registry::instance();
37 return reg.getInfo(self.id).library.c_str();
38 }
39
40 const char*
41 cgaudi_factory_get_type(cgaudi_factory_t self)
42 {
43 Registry &reg = Registry::instance();
44 return reg.getInfo(self.id).type.c_str();
45 }
46
47 const char*
48 cgaudi_factory_get_rtype(cgaudi_factory_t self)
49 {
50 Registry &reg = Registry::instance();
51 return reg.getInfo(self.id).rtype.c_str();
52 }
53
54 const char*
55 cgaudi_factory_get_classname(cgaudi_factory_t self)
56 {
57 Registry &reg = Registry::instance();
58 return reg.getInfo(self.id).className.c_str();
59 }
60
61 int
62 cgaudi_factory_get_property_size(cgaudi_factory_t self)
63 {
64 Registry &reg = Registry::instance();
65 const Registry::FactoryInfo& fi = reg.getInfo(self.id);
66 return int(fi.properties.size());
67 }
68
69
70 cgaudi_property_t
71 cgaudi_factory_get_property_at(cgaudi_factory_t self, int n)
72 {
73 cgaudi_property_t cprop{ self.registry, self.id, nullptr };
74 Registry &reg = Registry::instance();
75 const Registry::FactoryInfo& fi = reg.getInfo( cprop.id );
76 if ( n < (int)fi.properties.size() )
77 cprop.key = next( begin( fi.properties ), n )->first.c_str();
78 return cprop;
79 }
80
81 const char*
82 cgaudi_property_get_key(cgaudi_property_t self)
83 {
84 return self.key;
85 }
86
87 const char*
88 cgaudi_property_get_value(cgaudi_property_t self)
89 {
90 Registry &reg = Registry::instance();
91 const Registry::FactoryInfo& fi = reg.getInfo(self.id);
92 auto prop = fi.properties.find(self.key);
93 return prop != fi.properties.end() ? prop->second.c_str() : nullptr;
94 }
cgaudi_factory_get_property_at
cgaudi_property_t cgaudi_factory_get_property_at(cgaudi_factory_t self, int n)
Definition: capi_pluginservice.cpp:71
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:55
Gaudi::PluginService::Details::Registry::getInfo
const FactoryInfo & getInfo(const std::string &id) const
Retrieve the FactoryInfo object for an id.
Definition: PluginService.cpp:303
std::map::end
T end(T...args)
Gaudi::PluginService::Details::Registry::FactoryInfo
Definition: PluginServiceDetails.h:106
std::map< KeyType, FactoryInfo >
Gaudi::PluginService::Details::Registry::FactoryInfo::properties
Properties properties
Definition: PluginServiceDetails.h:121
cgaudi_pluginsvc_instance
cgaudi_pluginsvc_t cgaudi_pluginsvc_instance()
Definition: capi_pluginservice.cpp:10
begin
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:48
capi_pluginservice.h
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:217
cgaudi_property_get_value
const char * cgaudi_property_get_value(cgaudi_property_t self)
Definition: capi_pluginservice.cpp:88
cgaudi_property_get_key
const char * cgaudi_property_get_key(cgaudi_property_t self)
Definition: capi_pluginservice.cpp:82
cgaudi_pluginsvc_get_factory_size
int cgaudi_pluginsvc_get_factory_size(cgaudi_pluginsvc_t self)
Definition: capi_pluginservice.cpp:17
cgaudi_factory_get_rtype
const char * cgaudi_factory_get_rtype(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:48
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:163
cgaudi_property_t::registry
cgaudi_pluginsvc_t registry
Definition: capi_pluginservice.h:48
GaudiPluginService.cpluginsvc.registry
def registry()
Definition: cpluginsvc.py:63
cgaudi_factory_get_property_size
int cgaudi_factory_get_property_size(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:62
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:24
Gaudi::PluginService::Details::Registry::FactoryInfo::library
std::string library
Definition: PluginServiceDetails.h:116
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:145
cgaudi_factory_get_type
const char * cgaudi_factory_get_type(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:41
Gaudi::PluginService::Details::Registry::FactoryInfo::rtype
std::string rtype
Definition: PluginServiceDetails.h:119
Gaudi::PluginService::Details::Registry
In-memory database of the loaded factories.
Definition: PluginServiceDetails.h:99
GaudiPluginService.cpluginsvc.factories
def factories()
Definition: cpluginsvc.py:72
Gaudi::PluginService::Details
Definition: PluginServiceDetails.h:49
Gaudi::PluginService::Details::Registry::FactoryInfo::className
std::string className
Definition: PluginServiceDetails.h:120
Gaudi::PluginService::Details::Registry::FactoryInfo::type
std::string type
Definition: PluginServiceDetails.h:118
cgaudi_factory_get_library
const char * cgaudi_factory_get_library(cgaudi_factory_t self)
Definition: capi_pluginservice.cpp:34