aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
operatorRegister4MultiDim.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2025 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
49
50#ifndef GUM_OPERATOR_REGISTER_4_MULTI_DIM_H
51#define GUM_OPERATOR_REGISTER_4_MULTI_DIM_H
52
53#include <atomic>
54#include <iostream>
55#include <string>
56#include <utility>
57
59
60namespace gum {
61
62 // the base object used by combinations
63 template < typename GUM_SCALAR >
65
66 // ===========================================================================
67 // === GUM_MULTI_DIM_OPERATOR_REGISTER ===
68 // ===========================================================================
69 // clang-format off
78 // clang-format on
79
80 template < typename GUM_SCALAR >
82 public:
87
88 // ========================================================================
90 // ========================================================================
92
118 void insert(const std::string& operation_name,
119 const std::string& type1,
120 const std::string& type2,
121 OperatorPtr newFunction);
122
140 void erase(const std::string& operation_name,
141 const std::string& type1,
142 const std::string& type2);
143
161 bool exists(const std::string& operation_name,
162 const std::string& type1,
163 const std::string& type2) const;
164
186 OperatorPtr get(const std::string& operation_name,
187 const std::string& type1,
188 const std::string& type2) const;
189
191 // ========================================================================
193 // ========================================================================
195
203
205
206 private:
207 // ========================================================================
209 // ========================================================================
211
214
217
220
222
225
236 };
237
239 template < typename GUM_SCALAR >
240 void registerOperator(const std::string& operation_name,
241 const std::string& type1,
242 const std::string& type2,
244
245} /* namespace gum */
246
247// always include the implementations
249
250#endif /* GUM_OPERATOR_REGISTER_MULTI_DIM_H */
The class for generic Hash Tables.
Definition hashTable.h:637
<agrum/base/multidim/multiDimImplementation.h>
~OperatorRegister4MultiDim()
Destructor.
void insert(const std::string &operation_name, const std::string &type1, const std::string &type2, OperatorPtr newFunction)
adds a new entry into the register
MultiDimImplementation< GUM_SCALAR > *(*)(const MultiDimImplementation< GUM_SCALAR > *, const MultiDimImplementation< GUM_SCALAR > *) OperatorPtr
The type of functions used by the register.
void erase(const std::string &operation_name, const std::string &type1, const std::string &type2)
removes a given entry from 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
HashTable< std::pair< std::string, std::string >, OperatorPtr > OperatorSet
The set of associations for a given operation type.
static OperatorRegister4MultiDim< GUM_SCALAR > & Register()
A named constructor that constructs one and only one Register per data type.
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.
HashTable< std::string, OperatorSet * > _set_
A mapping from pairs of types of MultiDimImplementations to operators.
Class hash tables iterators.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
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.