28 #ifndef DOXYGEN_SHOULD_SKIP_THIS 37 template <
typename GUM_SCALAR >
39 const std::string& operation_name,
40 const std::string& type1,
41 const std::string& type2,
46 if (!__set.exists(operation_name)) {
47 theset = __set.insert(operation_name,
new OperatorSet).second;
48 # ifdef GUM_DEBUG_MODE 52 __debug__::__inc_deletion(
53 "HashTable", __FILE__, __LINE__,
"destructor of", (
void*)theset);
56 theset = __set[operation_name];
59 std::pair< std::string, std::string > thepair(type1, type2);
61 theset->insert(thepair, newFunction);
65 template <
typename GUM_SCALAR >
67 const std::string& operation_name,
68 const std::string& type1,
69 const std::string& type2) {
70 if (!__set.exists(operation_name))
return;
72 OperatorSet* theset = __set[operation_name];
74 theset->erase(std::pair< std::string, std::string >(type1, type2));
78 template <
typename GUM_SCALAR >
80 const std::string& operation_name,
81 const std::string& type1,
82 const std::string& type2)
const {
83 if (!__set.exists(operation_name))
return false;
84 OperatorSet* theset = __set[operation_name];
85 return theset->exists(std::pair< std::string, std::string >(type1, type2));
90 template <
typename GUM_SCALAR >
93 const std::string& operation_name,
94 const std::string& type1,
95 const std::string& type2)
const {
96 OperatorSet* theset = __set[operation_name];
97 return (*theset)[std::pair< std::string, std::string >(type1, type2)];
102 template <
typename GUM_SCALAR >
103 OperatorRegister4MultiDim< GUM_SCALAR >&
105 static OperatorRegister4MultiDim< GUM_SCALAR >* container =
nullptr;
106 static bool first =
true;
110 container =
new OperatorRegister4MultiDim< GUM_SCALAR >;
112 # ifdef GUM_DEBUG_MODE 116 __debug__::__inc_deletion(
"HashTable",
120 (
void*)&container->__set);
129 template <
typename GUM_SCALAR >
133 template <
typename GUM_SCALAR >
138 iter != __set.endSafe();
144 template <
typename GUM_SCALAR >
146 const std::string& operation_name,
147 const std::string& type1,
148 const std::string& type2,
151 operation_name, type1, type2,
function);
A container for registering binary functions on multiDimImplementations.
gum is the global namespace for all aGrUM entities
void registerOperator(const std::string &operation_name, const std::string &type1, const std::string &type2, typename OperatorRegister4MultiDim< GUM_SCALAR >::OperatorPtr function)
A function to more easily register new operators in MultiDims.
HashTableIteratorSafe< Key, Val > iterator_safe
Types for STL compliance.
bool exists(const std::string &operation_name, const std::string &type1, const std::string &type2) const
Indicates whether a given entry exists in the register.
void erase(const std::string &operation_name, const std::string &type1, const std::string &type2)
removes a given entry from the register
void insert(const std::string &operation_name, const std::string &type1, const std::string &type2, OperatorPtr newFunction)
adds a new entry into the register
static OperatorRegister4MultiDim< GUM_SCALAR > & Register()
A named constructor that constructs one and only one Register per data type.
MultiDimImplementation< GUM_SCALAR > *(* OperatorPtr)(const MultiDimImplementation< GUM_SCALAR > *, const MultiDimImplementation< GUM_SCALAR > *)
The type of functions used by the register.
OperatorRegister4MultiDim()
Default constructor: creates an empty register.
OperatorPtr get(const std::string &operation_name, const std::string &type1, const std::string &type2) const
returns the specialized operator assigned to a given pair of MultiDimImplementations ...
~OperatorRegister4MultiDim()
Destructor.