aGrUM
3.2.0
a C++ library for (probabilistic) graphical models
Toggle main menu visibility
fmdpDatReader.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
80
81
// ======================================================================================================
82
#ifndef GUM_FMDP_DAT_READER_H
83
#define GUM_FMDP_DAT_READER_H
84
// ======================================================================================================
85
#include <fstream>
86
#include <iostream>
87
#include <string>
88
// ======================================================================================================
89
#include <
agrum/FMDP/fmdpFactory.h
>
90
#include <
agrum/FMDP/io/fmdpReader.h
>
91
// ======================================================================================================
92
// ======================================================================================================
93
94
#ifndef DOXYGEN_SHOULD_SKIP_THIS
95
// including coco-generated PARSER and SCANNER; GUM_COCOR_PUBLIC is locally
96
// forced to this module's own export macro so the grammar is tagged
97
// correctly even in a translation unit (e.g. gumTest) that does not define
98
// AGRUM_FMDP_EXPORTING.
99
# pragma push_macro("GUM_COCOR_PUBLIC")
100
# undef GUM_COCOR_PUBLIC
101
# define GUM_COCOR_PUBLIC GUM_PUBLIC_FMDP
102
# include <agrum/FMDP/io/dat/cocoR/Parser.h>
103
# pragma pop_macro("GUM_COCOR_PUBLIC")
104
#endif
// DOXYGEN_SHOULD_SKIP_THIS
105
106
namespace
gum
{
114
template
<
typename
GUM_ELEMENT >
115
class
FMDPDatReader
:
public
FMDPReader
< GUM_ELEMENT > {
116
public
:
117
FMDPDatReader
(
FMDP< GUM_ELEMENT >
* fmdp, std::string_view filename);
118
~FMDPDatReader
()
override
;
119
122
MDPDAT::Scanner&
scanner
();
123
125
const
std::string&
streamName
()
const
;
126
128
bool
trace
()
const
;
129
void
trace
(
bool
b);
130
134
Size
proceed
()
override
;
135
138
140
Size
errors
();
142
Size
warnings
();
143
145
Idx
errLine
(
Idx
i);
147
Idx
errCol
(
Idx
i);
149
bool
errIsError
(
Idx
i);
151
std::string
errMsg
(
Idx
i);
152
154
void
showElegantErrors
(std::ostream& o = std::cerr);
155
157
void
showElegantErrorsAndWarnings
(std::ostream& o = std::cerr);
158
160
void
showErrorCounts
(std::ostream& o = std::cerr);
162
163
protected
:
164
FMDP< GUM_ELEMENT >
*
_fmdp_
;
165
FMDPFactory< GUM_ELEMENT >
*
_factory_
;
166
MDPDAT::Scanner*
_scanner_
;
167
MDPDAT::Parser*
_parser_
;
168
169
std::string
_streamName_
;
170
bool
_traceScanning_
;
171
bool
_parseDone_
;
172
173
// a boolean to throw the ioerror not in the constructor but in the
174
// proceed()
175
bool
_ioerror_
;
176
};
177
178
179
#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
180
extern
template
class
FMDPDatReader< double >
;
181
#endif
182
183
}
// namespace gum
184
185
#include <
agrum/FMDP/io/dat/fmdpDatReader_tpl.h
>
186
187
#endif
// GUM_FMDP_DAT_READER_H
gum::FMDPDatReader
Definition of templatized reader of FMDPDat files for Factored Markov Decision Processes.
Definition
fmdpDatReader.h:115
gum::FMDPDatReader::_parser_
MDPDAT::Parser * _parser_
Definition
fmdpDatReader.h:167
gum::FMDPDatReader::_scanner_
MDPDAT::Scanner * _scanner_
Definition
fmdpDatReader.h:166
gum::FMDPDatReader::_streamName_
std::string _streamName_
Definition
fmdpDatReader.h:169
gum::FMDPDatReader::_fmdp_
FMDP< GUM_ELEMENT > * _fmdp_
Definition
fmdpDatReader.h:164
gum::FMDPDatReader::trace
bool trace() const
accessor to trace function (just write the number of parser line)
gum::FMDPDatReader::warnings
Size warnings()
gum::FMDPDatReader::_factory_
FMDPFactory< GUM_ELEMENT > * _factory_
Definition
fmdpDatReader.h:165
gum::FMDPDatReader::showErrorCounts
void showErrorCounts(std::ostream &o=std::cerr)
send on std::cerr the number of errors and the number of warnings
gum::FMDPDatReader::proceed
Size proceed() override
parse.
gum::FMDPDatReader::trace
void trace(bool b)
gum::FMDPDatReader::showElegantErrorsAndWarnings
void showElegantErrorsAndWarnings(std::ostream &o=std::cerr)
send on std::cerr the list of errors or warnings
gum::FMDPDatReader::~FMDPDatReader
~FMDPDatReader() override
gum::FMDPDatReader::FMDPDatReader
FMDPDatReader(FMDP< GUM_ELEMENT > *fmdp, std::string_view filename)
gum::FMDPDatReader::errors
Size errors()
publishing Errors API
gum::FMDPDatReader::streamName
const std::string & streamName() const
name of readen file
gum::FMDPDatReader::scanner
MDPDAT::Scanner & scanner()
Direct access to FMDPDat scanner (mandatory for listener connection).
gum::FMDPDatReader::showElegantErrors
void showElegantErrors(std::ostream &o=std::cerr)
send on std::cerr the list of errors
gum::FMDPDatReader::_ioerror_
bool _ioerror_
Definition
fmdpDatReader.h:175
gum::FMDPDatReader::errCol
Idx errCol(Idx i)
col of ith error or warning
gum::FMDPDatReader::_traceScanning_
bool _traceScanning_
Definition
fmdpDatReader.h:170
gum::FMDPDatReader::errIsError
bool errIsError(Idx i)
type of ith error or warning
gum::FMDPDatReader::_parseDone_
bool _parseDone_
Definition
fmdpDatReader.h:171
gum::FMDPDatReader::errMsg
std::string errMsg(Idx i)
message of ith error or warning
gum::FMDPDatReader::errLine
Idx errLine(Idx i)
line of ith error or warning
gum::FMDPFactory
A factory class to ease Factored Markov Decision Process construction.
Definition
fmdpFactory.h:89
gum::FMDPReader::FMDPReader
FMDPReader(FMDP< GUM_ELEMENT > *fmdp, std::string_view filename)
Constructor A reader is defined for reading a defined file.
gum::FMDP
This class is used to implement factored decision process.
Definition
fmdp.h:75
fmdpDatReader_tpl.h
Definition of templatized reader of dat files for Factored Markov Decision Process.
fmdpFactory.h
Headers of the FMDPFactory class.
fmdpReader.h
Definition of abstract classes for file input manipulation of Factored Markov Decision Process.
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
aGrUM
3.2.0
© PHW&CG&others - 2022
DoXyGeN 1.18.0