| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
capi_pluginservice.cpp
Go to the documentation of this file.
1 #include <vector>
2 #include "capi_pluginservice.h"
3 #include <Gaudi/PluginService.h>
4
5 #include <iostream>
6 using namespace Gaudi::PluginService::Details;
7
8 cgaudi_pluginsvc_t
9 cgaudi_pluginsvc_instance()
10 {
11 static Registry& cxxreg = Registry::instance();
12 cgaudi_pluginsvc_t reg;
13 reg.registry = (void*)(&cxxreg);
14 return reg;
15 }
16
17 int
18 cgaudi_pluginsvc_get_factory_size(cgaudi_pluginsvc_t self)
19 {
20 const Registry::FactoryMap &fmap = ((const Registry*)self.registry)->factories();
21 return int(fmap.size());
22 }
23
24
25 cgaudi_factory_t
26 cgaudi_pluginsvc_get_factory_at(cgaudi_pluginsvc_t self, int n)
27 {
28 const Registry *reg = ((const Registry*)self.registry);
29 std::vector<Registry::KeyType> keys;
30 keys.reserve(reg->factories().size());
31 for (Registry::FactoryMap::const_iterator
32 itr = reg->factories().begin(),
33 iend= reg->factories().end();
34 itr != iend;
35 itr++) {
36 keys.push_back(itr->first);
37 }
38 const char *key = keys[n].c_str();
39 cgaudi_factory_t fac;
40 fac.registry = self;
41 fac.id = key;
42 return fac;
43 }
44
45 const char*
46 cgaudi_factory_get_library(cgaudi_factory_t self)
47 {
48 Registry &reg = Registry::instance();
49 std::string id = self.id;
50 const Registry::FactoryInfo& fi = reg.getInfo(id);
51 return fi.library.c_str();
52 }
53
54 const char*
55 cgaudi_factory_get_type(cgaudi_factory_t self)
56 {
57 Registry &reg = Registry::instance();
58 std::string id = self.id;
59 const Registry::FactoryInfo& fi = reg.getInfo(id);
60 return fi.type.c_str();
61 }
62
63 const char*
64 cgaudi_factory_get_rtype(cgaudi_factory_t self)
65 {
66 Registry &reg = Registry::instance();
67 std::string id = self.id;
68 const Registry::FactoryInfo& fi = reg.getInfo(id);
69 return fi.rtype.c_str();
70 }
71
72 const char*
73 cgaudi_factory_get_classname(cgaudi_factory_t self)
74 {
75 Registry &reg = Registry::instance();
76 std::string id = self.id;
77 const Registry::FactoryInfo& fi = reg.getInfo(id);
78 return fi.className.c_str();
79 }
80
81 int
82 cgaudi_factory_get_property_size(cgaudi_factory_t self)
83 {
84 Registry &reg = Registry::instance();
85 std::string id = self.id;
86 const Registry::FactoryInfo& fi = reg.getInfo(id);
87 return int(fi.properties.size());
88 }
89
90
91 cgaudi_property_t
92 cgaudi_factory_get_property_at(cgaudi_factory_t self, int n)
93 {
94 cgaudi_property_t cprop;
95 cprop.registry = self.registry;
96 cprop.id = self.id;
97 cprop.key = NULL;
98 Registry &reg = Registry::instance();
99 std::string id = cprop.id;
100 const Registry::FactoryInfo& fi = reg.getInfo(id);
101 int i = 0;
102 for (Registry::Properties::const_iterator
103 itr = fi.properties.begin(),
104 iend = fi.properties.end();
105 itr != iend;
106 itr++, i++) {
107 if (i == n) {
108 cprop.key = itr->first.c_str();
109 return cprop;
110 }
111 }
112 return cprop;
113 }
114
115 const char*
116 cgaudi_property_get_key(cgaudi_property_t self)
117 {
118 return self.key;
119 }
120
121 const char*
122 cgaudi_property_get_value(cgaudi_property_t self)
123 {
124 Registry &reg = Registry::instance();
125 std::string id = self.id;
126 const Registry::FactoryInfo& fi = reg.getInfo(id);
127 Registry::KeyType key = self.key;
128 Registry::Properties::const_iterator prop = fi.properties.find(key);
129 if (prop == fi.properties.end()) {
130 return NULL;
131 }
132 return prop->second.c_str();
133 }