aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
netReader.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
42
#ifndef GUM_NET_READER_H
43
#define GUM_NET_READER_H
44
45
#include <iostream>
46
#include <string>
47
48
#include <
agrum/agrum.h
>
49
50
#include <
agrum/BN/io/BNReader.h
>
51
52
#ifndef DOXYGEN_SHOULD_SKIP_THIS
53
// including coco-generated PARSER and SCANNER; GUM_COCOR_PUBLIC is locally
54
// forced to this module's own export macro so the grammar is tagged
55
// correctly even in a translation unit (e.g. gumTest) that does not define
56
// AGRUM_BN_EXPORTING.
57
# undef _COCO_PARSER_H_
58
# undef _COCO_SCANNER_H_
59
# pragma push_macro("GUM_COCOR_PUBLIC")
60
# undef GUM_COCOR_PUBLIC
61
# define GUM_COCOR_PUBLIC GUM_PUBLIC_BN
62
# include <agrum/BN/io/net/cocoR/Parser.h>
63
# pragma pop_macro("GUM_COCOR_PUBLIC")
64
#endif
// DOXYGEN_SHOULD_SKIP_THIS
65
66
namespace
gum
{
67
/* =========================================================================*/
68
/* === READERS === */
69
/* =========================================================================*/
79
template
< GUM_Numeric GUM_SCALAR >
80
class
NetReader
:
public
BNReader
< GUM_SCALAR > {
81
public
:
91
NetReader
(BayesNet< GUM_SCALAR >* bn, std::string_view filename);
92
96
~NetReader
()
override
;
97
100
net::Scanner&
scanner
();
101
103
const
std::string&
streamName
()
const
;
104
106
bool
trace
()
const
;
107
void
trace
(
bool
b);
108
112
Size
proceed
() final;
113
116
118
Size
errors
();
120
Size
warnings
();
121
123
Idx
errLine
(
Idx
i);
125
Idx
errCol
(
Idx
i);
127
bool
errIsError
(
Idx
i);
129
std
::
string
errMsg
(
Idx
i);
130
132
void
showElegantErrors
(
std
::ostream& o =
std
::cerr);
133
135
void
showElegantErrorsAndWarnings
(
std
::ostream& o =
std
::cerr);
136
138
void
showErrorsAndWarnings
(
std
::ostream& o =
std
::cerr);
139
141
void
showErrorCounts
(
std
::ostream& o =
std
::cerr);
143
144
protected:
145
BayesNet
< GUM_SCALAR >*
_bn_
;
146
BayesNetFactory
< GUM_SCALAR >*
_factory_
;
147
net::Scanner*
_scanner_
;
148
net::Parser*
_parser_
;
149
150
std
::
string
_streamName_
;
151
bool
_traceScanning_
;
152
bool
_parseDone_
;
153
154
// a boolean to throw the ioerror not in the constructor but in the
155
// proceed()
156
bool
_ioerror_
;
157
};
158
159
160
#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
161
extern
template
class
GUM_PUBLIC_BN
NetReader< double >
;
162
#endif
163
164
}
/* namespace gum */
165
166
#include "
netReader_tpl.h
"
167
168
#endif
// GUM_NET_READER_H
BNReader.h
Definition of abstract classes for file input manipulation of Bayesian networks.
agrum.h
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::BayesNet
Class representing a Bayesian network.
Definition
BayesNet.h:99
gum::NetReader::streamName
const std::string & streamName() const
name of readen file
gum::NetReader::_parser_
net::Parser * _parser_
Definition
netReader.h:148
gum::NetReader::trace
bool trace() const
accessor to trace function (just write the number of parser line)
gum::NetReader::_parseDone_
bool _parseDone_
Definition
netReader.h:152
gum::NetReader::errIsError
bool errIsError(Idx i)
type of ith error or warning
gum::NetReader::_ioerror_
bool _ioerror_
Definition
netReader.h:156
gum::NetReader::errors
Size errors()
publishing Errors API
gum::NetReader::_scanner_
net::Scanner * _scanner_
Definition
netReader.h:147
gum::NetReader::_streamName_
std::string _streamName_
Definition
netReader.h:150
gum::NetReader::proceed
Size proceed() final
parse.
gum::NetReader::trace
void trace(bool b)
gum::NetReader::errLine
Idx errLine(Idx i)
line of ith error or warning
gum::NetReader::showErrorCounts
void showErrorCounts(std::ostream &o=std::cerr)
send on std::cerr the number of errors and the number of warnings
gum::NetReader::errMsg
std::string errMsg(Idx i)
message of ith error or warning
gum::NetReader::showErrorsAndWarnings
void showErrorsAndWarnings(std::ostream &o=std::cerr)
send on std::cerr the list of errors or warnings
gum::NetReader::errCol
Idx errCol(Idx i)
col of ith error or warning
gum::NetReader::~NetReader
~NetReader() override
Default destructor.
gum::NetReader::warnings
Size warnings()
gum::NetReader::showElegantErrorsAndWarnings
void showElegantErrorsAndWarnings(std::ostream &o=std::cerr)
send on std::cerr the list of errors or warnings with contents
gum::NetReader::showElegantErrors
void showElegantErrors(std::ostream &o=std::cerr)
send on std::cerr the list of errorswith contents
gum::NetReader::_traceScanning_
bool _traceScanning_
Definition
netReader.h:151
gum::NetReader::_factory_
BayesNetFactory< GUM_SCALAR > * _factory_
Definition
netReader.h:146
gum::NetReader::scanner
net::Scanner & scanner()
Direct access to DSL scanner (mandatory for listener connection).
gum::NetReader::NetReader
NetReader(BayesNet< GUM_SCALAR > *bn, std::string_view filename)
Constructor A reader is defined for reading a defined file.
gum::NetReader::_bn_
BayesNet< GUM_SCALAR > * _bn_
Definition
netReader.h:145
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::NetReader< double >
template class GUM_PUBLIC_BN NetReader< double >
Definition
netReader.cpp:46
std
STL namespace.
netReader_tpl.h
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0