All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
11 {
12  static Registry& cxxreg = Registry::instance();
13  return { (void*)(&cxxreg) };
14 }
15 
16 int
18 {
19  const Registry::FactoryMap &fmap = ((const Registry*)self.registry)->factories();
20  return int(fmap.size());
21 }
22 
23 constexpr struct select1st_t {
24  template <typename S,typename T>
25  const S& operator()(const std::pair<S,T>& p) const
26  { return p.first; }
27  template <typename S,typename T>
28  S& operator()(std::pair<S,T>& p) const
29  { return p.first; }
30 } select1st {};
31 
34 {
35  const Registry *reg = ((const Registry*)self.registry);
36  std::vector<Registry::KeyType> keys;
37  keys.reserve(reg->factories().size());
38  std::transform(reg->factories().begin(),reg->factories().end(),
39  std::back_inserter(keys), select1st );
40  return { self, keys[n].c_str() };
41 }
42 
43 const char*
45 {
47  return reg.getInfo(self.id).library.c_str();
48 }
49 
50 const char*
52 {
54  return reg.getInfo(self.id).type.c_str();
55 }
56 
57 const char*
59 {
61  return reg.getInfo(self.id).rtype.c_str();
62 }
63 
64 const char*
66 {
68  return reg.getInfo(self.id).className.c_str();
69 }
70 
71 int
73 {
75  const Registry::FactoryInfo& fi = reg.getInfo(self.id);
76  return int(fi.properties.size());
77 }
78 
79 
82 {
83  cgaudi_property_t cprop{ self.registry, self.id, nullptr };
85  const Registry::FactoryInfo& fi = reg.getInfo(cprop.id);
86  if (n<(long)fi.properties.size()) {
87  auto itr = std::next(fi.properties.cbegin(),n);
88  cprop.key = itr->first.c_str();
89  }
90  return cprop;
91 }
92 
93 const char*
95 {
96  return self.key;
97 }
98 
99 const char*
101 {
102  Registry &reg = Registry::instance();
103  const Registry::FactoryInfo& fi = reg.getInfo(self.id);
104  auto prop = fi.properties.find(self.key);
105  return prop != fi.properties.end() ? prop->second.c_str() : nullptr;
106 }
cgaudi_property_t cgaudi_factory_get_property_at(cgaudi_factory_t self, int n)
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.
constexpr struct select1st_t select1st
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)
S & operator()(std::pair< S, T > &p) const
cgaudi_factory_t cgaudi_pluginsvc_get_factory_at(cgaudi_pluginsvc_t self, int n)
const S & operator()(const std::pair< S, T > &p) const
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.
std::map< KeyType, FactoryInfo > FactoryMap
Type used for the database implementation.
const char * cgaudi_factory_get_library(cgaudi_factory_t self)