aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
O3prmBNReader.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
51#ifndef GUM_PRM_O3PRM_BNREADER_H
52#define GUM_PRM_O3PRM_BNREADER_H
53
54#include <algorithm>
55#include <string>
56
59
60#include <string_view>
61
62namespace gum {
74 template < GUM_Numeric GUM_SCALAR >
75 class O3prmBNReader: public BNReader< GUM_SCALAR > {
76 public:
77 O3prmBNReader(BayesNet< GUM_SCALAR >* bn,
78 const std::string& filename,
79 const std::string& entityName = "",
80 const std::string& classPath = "");
81
82 ~O3prmBNReader() override;
83
87 Size proceed() override;
88
91
93 Size errors();
94
96 Size warnings();
97
98 Idx errLine(Idx i);
99
101 Idx errCol(Idx i);
102
104 bool errIsError(Idx i);
105
107 std::string errMsg(Idx i);
108
110 void showElegantErrors(std::ostream& o = std::cerr);
111
113 void showElegantErrorsAndWarnings(std::ostream& o = std::cerr);
114
116 void showErrorCounts(std::ostream& o = std::cerr);
117
119
120 private:
121 std::string _filename_;
122
123 std::string _classpath_;
124 std::string _entityName_;
125
126 BayesNet< GUM_SCALAR >* _bn_;
128
130 static std::string _getVariableName_(std::string_view path,
131 std::string_view type,
132 std::string_view name,
133 std::string_view toRemove = "");
134 static std::string _getEntityName_(std::string_view filename);
135 static std::string _getInstanceName_(std::string_view classname);
136 };
137
138} // namespace gum
139
140// always include the implementation of the templates
142
143
144#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
145extern template class gum::O3prmBNReader< double >;
146#endif
147
148
149#endif // GUM_PRM_O3PRM_BNREADER_H
Definition of abstract classes for file input manipulation of Bayesian networks.
Inline implementation of O3prmReader.
Headers for the O3prmReader class.
BNReader(BayesNet< GUM_SCALAR > *bn, std::string_view filename)
Constructor A reader is defined for reading a defined file.
This class is used contain and manipulate gum::ParseError.
Read an O3PRM and transform the gum::prm::PRMSystem into gum::BayesNet.
Size errors()
publishing Errors API
std::string _filename_
void showElegantErrorsAndWarnings(std::ostream &o=std::cerr)
send on std::cerr the list of errors or warnings
Size proceed() override
parse the file
static std::string _getInstanceName_(std::string_view classname)
static std::string _getVariableName_(std::string_view path, std::string_view type, std::string_view name, std::string_view toRemove="")
Idx errLine(Idx i)
publishing Errors API
std::string _entityName_
ErrorsContainer _errors_
O3prmBNReader(BayesNet< GUM_SCALAR > *bn, const std::string &filename, const std::string &entityName="", const std::string &classPath="")
void showElegantErrors(std::ostream &o=std::cerr)
send on std::cerr the list of errors
void showErrorCounts(std::ostream &o=std::cerr)
send on std::cerr the number of errors and the number of warnings
static std::string _getEntityName_(std::string_view filename)
bool errIsError(Idx i)
type of ith error or warning
void _generateBN_(prm::PRMSystem< GUM_SCALAR > &system)
std::string _classpath_
BayesNet< GUM_SCALAR > * _bn_
std::string errMsg(Idx i)
message of ith error or warning
Idx errCol(Idx i)
col of ith error or warning
A PRMSystem is a container of PRMInstance and describe a relational skeleton.
Definition PRMSystem.h:72
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74
Size Idx
Type for indexes.
Definition types.h:79
gum is the global namespace for all aGrUM entities
Definition agrum.h:46