aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
BIFReader.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
84
#ifndef GUM_BIF_READER_H
85
#define GUM_BIF_READER_H
86
87
#include <fstream>
88
#include <iostream>
89
#include <string>
90
91
#include <
agrum/BN/io/BNReader.h
>
92
93
#ifndef DOXYGEN_SHOULD_SKIP_THIS
94
// including coco-generated PARSER and SCANNER; GUM_COCOR_PUBLIC is locally
95
// forced to this module's own export macro so the grammar is tagged
96
// correctly even in a translation unit (e.g. gumTest) that does not define
97
// AGRUM_BN_EXPORTING.
98
# pragma push_macro("GUM_COCOR_PUBLIC")
99
# undef GUM_COCOR_PUBLIC
100
# define GUM_COCOR_PUBLIC GUM_PUBLIC_BN
101
# include <agrum/BN/io/BIF/cocoR/Parser.h>
102
# pragma pop_macro("GUM_COCOR_PUBLIC")
103
#endif
// DOXYGEN_SHOULD_SKIP_THIS
104
105
namespace
gum
{
149
template
< GUM_Numeric GUM_SCALAR >
150
class
BIFReader
final:
public
BNReader
< GUM_SCALAR > {
151
public
:
152
BIFReader
(BayesNet< GUM_SCALAR >* bn, std::string_view filename);
153
154
~BIFReader
()
override
;
155
158
BIF::Scanner&
scanner
();
159
161
const
std::string&
streamName
()
const
;
162
164
bool
trace
()
const
;
165
void
trace
(
bool
b);
166
170
Size
proceed
()
override
;
171
174
176
Size
errors
()
const
;
178
Size
warnings
()
const
;
179
181
Idx
errLine
(
Idx
i)
const
;
183
Idx
errCol
(
Idx
i)
const
;
185
bool
errIsError
(
Idx
i)
const
;
187
std::string
errMsg
(
Idx
i)
const
;
188
190
void
showElegantErrors
(std::ostream& o = std::cerr)
const
;
191
193
void
showElegantErrorsAndWarnings
(std::ostream& o = std::cerr)
const
;
194
196
void
showErrorCounts
(std::ostream& o = std::cerr)
const
;
198
199
private
:
200
BayesNet< GUM_SCALAR >*
_bn_
;
201
BayesNetFactory< GUM_SCALAR >
*
_factory_
;
202
BIF::Scanner*
_scanner_
;
203
BIF::Parser*
_parser_
;
204
205
std::string
_streamName_
;
206
bool
_traceScanning_
;
207
bool
_parseDone_
;
208
209
// a boolean to throw the ioerror not in the constructor but in the
210
// proceed()
211
bool
_ioerror_
;
212
};
213
214
215
#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
216
extern
template
class
GUM_PUBLIC_BN
BIFReader< double >
;
217
#endif
218
}
// namespace gum
219
220
#include <
agrum/BN/io/BIF/BIFReader_tpl.h
>
221
222
#endif
// GUM_BIF_READER_H
BIFReader_tpl.h
Definition of templatized reader of BIF files for Bayesian networks.
BNReader.h
Definition of abstract classes for file input manipulation of Bayesian networks.
gum::BIFReader::_traceScanning_
bool _traceScanning_
Definition
BIFReader.h:206
gum::BIFReader::_bn_
BayesNet< GUM_SCALAR > * _bn_
Definition
BIFReader.h:200
gum::BIFReader::errCol
Idx errCol(Idx i) const
col of ith error or warning
gum::BIFReader::warnings
Size warnings() const
gum::BIFReader::_parser_
BIF::Parser * _parser_
Definition
BIFReader.h:203
gum::BIFReader::errors
Size errors() const
publishing Errors API
gum::BIFReader::_scanner_
BIF::Scanner * _scanner_
Definition
BIFReader.h:202
gum::BIFReader::showErrorCounts
void showErrorCounts(std::ostream &o=std::cerr) const
send on std::cerr the number of errors and the number of warnings
gum::BIFReader::scanner
BIF::Scanner & scanner()
Direct access to BIF scanner (mandatory for listener connection).
gum::BIFReader::BIFReader
BIFReader(BayesNet< GUM_SCALAR > *bn, std::string_view filename)
gum::BIFReader::_ioerror_
bool _ioerror_
Definition
BIFReader.h:211
gum::BIFReader::_factory_
BayesNetFactory< GUM_SCALAR > * _factory_
Definition
BIFReader.h:201
gum::BIFReader::errLine
Idx errLine(Idx i) const
line of ith error or warning
gum::BIFReader::showElegantErrors
void showElegantErrors(std::ostream &o=std::cerr) const
send on std::cerr the list of errors
gum::BIFReader::errMsg
std::string errMsg(Idx i) const
message of ith error or warning
gum::BIFReader::showElegantErrorsAndWarnings
void showElegantErrorsAndWarnings(std::ostream &o=std::cerr) const
send on std::cerr the list of errors or warnings
gum::BIFReader::_streamName_
std::string _streamName_
Definition
BIFReader.h:205
gum::BIFReader::~BIFReader
~BIFReader() override
gum::BIFReader::streamName
const std::string & streamName() const
name of read file
gum::BIFReader::proceed
Size proceed() override
parse.
gum::BIFReader::errIsError
bool errIsError(Idx i) const
type of ith error or warning
gum::BIFReader::trace
void trace(bool b)
gum::BIFReader::trace
bool trace() const
accessor to trace function (just write the number of parser line)
gum::BIFReader::_parseDone_
bool _parseDone_
Definition
BIFReader.h:207
gum::BNReader::BNReader
BNReader(BayesNet< GUM_SCALAR > *bn, std::string_view filename)
Constructor A reader is defined for reading a defined file.
gum::BayesNetFactory
A factory class to ease BayesNet construction.
Definition
BayesNetFactory.h:83
gum::Size
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition
types.h:74
gum::Idx
Size Idx
Type for indexes.
Definition
types.h:79
gum
gum is the global namespace for all aGrUM entities
Definition
agrum.h:46
gum::BIFReader< double >
template class GUM_PUBLIC_BN BIFReader< double >
Definition
BIFReader.cpp:46
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0