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 
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*
35 {
37  return reg.getInfo(self.id).library.c_str();
38 }
39 
40 const char*
42 {
44  return reg.getInfo(self.id).type.c_str();
45 }
46 
47 const char*
49 {
51  return reg.getInfo(self.id).rtype.c_str();
52 }
53 
54 const char*
56 {
58  return reg.getInfo(self.id).className.c_str();
59 }
60 
61 int
63 {
65  const Registry::FactoryInfo& fi = reg.getInfo(self.id);
66  return int(fi.properties.size());
67 }
68 
69 
72 {
73  cgaudi_property_t cprop{ self.registry, self.id, nullptr };
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*
83 {
84  return self.key;
85 }
86 
87 const char*
89 {
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_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.
T end(T...args)
cgaudi_pluginsvc_t cgaudi_pluginsvc_instance()
auto begin(reverse_wrapper< T > &w)
Definition: reverse.h:48
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)
T find(T...args)
T size(T...args)
T c_str(T...args)
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.
const char * cgaudi_factory_get_library(cgaudi_factory_t self)