Gyoto
Classes | Namespaces | Macros | Functions
GyotoRegister.h File Reference

Gyoto registers. More...

#include <string>
#include <glob.h>
#include <filesystem>
#include "GyotoSmartPointer.h"

Go to the source code of this file.

Classes

class  Gyoto::Register::Entry
 Entry in a register (or a full register) More...
 

Namespaces

 Gyoto
 Namespace for the Gyoto library.
 
 Gyoto::Register
 Gyoto registers.
 

Macros

#define GYOTO_GETSUBCONTRACTOR(space)
 Defines the getSubcontractor() function for namespace space. More...
 

Functions

void Gyoto::Register::init (char const *pluglist=NULL)
 Initialise the various registers. More...
 
void Gyoto::Register::list ()
 List the various registers.
 
void * Gyoto::loadPlugin (char const *const plugname, int nofail=0)
 Load a plugin by name. More...
 
bool Gyoto::havePlugin (std::string plugname)
 Check whether a given plug-in has already been loaded. More...
 
void Gyoto::requirePlugin (std::string plugname, int nofail=0)
 Load a plugin by name, only if not loaded yet. More...
 
std::vector< std::string > Gyoto::pluginPath ()
 Get a copy of the plug-in path.
 
void Gyoto::pluginPath (const std::vector< std::string > &v)
 Set the plug-in path.
 

Detailed Description

Gyoto registers.

Gyoto::Register::Entry instances are used to map kind names to Gyoto::SmartPointee::Subcontractor_t functions used to instantiate objects from XML files through the Gyoto::Factory.

Macro Definition Documentation

◆ GYOTO_GETSUBCONTRACTOR

#define GYOTO_GETSUBCONTRACTOR (   space)

Defines the getSubcontractor() function for namespace space.

This macro is called for instance to define Gyoto::Metric::getSubcontractor(). A function defined this way will:

  • load any mandatory (i.e. not prepended with "fallback:") plug-in listed in plugin using requirePlugin();
  • if the Gyoto::space::Register_ register is still empty at this point, load fallback (i.e. prepended with "fallback:") plug-ins listed in plugin until it is not anymore;
  • if plugin is empty of contains only fallback plug-ins, look for a subcontractor matching name in the register; if a match is found, insert the name of the corresponding plug-in in plugin and return a pointer to the matching subcontractor;
  • look for a subcontractor matching name and one mandatory plug-in from plugin in the relevant register; if a match is found, return the subcontractor;
  • for each fallback plugin plg:
    • try to load and look for a subcontractor matching name and plg;
    • try to find a file that matches plg as a glob pattern, if one exists, try to load it as a plug-in and look for a subcontractor matching pname is it;
    • try to find a file that matches plg as a glob pattern, if one exists, try to load it as a plug-in and look for a subcontractor matching pname is it;
    • try to find a file that matches <directory>/libgyoto-<plg>.so for every directory in the plug-in path. If such a file exists, try to load it as a plug-in and look for a subcontractor matching pname is it; At any point, if a matching subcontracting subcontractor is found, return it.

Else,

  • if errmode is 1, return NULL;
  • if errmode is 0, throw a Gyoto::Error.
Parameters
[in]spacea Gyoto namespace such as Metric, Astrobj, Spectrum or Spectrometer.