aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
projectionRegister4MultiDim.h
Go to the documentation of this file.
1
/****************************************************************************
2
* This file is part of the aGrUM/pyAgrum library. *
3
* *
4
* Copyright (c) 2005-2026 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-2026 *
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_PROJECTION_REGISTER_4_MULTI_DIM_H
51
#define GUM_PROJECTION_REGISTER_4_MULTI_DIM_H
52
53
#include <atomic>
54
#include <iostream>
55
#include <string>
56
#include <utility>
57
58
#include <
agrum/base/variables/discreteVariable.h
>
59
60
#include <string_view>
61
62
namespace
gum
{
63
64
// the base object used by the projections
65
template
<
typename
GUM_ELEMENT >
66
class
MultiDimImplementation
;
67
68
// ===========================================================================
69
// === GUM_MULTI_DIM_PROJECTION_REGISTER ===
70
// ===========================================================================
71
// clang-format off
81
// clang-format on
82
83
template
<
typename
GUM_ELEMENT >
84
class
ProjectionRegister4MultiDim
{
85
public
:
87
using
ProjectionPtr
88
=
MultiDimImplementation< GUM_ELEMENT >
* (*)(
const
MultiDimImplementation< GUM_ELEMENT >
*,
89
const
gum::VariableSet
&);
90
91
// ========================================================================
93
// ========================================================================
95
119
void
insert
(std::string_view projection_name,
120
std::string_view type_multidim,
121
ProjectionPtr
newFunction);
122
137
void
erase
(std::string_view projection_name, std::string_view type_multidim);
138
153
bool
exists
(std::string_view projection_name, std::string_view type_multidim)
const
;
154
173
ProjectionPtr
get
(std::string_view projection_name, std::string_view type_multidim)
const
;
174
176
// ========================================================================
178
// ========================================================================
180
187
static
ProjectionRegister4MultiDim
&
Register
();
188
190
191
private
:
192
// ========================================================================
194
// ========================================================================
196
198
ProjectionRegister4MultiDim
();
199
201
ProjectionRegister4MultiDim
(
const
ProjectionRegister4MultiDim
&);
202
204
~ProjectionRegister4MultiDim
();
205
207
209
using
ProjectionSet
=
HashTable< std::string, ProjectionPtr >
;
210
220
HashTable< std::string, ProjectionSet* >
_set_
;
221
};
222
224
template
<
typename
GUM_ELEMENT >
225
void
registerProjection
(
226
std::string_view projection_name,
227
std::string_view type_multidim,
228
typename
ProjectionRegister4MultiDim< GUM_ELEMENT >::ProjectionPtr
function);
229
230
// a display operator for ProjectionPtrs
231
232
}
/* namespace gum */
233
234
// always include the implementations
235
#include <
agrum/base/multidim/utils/operators/projectionRegister4MultiDim_tpl.h
>
236
237
#endif
/* GUM_PROJECTION_REGISTER_MULTI_DIM_H */
gum::HashTable< std::string, ProjectionPtr >
gum::MultiDimImplementation
<agrum/base/multidim/multiDimImplementation.h>
Definition
multiDimImplementation.h:85
gum::ProjectionRegister4MultiDim::get
ProjectionPtr get(std::string_view projection_name, std::string_view type_multidim) const
returns the specialized projection operator assigned to a given type of MultiDimImplementation
gum::ProjectionRegister4MultiDim::ProjectionRegister4MultiDim
ProjectionRegister4MultiDim()
Default constructor: creates an empty register.
gum::ProjectionRegister4MultiDim::ProjectionSet
HashTable< std::string, ProjectionPtr > ProjectionSet
The set of associations for a given projection type.
Definition
projectionRegister4MultiDim.h:208
gum::ProjectionRegister4MultiDim::insert
void insert(std::string_view projection_name, std::string_view type_multidim, ProjectionPtr newFunction)
adds a new entry into the register
gum::ProjectionRegister4MultiDim::erase
void erase(std::string_view projection_name, std::string_view type_multidim)
removes a given entry from the register
gum::ProjectionRegister4MultiDim::Register
static ProjectionRegister4MultiDim & Register()
a named constructor that constructs one and only one Register per data type
gum::ProjectionRegister4MultiDim::ProjectionPtr
MultiDimImplementation< GUM_ELEMENT > *(*)(const MultiDimImplementation< GUM_ELEMENT > *, const gum::VariableSet &) ProjectionPtr
the type of functions used by the register
Definition
projectionRegister4MultiDim.h:87
gum::ProjectionRegister4MultiDim::_set_
HashTable< std::string, ProjectionSet * > _set_
A mapping from the types of MultiDimImplementations to projection operators.
Definition
projectionRegister4MultiDim.h:219
gum::ProjectionRegister4MultiDim::exists
bool exists(std::string_view projection_name, std::string_view type_multidim) const
indicates whether a given entry exists in the register
discreteVariable.h
Base class for discrete random variable.
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
gum::VariableSet
Set< const DiscreteVariable * > VariableSet
Definition
discreteVariable.h:192
gum::registerProjection
void registerProjection(std::string_view projection_name, std::string_view type_multidim, typename ProjectionRegister4MultiDim< GUM_ELEMENT >::ProjectionPtr function)
A function to more easily register new projection functions in MultiDims.
projectionRegister4MultiDim_tpl.h
A container for registering projection functions on multiDimImplementations.
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0