aGrUM  0.16.0
BIFReader.h
Go to the documentation of this file.
1 
65 #ifndef BIF_READER_H
66 #define BIF_READER_H
67 
68 #include <fstream>
69 #include <iostream>
70 #include <string>
71 
73 #include <agrum/BN/IBayesNet.h>
74 #include <agrum/BN/io/BNReader.h>
75 
76 #ifndef DOXYGEN_SHOULD_SKIP_THIS
77 // including coco-generated PARSER and SCANNER
78 # include <agrum/BN/io/BIF/cocoR/Parser.h>
79 #endif // DOXYGEN_SHOULD_SKIP_THIS
80 
81 namespace gum {
125  template < typename GUM_SCALAR >
126  class BIFReader : public BNReader< GUM_SCALAR > {
127  public:
128  BIFReader(BayesNet< GUM_SCALAR >* bn, const std::string& filename);
129 
130  ~BIFReader() final;
131 
134  BIF::Scanner& scanner();
135 
137  const std::string& streamName() const;
138 
140  bool trace() const;
141  void trace(bool b);
142 
146  Size proceed() final;
147 
150 
152  Size errors();
154  Size warnings();
155 
157  Idx errLine(Idx i);
159  Idx errCol(Idx i);
161  bool errIsError(Idx i);
163  std::string errMsg(Idx i);
164 
166  void showElegantErrors(std::ostream& o = std::cerr);
167 
169  void showElegantErrorsAndWarnings(std::ostream& o = std::cerr);
170 
172  void showErrorCounts(std::ostream& o = std::cerr);
174 
175  protected:
178  BIF::Scanner* __scanner;
179  BIF::Parser* __parser;
180 
181  std::string __streamName;
184 
185  // a boolean to throw the ioerror not in the constructor but in the
186  // proceed()
187  bool __ioerror;
188  };
189 
190 
191 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
192  extern template class BIFReader< double >;
193 #endif
194 
195 } // namespace gum
196 
198 
199 #endif // BIF_READER_H
Class representing a Bayesian Network.
Definition: BayesNet.h:78
BayesNet< GUM_SCALAR > * __bn
Definition: BIFReader.h:176
const std::string & streamName() const
name of readen file
bool errIsError(Idx i)
type of ith error or warning
std::string errMsg(Idx i)
message of ith error or warning
BayesNetFactory< GUM_SCALAR > * __factory
Definition: BIFReader.h:177
void showErrorCounts(std::ostream &o=std::cerr)
send on std::cerr the number of errors and the number of warnings
BIF::Parser * __parser
Definition: BIFReader.h:179
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
void showElegantErrors(std::ostream &o=std::cerr)
send on std::cerr the list of errors
Pure virtual class for reading a BN from a file.
Definition: BNReader.h:55
Size proceed() final
parse.
BIF::Scanner * __scanner
Definition: BIFReader.h:178
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
~BIFReader() final
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Idx errCol(Idx i)
col of ith error or warning
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
bool __parseDone
Definition: BIFReader.h:183
std::string __streamName
Definition: BIFReader.h:181
bool trace() const
accessor to trace function (just write the number of parser line)
Definition of templatized reader of BIF files for Bayesian Networks.
Definition: BIFReader.h:126
Size warnings()
of errors
Size errors()
publishing Errors API
BIF::Scanner & scanner()
Direct access to BIF scanner (mandatory for listener connection)
Size Idx
Type for indexes.
Definition: types.h:53
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
bool __traceScanning
Definition: BIFReader.h:182
Idx errLine(Idx i)
line of ith error or warning
A factory class to ease BayesNet construction.
Definition: BayesNet.h:45
BIFReader(BayesNet< GUM_SCALAR > *bn, const std::string &filename)
void showElegantErrorsAndWarnings(std::ostream &o=std::cerr)
send on std::cerr the list of errors or warnings