31 #ifndef DOXYGEN_SHOULD_SKIP_THIS 40 template <
typename GUM_SCALAR >
42 const std::string& operation_name,
43 const std::string& type1,
44 const std::string& type2,
49 if (!__set.exists(operation_name)) {
50 theset = __set.insert(operation_name,
new OperatorSet).second;
51 # ifdef GUM_DEBUG_MODE 55 __debug__::__inc_deletion(
56 "HashTable", __FILE__, __LINE__,
"destructor of", (
void*)theset);
59 theset = __set[operation_name];
62 std::pair< std::string, std::string > thepair(type1, type2);
64 theset->insert(thepair, newFunction);
68 template <
typename GUM_SCALAR >
70 const std::string& operation_name,
71 const std::string& type1,
72 const std::string& type2) {
73 if (!__set.exists(operation_name))
return;
75 OperatorSet* theset = __set[operation_name];
77 theset->erase(std::pair< std::string, std::string >(type1, type2));
81 template <
typename GUM_SCALAR >
83 const std::string& operation_name,
84 const std::string& type1,
85 const std::string& type2)
const {
86 if (!__set.exists(operation_name))
return false;
87 OperatorSet* theset = __set[operation_name];
88 return theset->exists(std::pair< std::string, std::string >(type1, type2));
93 template <
typename GUM_SCALAR >
96 const std::string& operation_name,
97 const std::string& type1,
98 const std::string& type2)
const {
99 OperatorSet* theset = __set[operation_name];
100 return (*theset)[std::pair< std::string, std::string >(type1, type2)];
105 template <
typename GUM_SCALAR >
106 OperatorRegister4MultiDim< GUM_SCALAR >&
108 static OperatorRegister4MultiDim< GUM_SCALAR >* container =
nullptr;
109 static bool first =
true;
113 container =
new OperatorRegister4MultiDim< GUM_SCALAR >;
115 # ifdef GUM_DEBUG_MODE 119 __debug__::__inc_deletion(
"HashTable",
123 (
void*)&container->__set);
132 template <
typename GUM_SCALAR >
136 template <
typename GUM_SCALAR >
141 iter != __set.endSafe();
147 template <
typename GUM_SCALAR >
149 const std::string& operation_name,
150 const std::string& type1,
151 const std::string& type2,
154 operation_name, type1, type2,
function);
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.