aGrUM  0.16.3
a C++ library for (probabilistic) graphical models
netReader.h
Go to the documentation of this file.
1 
23 #ifndef NETREADER_H
24 #define NETREADER_H
25 
26 #include <agrum/BN/BayesNet.h>
27 #include <agrum/BN/io/BNReader.h>
28 #include <agrum/agrum.h>
29 #include <iostream>
30 #include <string>
31 
32 #ifndef DOXYGEN_SHOULD_SKIP_THIS
33 // including coco-generated PARSER and SCANNER
34 # undef COCO_PARSER_H__
35 # undef COCO_SCANNER_H__
36 # include <agrum/BN/io/net/cocoR/Parser.h>
37 #endif // DOXYGEN_SHOULD_SKIP_THIS
38 
39 namespace gum {
40  /* =========================================================================*/
41  /* === READERS === */
42  /* =========================================================================*/
52  template < typename GUM_SCALAR >
53  class NetReader : public BNReader< GUM_SCALAR > {
54  public:
64  NetReader(BayesNet< GUM_SCALAR >* bn, const std::string& filename);
65 
69  ~NetReader() final;
70 
73  net::Scanner& scanner();
74 
76  const std::string& streamName() const;
77 
79  bool trace() const;
80  void trace(bool b);
81 
85  Size proceed() final;
86 
89 
91  Size errors();
93  Size warnings();
94 
96  Idx errLine(Idx i);
98  Idx errCol(Idx i);
100  bool errIsError(Idx i);
102  std::string errMsg(Idx i);
103 
105  void showElegantErrors(std::ostream& o = std::cerr);
106 
108  void showElegantErrorsAndWarnings(std::ostream& o = std::cerr);
109 
111  void showErrorsAndWarnings(std::ostream& o = std::cerr);
112 
114  void showErrorCounts(std::ostream& o = std::cerr);
116 
117  protected:
120  net::Scanner* __scanner;
121  net::Parser* __parser;
122 
123  std::string __streamName;
126 
127  // a boolean to throw the ioerror not in the constructor but in the
128  // proceed()
129  bool __ioerror;
130  };
131 
132 
133 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
134  extern template class NetReader< double >;
135 #endif
136 
137 } /* namespace gum */
138 
139 #include "netReader_tpl.h"
140 
141 #endif // NETREADER_H
Class representing a Bayesian Network.
Definition: BayesNet.h:78
bool errIsError(Idx i)
type of ith error or warning
void showErrorsAndWarnings(std::ostream &o=std::cerr)
send on std::cerr the list of errors or warnings
BayesNet< GUM_SCALAR > * __bn
Definition: netReader.h:118
net::Scanner * __scanner
Definition: netReader.h:120
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
net::Parser * __parser
Definition: netReader.h:121
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
bool trace() const
accessor to trace function (just write the number of parser line)
Pure virtual class for reading a BN from a file.
Definition: BNReader.h:55
Size warnings()
of errors
std::string errMsg(Idx i)
message of ith error or warning
BayesNetFactory< GUM_SCALAR > * __factory
Definition: netReader.h:119
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Size errors()
publishing Errors API
const std::string & streamName() const
name of readen file
net::Scanner & scanner()
Direct access to DSL scanner (mandatory for listener connection)
std::string __streamName
Definition: netReader.h:123
void showErrorCounts(std::ostream &o=std::cerr)
send on std::cerr the number of errors and the number of warnings
~NetReader() final
Default destructor.
Size proceed() final
parse.
Pure virtual class for reading a BN from a file.
Definition: netReader.h:53
void showElegantErrorsAndWarnings(std::ostream &o=std::cerr)
send on std::cerr the list of errors or warnings with contents
bool __parseDone
Definition: netReader.h:125
bool __traceScanning
Definition: netReader.h:124
Size Idx
Type for indexes.
Definition: types.h:53
void showElegantErrors(std::ostream &o=std::cerr)
send on std::cerr the list of errorswith contents
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
NetReader(BayesNet< GUM_SCALAR > *bn, const std::string &filename)
Constructor A reader is defined for reading a defined file.
Idx errCol(Idx i)
col of ith error or warning
A factory class to ease BayesNet construction.
Definition: BayesNet.h:45
Idx errLine(Idx i)
line of ith error or warning