20#ifndef __GyotoRegister_H_
21#define __GyotoRegister_H_
61 void init(
char const * pluglist = NULL );
88 void *
loadPlugin(
char const *
const plugname,
int nofail = 0);
164#define GYOTO_GETSUBCONTRACTOR(space) \
165 Gyoto::space::Subcontractor_t* \
166 Gyoto::space::getSubcontractor(std::string name, std::vector<std::string> &plugin, int errmode) { \
167 for (size_t i=0; i<plugin.size(); ++i) { \
168 GYOTO_DEBUG_EXPR(plugin[i]); \
169 Gyoto::requirePlugin(plugin[i]); \
171 if (!Gyoto::space::Register_) throwError("No " GYOTO_STRINGIFY(space) " kind registered!"); \
172 Subcontractor_t* sctr= NULL; \
173 std::string plg(""); \
174 if (!plugin.size()) { \
176 (Subcontractor_t*)Gyoto::space::Register_ \
177 -> getSubcontractor(name, plg, errmode); \
178 plugin.push_back(plg); \
180 for (size_t i=plugin.size()-1; i>=0 && sctr == NULL; --i) { \
182 (Subcontractor_t*)Gyoto::space::Register_ \
183 -> getSubcontractor(name, plugin[i], 1); \
185 if (!errmode && !sctr) throwError ("Kind not found in the specified plug-ins: "+name); \
Reference-counting pointers.
Entry in a register (or a full register)
Definition: GyotoRegister.h:117
const std::string plugin_
Plug-in from which this Entry was loaded.
Definition: GyotoRegister.h:129
std::string name_
Kind name for the entry, as found in the "kind" XML attribute.
Definition: GyotoRegister.h:123
Register::Entry * next_
Next entry in the register, or NULL.
Definition: GyotoRegister.h:127
Gyoto::SmartPointee::Subcontractor_t * getSubcontractor(std::string name, std::string &plugin, int errmode=0)
Get subcontractor for a given name.
Gyoto::SmartPointee::Subcontractor_t * subcontractor_
Pointer to the Gyoto::SmartPointee::Subcontractor_t function that produces an object of this kind.
Definition: GyotoRegister.h:125
Entry(std::string name, Gyoto::SmartPointee::Subcontractor_t *subcontractor, Entry *next)
Constructor.
Gyoto::SmartPointer< Gyoto::SmartPointee > Subcontractor_t(Gyoto::FactoryMessenger *, std::vector< std::string > const &)
A subcontractor builds an object upon order from the Factory.
Definition: GyotoSmartPointer.h:114
void Register(std::string name, Gyoto::Astrobj::Subcontractor_t *scp)
Make an Astrobj kind known to the Factory.
void list()
List the various registers.
void init(char const *pluglist=NULL)
Initialise the various registers.
Namespace for the Gyoto library.
Definition: GyotoAstrobj.h:43
void * loadPlugin(char const *const plugname, int nofail=0)
Load a plugin by name.
void requirePlugin(std::string plugname, int nofail=0)
Load a plugin by name, only if not loaded yet.
bool havePlugin(std::string plugname)
Check whether a given plug-in has already been loaded.