aGrUM  0.14.2
fmdpDatReader.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
63 // ======================================================================================================
64 #ifndef FMDP_DAT_READER_H
65 #define FMDP_DAT_READER_H
66 // ======================================================================================================
67 #include <fstream>
68 #include <iostream>
69 #include <string>
70 // ======================================================================================================
71 #include <agrum/FMDP/fmdp.h>
72 #include <agrum/FMDP/fmdpFactory.h>
74 // ======================================================================================================
76 // ======================================================================================================
77 
78 #ifndef DOXYGEN_SHOULD_SKIP_THIS
79 // including coco-generated PARSER and SCANNER
80 # include <agrum/FMDP/io/dat/cocoR/Parser.h>
81 #endif // DOXYGEN_SHOULD_SKIP_THIS
82 
83 namespace gum {
90  template < typename GUM_SCALAR >
91  class FMDPDatReader : public FMDPReader< GUM_SCALAR > {
92  public:
93  FMDPDatReader(FMDP< GUM_SCALAR >* fmdp, const std::string& filename);
95 
98  MDPDAT::Scanner& scanner();
99 
101  const std::string& streamName() const;
102 
104  bool trace() const;
105  void trace(bool b);
106 
110  Size proceed();
111 
114 
116  Size errors();
118  Size warnings();
119 
121  Idx errLine(Idx i);
123  Idx errCol(Idx i);
125  bool errIsError(Idx i);
127  std::string errMsg(Idx i);
128 
130  void showElegantErrors(std::ostream& o = std::cerr);
131 
133  void showElegantErrorsAndWarnings(std::ostream& o = std::cerr);
134 
136  void showErrorCounts(std::ostream& o = std::cerr);
138 
139  protected:
142  MDPDAT::Scanner* __scanner;
143  MDPDAT::Parser* __parser;
144 
145  std::string __streamName;
148 
149  // a boolean to throw the ioerror not in the constructor but in the
150  // proceed()
151  bool __ioerror;
152  };
153 
154 
155 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
156  extern template class FMDPDatReader< double >;
157 #endif
158 
159 } // namespace gum
160 
162 
163 #endif // FMDP_DAT_READER_H
bool errIsError(Idx i)
type of ith error or warning
FMDPDatReader(FMDP< GUM_SCALAR > *fmdp, const std::string &filename)
A factory class to ease Factored Markov Decision Process construction.
Definition: fmdpFactory.h:68
Definition of abstract classes for file input manipulation of Factored Markov Decision Process...
const std::string & streamName() const
name of readen file
Size errors()
publishing Errors API
Pure virtual class for reading a FMDP from a file.
Definition: fmdpReader.h:57
FMDPFactory< GUM_SCALAR > * __factory
FMDP< GUM_SCALAR > * __fmdp
MDPDAT::Parser * __parser
Idx errCol(Idx i)
col of ith error or warning
This class is used to implement factored decision process.
Definition: fmdp.h:54
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
Definition of templatized reader of FMDPDat files for Factored Markov Decision Processes.
Definition: fmdpDatReader.h:91
Class for implementation of factored markov decision process.
void showElegantErrorsAndWarnings(std::ostream &o=std::cerr)
send on std::cerr the list of errors or warnings
MDPDAT::Scanner & scanner()
Direct access to FMDPDat scanner (mandatory for listener connection)
Size warnings()
of errors
void showElegantErrors(std::ostream &o=std::cerr)
send on std::cerr the list of errors
MDPDAT::Scanner * __scanner
Headers of MultiDimFunctionGraph.
Headers of the FMDPFactory class.
void showErrorCounts(std::ostream &o=std::cerr)
send on std::cerr the number of errors and the number of warnings
Size Idx
Type for indexes.
Definition: types.h:50
std::string errMsg(Idx i)
message of ith error or warning
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
Definition of templatized reader of dat files for Factored Markov Decision Process.
bool trace() const
accessor to trace function (just write the number of parser line)
Size proceed()
parse.
std::string __streamName
Idx errLine(Idx i)
line of ith error or warning