1 #ifndef STK_UTIL_DIAG_UserPlugin_h 2 #define STK_UTIL_DIAG_UserPlugin_h 10 #include <stk_util/diag/StringUtil.hpp> 11 #include <stk_util/util/Fortran.hpp> 12 #include <stk_util/diag/Writer_fwd.hpp> 41 std::string derived_id_name(
int derived_id);
63 typedef std::pair<const std::type_info *, std::string>
NamePair;
96 struct less_nocase :
public std::binary_function<NamePair, NamePair, bool>
101 #ifdef SIERRA_TYPE_INFO_BEFORE_EQUALITY_BUG 102 return (lhs.first->before(*rhs.first) && *lhs.first != *rhs.first)
103 || (*lhs.first == *rhs.first && second_less_nocase(lhs.second, rhs.second));
105 return lhs.first->before(*rhs.first)
106 || (*lhs.first == *rhs.first && second_less_nocase(lhs.second, rhs.second));
175 static void registerDL(
const char *so_path,
const char *function_name = 0);
177 template <
typename T>
178 static T getsym(
const char *sym);
266 std::vector<std::string>
getDerivedNames(
const std::type_info &type)
const;
283 static T &
create(
const std::string &derived_name) {
309 return registry.verbose_print(
dout);
330 template <
class Creator,
typename S = Creator *(*)()>
389 return (*creator_function);
407 return create(derived_id_name(derived_id));
419 static bool exists(
const std::string &derived_name) {
423 static std::vector<std::string> getDerivedNames() {
435 template <
class DerivedClass>
439 typedef DerivedClass XDerivedClass;
451 : m_function(DerivedClass::createInstance)
466 : m_function(create_instance)
480 : m_function(XDerivedClass::createInstance)
494 : m_function(create_instance)
576 return (*user_function);
595 return user_function;
608 static bool exists(
const std::string &derived_name) {
629 : m_function(function)
640 void *Registry::getsym<void *>(
const char *sym);
642 template <
typename T>
643 inline T Registry::getsym(
const char *sym) {
644 return static_cast<T
>(getsym<void *>(sym));
650 typedef std::type_info *type_info_func();
664 type_info_func type_id,
665 void * user_subroutine,
683 #define FORTRAN_USER_SUBROUTINE(NAME, USER_SUB) extern "C" const std::type_info * SIERRA_FORTRAN(NAME)() {return &typeid(USER_SUB::Signature);} 685 #endif // STK_UTIL_DIAG_UserPlugin_h Class template Register registers the createInstance() function with the derived_name on object creat...
Registry(const NamePair &name_pair)
Creates a new Registry instance and registers it, and more importantly the derived class factory with...
void SIERRA_FORTRAN() register_user_subroutine(type_info_func type_id, void *user_subroutine, const char *name, int name_length)
FORTRAN compatible user subprogram registration routine.
std::ostream & dout()
Diagnostic output stream.
S Signature
Subroutine call signature.
static Signature create(int derived_id)
Member function create returns the createInstance() function associated with the specified base class...
std::pair< const std::type_info *, std::string > NamePair
Typedef NamePair is the derived class key.
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 functio...
static bool exists(const std::string &derived_name)
Member function exists returns true if user function specified by derived_name exists.
std::ostream & verbose_print(std::ostream &os) const
Member function dump dumps the registry.
S Signature
Creator signature.
static bool exists(const std::string &derived_name)
Member function exists returns true if class of the type specified by derived_name exists in BaseClas...
static UserPlugin & instance()
Member function instance returns the instance of the registry, cast as a UserPlugin registry...
Register(const std::string &derived_name, Signature create_instance)
Creates a new Register instance. Upon creation, the DerivedClass::createInstance() instance creation ...
static Signature create(const std::string &derived_name)
Member function create returns the createInstance() function associated with the specified base class...
Register(int derived_id)
Creates a new Register instance. Upon creation, the DerivedClass::createInstance() instance creation ...
Class less_nocase implements a case insensitive compare functor.
static void registerFunction(const std::string &function_name, Signature *function)
Member function registerFunction registers the user function's name with the specified user function ...
void registerIt(const NamePair &name_pair, void *func_ptr)
Member function registerIt registers a name pair with a void pointer.
Register(const std::string &function_name, Signature *function)
Creates a new Register instance. Upon creation, the func_ptr() function is registered with the functi...
void * getPluginPtr(const NamePair &name_pair) const
Member function getPluginPtr find the function with the name pair specified.
static T & create(const std::string &derived_name)
static void registerCreator(const std::string &derived_name, Signature function)
Member function registerCreator registers the base class name and specified derived class name with t...
Register(const std::string &derived_name)
Creates a new Register instance. Upon creation, the DerivedClass::createInstance() instance creation ...
Class Writer implements a runtime selectable diagnostic output writer to aid in the development and d...
static UserSubroutine & instance()
Member function instance returns the instance of the registry, cast as a UserSubroutine registry...
std::vector< std::string > getDerivedNames(const std::type_info &type) const
Member function getDerivedNames returns names assocaited with the function pointers of the specified ...
Class hash_nocase implements a hash, case insensitive NamePair hash functor.
void * getFuncPtr(const NamePair &name_pair) const
Member function getFuncPtr returns the function pointer with the specfied <it>name_pair.
static Signature * getFunction(const std::string &function_name)
Member function execute returns the user function function pointer associated with the specified sign...
Class template Register registers the user function function pointer with the function_name on object...
static Signature * execute(const std::string &function_name)
Member function execute returns the user function function associated with the specified signature an...
Register(int derived_id, Signature create_instance)
Creates a new Register instance. Upon creation, the DerivedClass::createInstance() instance creation ...
Registry * getFactoryPtr(const NamePair &name) const
Member function getFuncPtr returns the function pointer with the specfied <it>name_pair.
std::map< NamePair, void *, less_nocase > RegistryMap
Typedef RegistryMap is the registration map.
static Registry & rootInstance()
Member function rootInstance creates the singleton.
void * getFunctionPtr(const NamePair &name_pair) const
Member function getFunctionPtr find the function with the name pair specified.