aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
MNReader.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /**
23  * @file
24  * @brief Definition of abstract classes for file input manipulation
25  * of Markov Networks.
26  *
27  * Every classe used to read a MN from a file, must inherit from
28  * MNWriter or MNReader.
29  *
30  * @author Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
31  */
32 #ifndef GUM_MN_READER_H
33 #define GUM_MN_READER_H
34 
35 #include <agrum/MN/MarkovNet.h>
36 #include <agrum/agrum.h>
37 #include <iostream>
38 #include <string>
39 
40 namespace gum {
41  /* =========================================================================*/
42  /* === READERS === */
43  /* =========================================================================*/
44  /**
45  * @class MNReader
46  * @headerfile MNReader.h <agrum/MN/io/MNReader.h>
47  * @ingroup mn_io
48  * @brief Pure virtual class for reading a MN from a file.
49  *
50  * Every class used to read the content of a Markov Network from a stream,
51  * or a file must be a subclass of MNReader.
52  */
53  template < typename GUM_SCALAR >
54  class MNReader {
55  public:
56  /**
57  * Constructor
58  * A reader is defined for reading a defined file. Hence the 2 args of the
59  * constructor.
60  * Note that the MN has to be built outside the reader. There is no
61  * delegation to create/destroy the MN from inside the reader.
62  */
63  MNReader(MarkovNet< GUM_SCALAR >* MN, const std::string& filename);
64 
65  /**
66  * Default destructor.
67  */
68  virtual ~MNReader();
69 
70  /**
71  * Reads a Markov Network from the file referenced by filePath into`
72  * parameter MarkovNet.
73  * @return Returns the number of error during the parsing (0 if none).
74  */
75  virtual Size proceed() = 0;
76  };
77 
78 
79 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
80  extern template class MNReader< double >;
81 #endif
82 
83 } /* namespace gum */
84 
85 #include <agrum/MN/io/MNReader_tpl.h>
86 
87 #endif // GUM_MN_READER_H