Sierra Toolkit
Version of the Day
|
#include <UserPlugin.hpp>
Classes | |
struct | less_nocase |
Class hash_nocase implements a hash, case insensitive NamePair hash functor. More... | |
Public Types | |
typedef std::pair< const std::type_info *, std::string > | NamePair |
Typedef NamePair is the derived class key. | |
typedef std::map< NamePair, void *, less_nocase > | RegistryMap |
Typedef RegistryMap is the registration map. | |
Public Member Functions | |
Registry () | |
Registry (const NamePair &name_pair) | |
Creates a new Registry instance and registers it, and more importantly the derived class factory with the specified name pair. More... | |
virtual | ~Registry () |
void | registerIt (const NamePair &name_pair, void *func_ptr) |
Member function registerIt registers a name pair with a void pointer. More... | |
void * | getPluginPtr (const NamePair &name_pair) const |
Member function getPluginPtr find the function with the name pair specified. More... | |
void * | getFunctionPtr (const NamePair &name_pair) const |
Member function getFunctionPtr find the function with the name pair specified. More... | |
Registry * | getFactoryPtr (const NamePair &name) const |
Member function getFuncPtr returns the function pointer with the specfied <it>name_pair. More... | |
void * | getFuncPtr (const NamePair &name_pair) const |
Member function getFuncPtr returns the function pointer with the specfied <it>name_pair. More... | |
std::vector< std::string > | getDerivedNames (const std::type_info &type) const |
Member function getDerivedNames returns names assocaited with the function pointers of the specified type. More... | |
std::ostream & | verbose_print (std::ostream &os) const |
Member function dump dumps the registry. More... | |
stk_classic::diag::Writer & | verbose_print (stk_classic::diag::Writer &dout) const |
Member function verbose_print dumps the registry. More... | |
template<> | |
void * | getsym (const char *sym) |
template<> | |
void * | getsym (const char *sym) |
Static Public Member Functions | |
static RegistryMap & | getRegistryMap () |
static Registry & | rootInstance () |
Member function rootInstance creates the singleton. More... | |
static void | registerDL (const char *so_path, const char *function_name=0) |
Member function registerDL opens a dynamic library and optionally executes a "C" registration function. More... | |
template<typename T > | |
static T | getsym (const char *sym) |
template<class T > | |
static T & | create (const std::string &derived_name) |
Class Registry serves as a singleton for holding templatized createInstance and UserSubroutine function pointers and pointer to class factory objects. The registry is simply a mapping of name pairs to a void pointer. The name pair consists of the base class name and the derived class names. And, since the only legal way to get things into the registry is via the and UserSubroutine classes, there is no signature checking performed at this level
There should never be a need to instantiate this singleton as the UserSubroutine registration process should perform that function when necessary.
Definition at line 55 of file UserPlugin.hpp.
|
inline |
Creates a new Registry instance.
Definition at line 123 of file UserPlugin.hpp.
|
inlineexplicit |
Creates a new Registry instance and registers it, and more importantly the derived class factory with the specified name pair.
name_pair | a NamePair gives the name to the registry entry. |
Definition at line 133 of file UserPlugin.hpp.
|
inlinevirtual |
Destructor ~Registry is virtual to fake polymorphism so that the registry class can utilize additional compiler/runtime checks that the registered class is indeed a class factory.
Definition at line 142 of file UserPlugin.hpp.
|
static |
Member function rootInstance creates the singleton.
Definition at line 44 of file UserPlugin.cpp.
|
static |
Member function registerDL opens a dynamic library and optionally executes a "C" registration function.
If function is specified, and not zero length, the function must exist. If the function name specified with zero length, the function "dl_register" is executed if it exists. If the function name is not found, if platform specific fortran suffix is appended and the function is searched again.
If no function name is specified, no registration function is executed.
NOTE: Loading C++ sharable objects results in static object construction upon load.
so_path | a char const pointer to the path of the shareable object file. If the path does not contains a '/' character, the file is searched for through the LD_LIBRARY_PATH envirnment variable. |
function_name | a char const pointer to the name of a registration function which will be called immediately after loading the sharable object. |
Definition at line 151 of file UserPlugin.cpp.
void sierra::Plugin::Registry::registerIt | ( | const NamePair & | name_pair, |
void * | func_ptr | ||
) |
Member function registerIt registers a name pair with a void pointer.
If the name pair already exists within the registry, a std::invalid_argument exception is thrown with the offending name pair called out.
name_pair | a NamePair const reference to the name pair to be registered. |
func_ptr | a void pointer to the function to be registered. |
a | std::invalid_argument exception is thrown if there is an instance creation function already registered for the derived class. |
Definition at line 54 of file UserPlugin.cpp.
void * sierra::Plugin::Registry::getPluginPtr | ( | const NamePair & | name_pair | ) | const |
Member function getPluginPtr find the function with the name pair specified.
If the name pair does not exist within the registry, a std::invalid_argument exception is thrown with the offending name pair called out.
name_pair | a NamePair const reference to the name pair to be retrieved. |
a | std::invalid_argument exception is thrown if the function is not found. |
Definition at line 75 of file UserPlugin.cpp.
void * sierra::Plugin::Registry::getFunctionPtr | ( | const NamePair & | name_pair | ) | const |
Member function getFunctionPtr find the function with the name pair specified.
If the name pair does not exist within the registry, a std::invalid_argument exception is thrown with the offending name pair called out.
name_pair | a NamePair const reference to the name pair to be retrieved. |
a | std::invalid_argument exception is thrown if the function is not found. |
Definition at line 93 of file UserPlugin.cpp.
Member function getFuncPtr returns the function pointer with the specfied <it>name_pair.
name_pair | a NamePair const reference to the registered name pair. |
Definition at line 110 of file UserPlugin.cpp.
void * sierra::Plugin::Registry::getFuncPtr | ( | const NamePair & | name_pair | ) | const |
Member function getFuncPtr returns the function pointer with the specfied <it>name_pair.
name_pair | a NamePair const reference to the registered name pair. |
Definition at line 126 of file UserPlugin.cpp.
std::vector< std::string > sierra::Plugin::Registry::getDerivedNames | ( | const std::type_info & | type | ) | const |
Member function getDerivedNames returns names assocaited with the function pointers of the specified type.
type | a std::type_info const reference to typeid to retrieve the derived names. |
Definition at line 135 of file UserPlugin.cpp.
|
inlinestatic |
Member template function create creates an instance of the desired object by providing the factory responsible for generating that object type. The create factory is retrieved using the base class name specified by the factory base class and the specified derived name.
The derived factory is responsible for implementing the appropriate operator() functions to constuct the derived object.
derived_name | a std::string const reference to the derived object's name/ |
Definition at line 283 of file UserPlugin.hpp.
std::ostream & sierra::Plugin::Registry::verbose_print | ( | std::ostream & | os | ) | const |
Member function dump dumps the registry.
os | a std::ostream reference to dump the registry to. |
Definition at line 212 of file UserPlugin.cpp.
stk_classic::diag::Writer & sierra::Plugin::Registry::verbose_print | ( | stk_classic::diag::Writer & | dout | ) | const |
Member function verbose_print dumps the registry.
os | a std::ostream reference to dump the registry to. |
Definition at line 222 of file UserPlugin.cpp.