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 
10 {
11  static Registry& cxxreg = Registry::instance();
13  reg.registry = (void*)(&cxxreg);
14  return reg;
15 }
16 
17 int
19 {
20  const Registry::FactoryMap &fmap = ((const Registry*)self.registry)->factories();
21  return int(fmap.size());
22 }
23 
24 
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*
47 {
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*
56 {
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*
65 {
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*
74 {
76  std::string id = self.id;
77  const Registry::FactoryInfo& fi = reg.getInfo(id);
78  return fi.className.c_str();
79 }
80 
81 int
83 {
85  std::string id = self.id;
86  const Registry::FactoryInfo& fi = reg.getInfo(id);
87  return int(fi.properties.size());
88 }
89 
90 
93 {
94  cgaudi_property_t cprop;
95  cprop.registry = self.registry;
96  cprop.id = self.id;
97  cprop.key = NULL;
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*
117 {
118  return self.key;
119 }
120 
121 const char*
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 }
cgaudi_property_t cgaudi_factory_get_property_at(cgaudi_factory_t self, int n)
cgaudi_pluginsvc_t registry
const char * cgaudi_factory_get_classname(cgaudi_factory_t self)
const FactoryInfo & getInfo(const std::string &id) const
Retrieve the FactoryInfo object for an id.
cgaudi_pluginsvc_t cgaudi_pluginsvc_instance()
const char * cgaudi_property_get_value(cgaudi_property_t self)
const char * cgaudi_property_get_key(cgaudi_property_t self)
int cgaudi_pluginsvc_get_factory_size(cgaudi_pluginsvc_t self)
const char * cgaudi_factory_get_rtype(cgaudi_factory_t self)
const FactoryMap & factories() const
Return the known factories (loading the list if not yet done).
cgaudi_pluginsvc_t registry
int cgaudi_factory_get_property_size(cgaudi_factory_t self)
cgaudi_factory_t cgaudi_pluginsvc_get_factory_at(cgaudi_pluginsvc_t self, int n)
static Registry & instance()
Retrieve the singleton instance of Registry.
const char * cgaudi_factory_get_type(cgaudi_factory_t self)
In-memory database of the loaded factories.
list i
Definition: ana.py:128
std::map< KeyType, FactoryInfo > FactoryMap
Type used for the database implementation.
const char * cgaudi_factory_get_library(cgaudi_factory_t self)