aGrUM  0.16.0
O3prmBNReader.h
Go to the documentation of this file.
1 
32 #ifndef GUM_PRM_O3PRM_BNREADER_H
33 #define GUM_PRM_O3PRM_BNREADER_H
34 
35 #include <algorithm>
36 #include <string>
37 
38 #include <agrum/BN/io/BNReader.h>
40 
41 #include <agrum/PRM/PRM.h>
43 
44 namespace gum {
56  template < typename GUM_SCALAR >
57  class O3prmBNReader : public BNReader< GUM_SCALAR > {
58  public:
60  const std::string& filename,
61  const std::string& entityName = "",
62  const std::string& classPath = "");
63 
65 
69  Size proceed();
70 
73 
78 
79  Idx errLine(Idx i) { return __errors.error(i).line; }
81  Idx errCol(Idx i) { return __errors.error(i).column; }
83  bool errIsError(Idx i) { return __errors.error(i).is_error; }
85  std::string errMsg(Idx i) { return __errors.error(i).msg; }
86 
88  void showElegantErrors(std::ostream& o = std::cerr) {
90  }
91 
93  void showElegantErrorsAndWarnings(std::ostream& o = std::cerr) {
95  }
96 
98  void showErrorCounts(std::ostream& o = std::cerr) {
100  }
102 
103  private:
104  std::string __filename;
105 
106  std::string __classpath;
107  std::string __entityName;
108 
111 
113  static std::string __getVariableName(const std::string& path,
114  const std::string& type,
115  const std::string& name,
116  const std::string& toRemove = "");
117  static std::string __getEntityName(const std::string& filename);
118  static std::string __getInstanceName(const std::string& classname);
119  };
120 
121 } // namespace gum
122 
123 // always include the implementation of the templates
125 
126 
127 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
128 extern template class gum::O3prmBNReader< double >;
129 #endif
130 
131 
132 #endif // GUM_PRM_O3PRM_BNREADER_H
Idx errCol(Idx i)
col of ith error or warning
Definition: O3prmBNReader.h:81
Class representing a Bayesian Network.
Definition: BayesNet.h:78
Idx errLine(Idx i)
publishing Errors API
Definition: O3prmBNReader.h:79
std::string msg
The gum::ParseError message.
std::string __entityName
static std::string __getEntityName(const std::string &filename)
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
static std::string __getVariableName(const std::string &path, const std::string &type, const std::string &name, const std::string &toRemove="")
Size error_count
Number of errors detected.
std::string __filename
ErrorsContainer __errors
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
O3prmBNReader(BayesNet< GUM_SCALAR > *bn, const std::string &filename, const std::string &entityName="", const std::string &classPath="")
void syntheticResults(std::ostream &o) const
Print errors on output stream.
void elegantErrorsAndWarnings(std::ostream &o) const
Print errors on output stream.
This class is used contain and manipulate gum::ParseError.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
void showElegantErrorsAndWarnings(std::ostream &o=std::cerr)
send on std::cerr the list of errors or warnings
Definition: O3prmBNReader.h:93
Pure virtual class for reading a BN from a file.
Definition: BNReader.h:55
void __generateBN(prm::PRMSystem< GUM_SCALAR > &system)
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.
bool is_error
If false, this gum::ParseError is a warning.
Idx line
The line of this gum::ParseError.
std::string errMsg(Idx i)
message of ith error or warning
Definition: O3prmBNReader.h:85
std::string __classpath
A PRMSystem is a container of PRMInstance and describe a relational skeleton.
Definition: PRMObject.h:229
static std::string __getInstanceName(const std::string &classname)
void elegantErrors(std::ostream &o) const
Print errors on output stream.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void showElegantErrors(std::ostream &o=std::cerr)
send on std::cerr the list of errors
Definition: O3prmBNReader.h:88
Size Idx
Type for indexes.
Definition: types.h:53
Size errors()
publishing Errors API
Definition: O3prmBNReader.h:75
ParseError error(Idx i) const
Returns the i-th error.
void showErrorCounts(std::ostream &o=std::cerr)
send on std::cerr the number of errors and the number of warnings
Definition: O3prmBNReader.h:98
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
Idx column
The column of this gum::ParseError, default is 0.
bool errIsError(Idx i)
type of ith error or warning
Definition: O3prmBNReader.h:83
Read an O3PRM and transform the gum::prm::PRMSystem into gum::BayesNet.
Definition: O3prmBNReader.h:57
Size proceed()
parse the file
Size warnings()
of errors
Definition: O3prmBNReader.h:77
BayesNet< GUM_SCALAR > * __bn