FluidXDescriptor.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30 */
31 
32 /**
33  @file FluidXDescriptor.hpp
34 
35  @author Aline LIBRES <aline.libres@gmail.com>
36  @author Jean-Christophe Fabre <jean-christophe.fabre@supagro.inra.fr>
37  */
38 
39 
40 #ifndef __OPENFLUID_FLUIDX_FLUIDXDESCRIPTOR_HPP__
41 #define __OPENFLUID_FLUIDX_FLUIDXDESCRIPTOR_HPP__
42 
43 
44 #include <QDomElement>
45 
46 #include <openfluid/dllexport.hpp>
52 #include <openfluid/dllexport.hpp>
54 
55 
56 namespace openfluid {
57 
58 
59 namespace base {
60 class IOListener;
61 }
62 
63 
64 namespace fluidx {
65 
66 
68 {
69  private:
70 
72 
74 
75  openfluid::fluidx::RunDescriptor m_RunDescriptor;
76 
77  openfluid::fluidx::DatastoreDescriptor m_DatastoreDescriptor;
78 
79  openfluid::fluidx::MonitoringDescriptor m_MonitoringDescriptor;
80 
81  std::string m_CurrentFile;
82 
83  std::string m_CurrentDir;
84 
85  bool m_RunConfigDefined;
86 
87  bool m_ModelDefined;
88 
89  std::string m_IndentStr;
90 
91  openfluid::base::IOListener* mp_Listener;
92 
93  bool extractWareEnabledFromNode(QDomElement& Node);
94 
95  void extractMonitoringFromNode(QDomElement& Node);
96 
97  openfluid::ware::WareParams_t extractParamsFromNode(QDomElement& Node);
98 
100  const openfluid::ware::WareParams_t& OverloadParams);
101 
102  void extractModelFromNode(QDomElement& Node);
103 
104  void extractRunFromNode(QDomElement& Node);
105 
106  void extractDomainFomNode(QDomElement& Node);
107 
108  openfluid::core::UnitClassID_t extractUnitClassIDFromNode(QDomElement& Node);
109 
110  void extractDomainDefinitionFromNode(QDomElement& Node);
111 
112  void extractDomainAttributesFromNode(QDomElement& Node);
113 
114  void extractDomainCalendarFromNode(QDomElement& Node);
115 
116  void extractDatastoreFromNode(QDomElement& Node);
117 
118  void parseFile(std::string Filename);
119 
120  // =====================================================================
121  // =====================================================================
122 
123  void prepareFluidXDir(const std::string& DirPath);
124 
125  std::string getGeneratorMethodAsStr(openfluid::fluidx::GeneratorDescriptor::GeneratorMethod Method) const;
126 
127  std::string getParamsAsStr(const openfluid::ware::WareParams_t& Params) const;
128 
129  void writeModelToStream(std::ostream& Contents);
130 
131  void writeDomainToStream(std::ostream& Contents);
132 
133  void writeDomainDefinitionToStream(std::ostream& Contents);
134 
135  void writeDomainAttributesToStream(std::ostream& Contents);
136 
137  void writeDomainCalendarToStream(std::ostream& Contents);
138 
139  void writeRunConfigurationToStream(std::ostream& Contents);
140 
141  void writeDatastoreToStream(std::ostream& Contents);
142 
143  void writeMonitoringToStream(std::ostream& Contents);
144 
145 
146  public:
147 
149 
150  ~FluidXDescriptor();
151 
152  void loadFromDirectory(const std::string& DirPath);
153 
155  { return m_ModelDescriptor; }
156 
158  { return m_DomainDescriptor; }
159 
161  { return m_RunDescriptor; }
162 
164  { return m_DatastoreDescriptor; }
165 
167  { return m_MonitoringDescriptor; }
168 
170  { return m_ModelDescriptor; }
171 
173  { return m_DomainDescriptor; }
174 
176  { return m_RunDescriptor; }
177 
179  { return m_DatastoreDescriptor; }
180 
182  { return m_MonitoringDescriptor; }
183 
184  void writeToManyFiles(const std::string& DirPath);
185 
186  void writeToSingleFile(const std::string& FilePath);
187 };
188 
189 
190 } } // namespaces
191 
192 
193 #endif /* __OPENFLUID_FLUIDX_FLUIDXDESCRIPTOR_HPP__ */
openfluid::fluidx::CoupledModelDescriptor & modelDescriptor()
Definition: FluidXDescriptor.hpp:154
const openfluid::fluidx::DatastoreDescriptor & datastoreDescriptor() const
Definition: FluidXDescriptor.hpp:178
Definition: FluidXDescriptor.hpp:67
openfluid::fluidx::MonitoringDescriptor & monitoringDescriptor()
Definition: FluidXDescriptor.hpp:166
openfluid::fluidx::DatastoreDescriptor & datastoreDescriptor()
Definition: FluidXDescriptor.hpp:163
GeneratorMethod
Definition: GeneratorDescriptor.hpp:53
const openfluid::fluidx::SpatialDomainDescriptor & spatialDomainDescriptor() const
Definition: FluidXDescriptor.hpp:172
Definition: RunDescriptor.hpp:51
const openfluid::fluidx::CoupledModelDescriptor & modelDescriptor() const
Definition: FluidXDescriptor.hpp:169
const openfluid::fluidx::MonitoringDescriptor & monitoringDescriptor() const
Definition: FluidXDescriptor.hpp:181
Definition: ApplicationException.hpp:47
Definition: SpatialDomainDescriptor.hpp:53
Definition: DatastoreDescriptor.hpp:50
openfluid::fluidx::RunDescriptor & runDescriptor()
Definition: FluidXDescriptor.hpp:160
#define OPENFLUID_API
Definition: dllexport.hpp:87
openfluid::fluidx::SpatialDomainDescriptor & spatialDomainDescriptor()
Definition: FluidXDescriptor.hpp:157
std::pair< UnitsClass_t, UnitID_t > UnitClassID_t
Definition: TypeDefs.hpp:91
Definition: IOListener.hpp:54
const openfluid::fluidx::RunDescriptor & runDescriptor() const
Definition: FluidXDescriptor.hpp:175
std::map< WareParamKey_t, WareParamValue_t > WareParams_t
Definition: TypeDefs.hpp:130