aGrUM  0.14.2
operatorRegister4MultiDim.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
28 #ifndef GUM_OPERATOR_REGISTER_4_MULTI_DIM_H
29 #define GUM_OPERATOR_REGISTER_4_MULTI_DIM_H
30 
31 #include <agrum/core/hashTable.h>
32 #include <iostream>
33 #include <string>
34 #include <utility>
35 
36 namespace gum {
37 
38  // the base object used by combinations
39  template < typename GUM_SCALAR >
40  class MultiDimImplementation;
41 
42  // ===========================================================================
43  // === GUM_MULTI_DIM_OPERATOR_REGISTER ===
44  // ===========================================================================
45  // clang-format off
54  // clang-format on
55  template < typename GUM_SCALAR >
57  public:
59  typedef MultiDimImplementation< GUM_SCALAR >* (*OperatorPtr)(
61  const MultiDimImplementation< GUM_SCALAR >*);
62 
63  // ========================================================================
65  // ========================================================================
67 
93  void insert(const std::string& operation_name,
94  const std::string& type1,
95  const std::string& type2,
96  OperatorPtr newFunction);
97 
115  void erase(const std::string& operation_name,
116  const std::string& type1,
117  const std::string& type2);
118 
136  bool exists(const std::string& operation_name,
137  const std::string& type1,
138  const std::string& type2) const;
139 
161  OperatorPtr get(const std::string& operation_name,
162  const std::string& type1,
163  const std::string& type2) const;
164 
166  // ========================================================================
168  // ========================================================================
170 
178 
180 
181  private:
182  // ========================================================================
184  // ========================================================================
186 
189 
192 
195 
197 
201 
212  };
213 
215  template < typename GUM_SCALAR >
216  void registerOperator(
217  const std::string& operation_name,
218  const std::string& type1,
219  const std::string& type2,
221 
222 } /* namespace gum */
223 
224 // always include the implementations
226 
227 #endif /* GUM_OPERATOR_REGISTER_MULTI_DIM_H */
HashTable< std::pair< std::string, std::string >, OperatorPtr > OperatorSet
The set of associations for a given operation type.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
The class for generic Hash Tables.
Definition: hashTable.h:676
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.
A container for registering binary functions on multiDimImplementations.
HashTable< std::string, OperatorSet *> __set
A mapping from pairs of types of MultiDimImplementations to operators.
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.
A container for registering binary functions on multiDimImplementations.
OperatorRegister4MultiDim()
Default constructor: creates an empty register.
<agrum/multidim/multiDimImplementation.h>
Class hash tables iterators.
~OperatorRegister4MultiDim()
Destructor.