aGrUM  0.14.2
O3prmBNReader.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
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  ***************************************************************************/
29 #ifndef GUM_PRM_O3PRM_BNREADER_H
30 #define GUM_PRM_O3PRM_BNREADER_H
31 
32 #include <algorithm>
33 #include <string>
34 
35 #include <agrum/BN/io/BNReader.h>
37 
38 #include <agrum/PRM/PRM.h>
40 
41 namespace gum {
53  template < typename GUM_SCALAR >
54  class O3prmBNReader : public BNReader< GUM_SCALAR > {
55  public:
57  const std::string& filename,
58  const std::string& entityName = "",
59  const std::string& classPath = "");
60 
62 
66  Size proceed();
67 
70 
75 
76  Idx errLine(Idx i) { return __errors.error(i).line; }
78  Idx errCol(Idx i) { return __errors.error(i).column; }
80  bool errIsError(Idx i) { return __errors.error(i).is_error; }
82  std::string errMsg(Idx i) { return __errors.error(i).msg; }
83 
85  void showElegantErrors(std::ostream& o = std::cerr) {
87  }
88 
90  void showElegantErrorsAndWarnings(std::ostream& o = std::cerr) {
92  }
93 
95  void showErrorCounts(std::ostream& o = std::cerr) {
97  }
99 
100  private:
101  std::string __filename;
102 
103  std::string __classpath;
104  std::string __entityName;
105 
108 
110  static std::string __getVariableName(const std::string& path,
111  const std::string& type,
112  const std::string& name,
113  const std::string& toRemove = "");
114  static std::string __getEntityName(const std::string& filename);
115  static std::string __getInstanceName(const std::string& classname);
116  };
117 
118 } // namespace gum
119 
120 // always include the implementation of the templates
122 
123 
124 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
125 extern template class gum::O3prmBNReader< double >;
126 #endif
127 
128 
129 #endif // GUM_PRM_O3PRM_BNREADER_H
Idx errCol(Idx i)
col of ith error or warning
Definition: O3prmBNReader.h:78
Class representing a Bayesian Network.
Definition: BayesNet.h:76
Idx errLine(Idx i)
publishing Errors API
Definition: O3prmBNReader.h:76
std::string msg
The gum::ParseError message.
std::string __entityName
static std::string __getEntityName(const std::string &filename)
Errors container (at least) for parser.
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
Headers of PRM.
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.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
void showElegantErrorsAndWarnings(std::ostream &o=std::cerr)
send on std::cerr the list of errors or warnings
Definition: O3prmBNReader.h:90
Pure virtual class for reading a BN from a file.
Definition: BNReader.h:52
void __generateBN(prm::PRMSystem< GUM_SCALAR > &system)
Headers for the O3prmReader class.
Definition of abstract classes for file input manipulation of Bayesian Networks.
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:82
std::string __classpath
A PRMSystem is a container of PRMInstance and describe a relational skeleton.
Definition: PRMObject.h:226
static std::string __getInstanceName(const std::string &classname)
void elegantErrors(std::ostream &o) const
Print errors on output stream.
Inline implementation of O3prmReader.
void showElegantErrors(std::ostream &o=std::cerr)
send on std::cerr the list of errors
Definition: O3prmBNReader.h:85
Size Idx
Type for indexes.
Definition: types.h:50
Size errors()
publishing Errors API
Definition: O3prmBNReader.h:72
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:95
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
Idx column
The column of this gum::ParseError, default is 0.
bool errIsError(Idx i)
type of ith error or warning
Definition: O3prmBNReader.h:80
Read an O3PRM and transform the gum::prm::PRMSystem into gum::BayesNet.
Definition: O3prmBNReader.h:54
Size proceed()
parse the file
Size warnings()
of errors
Definition: O3prmBNReader.h:74
BayesNet< GUM_SCALAR > * __bn