aGrUM 2.3.2
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-2025 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-2025 *
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
85// ======================================================================================================
86#ifndef FMDP_DAT_READER_H
87#define FMDP_DAT_READER_H
88// ======================================================================================================
89#include <fstream>
90#include <iostream>
91#include <string>
92// ======================================================================================================
95// ======================================================================================================
96// ======================================================================================================
97
98#ifndef DOXYGEN_SHOULD_SKIP_THIS
99// including coco-generated PARSER and SCANNER
100# include <agrum/FMDP/io/dat/cocoR/Parser.h>
101#endif // DOXYGEN_SHOULD_SKIP_THIS
102
103namespace gum {
111 template < typename GUM_SCALAR >
112 class FMDPDatReader: public FMDPReader< GUM_SCALAR > {
113 public:
114 FMDPDatReader(FMDP< GUM_SCALAR >* fmdp, const std::string& filename);
116
119 MDPDAT::Scanner& scanner();
120
122 const std::string& streamName() const;
123
125 bool trace() const;
126 void trace(bool b);
127
132
135
140
148 std::string errMsg(Idx i);
149
151 void showElegantErrors(std::ostream& o = std::cerr);
152
154 void showElegantErrorsAndWarnings(std::ostream& o = std::cerr);
155
157 void showErrorCounts(std::ostream& o = std::cerr);
159
160 protected:
163 MDPDAT::Scanner* _scanner_;
164 MDPDAT::Parser* _parser_;
165
166 std::string _streamName_;
169
170 // a boolean to throw the ioerror not in the constructor but in the
171 // proceed()
173 };
174
175
176#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
177 extern template class FMDPDatReader< double >;
178#endif
179
180} // namespace gum
181
183
184#endif // FMDP_DAT_READER_H
Definition of templatized reader of FMDPDat files for Factored Markov Decision Processes.
std::string errMsg(Idx i)
message of ith error or warning
MDPDAT::Scanner & scanner()
Direct access to FMDPDat scanner (mandatory for listener connection).
bool trace() const
accessor to trace function (just write the number of parser line)
FMDP< GUM_SCALAR > * _fmdp_
Idx errCol(Idx i)
col of ith error or warning
Size errors()
publishing Errors API
FMDPDatReader(FMDP< GUM_SCALAR > *fmdp, const std::string &filename)
MDPDAT::Scanner * _scanner_
Size proceed()
parse.
Idx errLine(Idx i)
line of ith error or warning
void showElegantErrorsAndWarnings(std::ostream &o=std::cerr)
send on std::cerr the list of errors or warnings
std::string _streamName_
MDPDAT::Parser * _parser_
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
void trace(bool b)
FMDPFactory< GUM_SCALAR > * _factory_
const std::string & streamName() const
name of readen file
bool errIsError(Idx i)
type of ith error or warning
A factory class to ease Factored Markov Decision Process construction.
Definition fmdpFactory.h:87
FMDPReader(FMDP< GUM_SCALAR > *fmdp, const std::string &filename)
Constructor A reader is defined for reading a defined file.
This class is used to implement factored decision process.
Definition fmdp.h:73
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