aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
DBTranslatorUtils.cpp
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
47
49
50#ifndef DOXYGEN_SHOULD_SKIP_THIS
51
53# ifdef GUM_NO_INLINE
55# endif /* GUM_NO_INLINE */
56
57namespace gum {
58
59 namespace learning {
60
61 namespace DBTranslators {
62
64 DBTranslator* create(const Variable& var,
65 const std::vector< std::string >& missing_symbols,
66 const bool editable_dictionary,
67 std::size_t max_dico_entries) {
68 switch (var.varType()) {
69 case VarType::LABELIZED : {
70 const LabelizedVariable& xvar = static_cast< const LabelizedVariable& >(var);
71 return new DBTranslator4LabelizedVariable(xvar,
72 missing_symbols,
73 editable_dictionary,
74 max_dico_entries);
75 }
76
77 case VarType::INTEGER : {
78 const auto& xvar = static_cast< const IntegerVariable& >(var);
79
80 return new DBTranslator4IntegerVariable(xvar, missing_symbols, max_dico_entries);
81 }
82
84 const auto& xvar = static_cast< const IDiscretizedVariable& >(var);
85 return new DBTranslator4DiscretizedVariable(xvar, missing_symbols, max_dico_entries);
86 }
87
88 case VarType::RANGE : {
89 const auto& xvar = static_cast< const RangeVariable& >(var);
90 return new DBTranslator4RangeVariable(xvar,
91 missing_symbols,
92 editable_dictionary,
93 max_dico_entries);
94 }
95
96 case VarType::CONTINUOUS : {
97 const auto& xvar = static_cast< const IContinuousVariable& >(var);
98 return new DBTranslator4ContinuousVariable(xvar, missing_symbols, editable_dictionary);
99 }
100
101 case VarType::NUMERICAL : {
102 const auto& xvar = static_cast< const NumericalDiscreteVariable& >(var);
103 return new DBTranslator4NumericalDiscreteVariable(xvar,
104 missing_symbols,
105 max_dico_entries);
106 }
107 }
108
109 GUM_ERROR(NotImplementedYet,
110 "The translator for Variable "
111 << var.name()
112 << " cannot yet be created yet by named constructor CreatePtr.");
113 }
114
115 } /* namespace DBTranslators */
116
117 } /* namespace learning */
118
119} /* namespace gum */
120
121#endif /* DOXYGEN_SHOULD_SKIP_THIS */
Utilities for DBTranslators.
Utilities for DBTranslators.
#define GUM_ERROR(type, msg)
Definition exceptions.h:72
DBTranslator * create(const Variable &var, const bool editable_dictionary=false, std::size_t max_dico_entries=std::numeric_limits< std::size_t >::max())
named constructor
include the inlined functions if necessary
Definition CSVParser.h:54
gum is the global namespace for all aGrUM entities
Definition agrum.h:46