aGrUM  0.14.2
BIFXMLBNWriter.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES *
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_BIF_XML_BN_WRITER_H
30 #define GUM_BIF_XML_BN_WRITER_H
31 
32 #define TIXML_USE_TICPP
33 
34 #include <fstream>
35 #include <iostream>
36 #include <sstream>
37 #include <string>
38 
39 #include <agrum/BN/io/BNWriter.h>
40 #include <agrum/agrum.h>
41 
42 namespace gum {
43 
56  template < typename GUM_SCALAR >
57  class BIFXMLBNWriter : public BNWriter< GUM_SCALAR > {
58  public:
59  // ==========================================================================
61  // ==========================================================================
63 
68 
72  ~BIFXMLBNWriter() final;
73 
75 
83  void write(std::ostream& output, const IBayesNet< GUM_SCALAR >& bn) final;
84 
94  void write(const std::string& filePath,
95  const IBayesNet< GUM_SCALAR >& bn) final;
96 
97  private:
101  std::string __heading(const IBayesNet< GUM_SCALAR >& bn);
102 
106  std::string __documentend();
107 
111  std::string __variableBloc(const DiscreteVariable& var);
112 
117  std::string __variableDefinition(const NodeId& varNodeId,
118  const IBayesNet< GUM_SCALAR >& bn);
119  };
120 
121 
122 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
123  extern template class BIFXMLBNWriter< double >;
124 #endif
125 
126 } /* namespace gum */
127 
129 #endif // GUM_BIF_XML_BN_WRITER_H
BIFXMLBNWriter()
Default constructor.
std::string __heading(const IBayesNet< GUM_SCALAR > &bn)
Returns the header of the BIF file.
Base class for discrete random variable.
Class representing the minimal interface for Bayesian Network.
Definition: IBayesNet.h:59
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
std::string __variableBloc(const DiscreteVariable &var)
Returns a bloc defining a variable in the BIF format.
std::string __documentend()
Returns the end of the BIF file.
std::string __variableDefinition(const NodeId &varNodeId, const IBayesNet< GUM_SCALAR > &bn)
Returns a bloc defining a variable&#39;s table (if she has) in the BIF format.
void write(std::ostream &output, const IBayesNet< GUM_SCALAR > &bn) final
Writes an bayes net in the given ouput stream.
~BIFXMLBNWriter() final
Destructor.
<agrum/BN/io/BIFXML/BIFXMLBNWriter.h>
Definition of abstract classes for file output manipulation of Bayesian Networks. ...
Pure virtual class for writting a BN to a file.
Definition: BNWriter.h:54
Size NodeId
Type for node ids.
Definition: graphElements.h:97