aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
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// ======================================================================================================
91// ======================================================================================================
92// ======================================================================================================
93
94#ifndef DOXYGEN_SHOULD_SKIP_THIS
95// including coco-generated PARSER and SCANNER
96# include <agrum/FMDP/io/dat/cocoR/Parser.h>
97#endif // DOXYGEN_SHOULD_SKIP_THIS
98
99namespace gum {
107 template < typename GUM_ELEMENT >
108 class FMDPDatReader: public FMDPReader< GUM_ELEMENT > {
109 public:
110 FMDPDatReader(FMDP< GUM_ELEMENT >* fmdp, std::string_view filename);
111 ~FMDPDatReader() override;
112
115 MDPDAT::Scanner& scanner();
116
118 const std::string& streamName() const;
119
121 bool trace() const;
122 void trace(bool b);
123
127 Size proceed() override;
128
131
136
144 std::string errMsg(Idx i);
145
147 void showElegantErrors(std::ostream& o = std::cerr);
148
150 void showElegantErrorsAndWarnings(std::ostream& o = std::cerr);
151
153 void showErrorCounts(std::ostream& o = std::cerr);
155
156 protected:
159 MDPDAT::Scanner* _scanner_;
160 MDPDAT::Parser* _parser_;
161
162 std::string _streamName_;
165
166 // a boolean to throw the ioerror not in the constructor but in the
167 // proceed()
169 };
170
171
172#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
173 extern template class FMDPDatReader< double >;
174#endif
175
176} // namespace gum
177
179
180#endif // GUM_FMDP_DAT_READER_H
Definition of templatized reader of FMDPDat files for Factored Markov Decision Processes.
MDPDAT::Parser * _parser_
MDPDAT::Scanner * _scanner_
std::string _streamName_
FMDP< GUM_ELEMENT > * _fmdp_
bool trace() const
accessor to trace function (just write the number of parser line)
FMDPFactory< GUM_ELEMENT > * _factory_
void showErrorCounts(std::ostream &o=std::cerr)
send on std::cerr the number of errors and the number of warnings
Size proceed() override
parse.
void trace(bool b)
void showElegantErrorsAndWarnings(std::ostream &o=std::cerr)
send on std::cerr the list of errors or warnings
~FMDPDatReader() override
FMDPDatReader(FMDP< GUM_ELEMENT > *fmdp, std::string_view filename)
Size errors()
publishing Errors API
const std::string & streamName() const
name of readen file
MDPDAT::Scanner & scanner()
Direct access to FMDPDat scanner (mandatory for listener connection).
void showElegantErrors(std::ostream &o=std::cerr)
send on std::cerr the list of errors
Idx errCol(Idx i)
col of ith error or warning
bool errIsError(Idx i)
type of ith error or warning
std::string errMsg(Idx i)
message of ith error or warning
Idx errLine(Idx i)
line of ith error or warning
A factory class to ease Factored Markov Decision Process construction.
Definition fmdpFactory.h:89
FMDPReader(FMDP< GUM_ELEMENT > *fmdp, std::string_view filename)
Constructor A reader is defined for reading a defined file.
This class is used to implement factored decision process.
Definition fmdp.h:75
Definition of templatized reader of dat files for Factored Markov Decision Process.
Headers of the FMDPFactory class.
Definition of abstract classes for file input manipulation of Factored Markov Decision Process.
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