fluidx/FluidXDescriptor.hpp
Go to the documentation of this file.
00001 /*
00002 
00003   This file is part of OpenFLUID software
00004   Copyright(c) 2007, INRA - Montpellier SupAgro
00005 
00006 
00007  == GNU General Public License Usage ==
00008 
00009   OpenFLUID is free software: you can redistribute it and/or modify
00010   it under the terms of the GNU General Public License as published by
00011   the Free Software Foundation, either version 3 of the License, or
00012   (at your option) any later version.
00013 
00014   OpenFLUID is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017   GNU General Public License for more details.
00018 
00019   You should have received a copy of the GNU General Public License
00020   along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
00021 
00022 
00023  == Other Usage ==
00024 
00025   Other Usage means a use of OpenFLUID that is inconsistent with the GPL
00026   license, and requires a written agreement between You and INRA.
00027   Licensees for Other Usage of OpenFLUID may use this file in accordance
00028   with the terms contained in the written agreement between You and INRA.
00029   
00030 */
00031 
00032 /**
00033  \file FluidXDescriptor.hpp
00034  \brief Header of ...
00035 
00036  \author Aline LIBRES <aline.libres@gmail.com>
00037  */
00038 
00039 #ifndef FLUIDXDESCRIPTOR_HPP_
00040 #define FLUIDXDESCRIPTOR_HPP_
00041 
00042 #include <openfluid/dllexport.hpp>
00043 #include <openfluid/fluidx/DomainDescriptor.hpp>
00044 #include <openfluid/fluidx/CoupledModelDescriptor.hpp>
00045 #include <openfluid/fluidx/RunDescriptor.hpp>
00046 #include <openfluid/fluidx/DatastoreDescriptor.hpp>
00047 #include <openfluid/fluidx/MonitoringDescriptor.hpp>
00048 #include <openfluid/fluidx/GeneratorDescriptor.hpp>
00049 #include <openfluid/dllexport.hpp>
00050 
00051 #include <QDomElement>
00052 
00053 
00054 namespace openfluid {
00055 
00056 namespace base {
00057 class IOListener;
00058 }
00059 
00060 namespace fluidx {
00061 
00062 class DLLEXPORT FluidXDescriptor
00063 {
00064   private:
00065 
00066     openfluid::fluidx::CoupledModelDescriptor m_ModelDescriptor;
00067 
00068     openfluid::fluidx::DomainDescriptor m_DomainDescriptor;
00069 
00070     openfluid::fluidx::RunDescriptor m_RunDescriptor;
00071 
00072     openfluid::fluidx::DatastoreDescriptor m_DatastoreDescriptor;
00073 
00074     openfluid::fluidx::MonitoringDescriptor m_MonitoringDescriptor;
00075 
00076     std::string m_CurrentFile;
00077 
00078     std::string m_CurrentDir;
00079 
00080     bool m_RunConfigDefined;
00081 
00082     bool m_ModelDefined;
00083 
00084     openfluid::base::IOListener* mp_Listener;
00085 
00086     std::string m_IndentStr;
00087 
00088     bool extractWareEnabledFromNode(QDomElement& Node);
00089 
00090     void extractMonitoringFromNode(QDomElement& Node);
00091 
00092     openfluid::ware::WareParams_t extractParamsFromNode(QDomElement& Node);
00093 
00094     openfluid::ware::WareParams_t mergeParams(
00095         const openfluid::ware::WareParams_t& Params,
00096         const openfluid::ware::WareParams_t& OverloadParams);
00097 
00098     void extractModelFromNode(QDomElement& Node);
00099 
00100     void extractRunFromNode(QDomElement& Node);
00101 
00102     void extractDomainFomNode(QDomElement& Node);
00103 
00104     openfluid::core::UnitClassID_t extractUnitClassIDFromNode(
00105         QDomElement& Node);
00106 
00107     void extractDomainDefinitionFromNode(QDomElement& Node);
00108 
00109     void extractDomainAttributesFromNode(QDomElement& Node);
00110 
00111     void extractDomainCalendarFromNode(QDomElement& Node);
00112 
00113     void extractDatastoreFromNode(QDomElement& Node);
00114 
00115     void parseFile(std::string Filename);
00116 
00117     // =====================================================================
00118     // =====================================================================
00119 
00120     void prepareFluidXDir(std::string DirPath);
00121 
00122     std::string getGeneratorMethodAsStr(
00123         openfluid::fluidx::GeneratorDescriptor::GeneratorMethod Method) const;
00124 
00125     std::string getParamsAsStr(
00126         const openfluid::ware::WareParams_t& Params) const;
00127 
00128     void writeModelToStream(std::ostream& Contents);
00129 
00130     void writeDomainToStream(std::ostream& Contents);
00131 
00132     void writeDomainDefinitionToStream(std::ostream& Contents);
00133 
00134     void writeDomainAttributesToStream(std::ostream& Contents);
00135 
00136     void writeDomainCalendarToStream(std::ostream& Contents);
00137 
00138     void writeRunConfigurationToStream(std::ostream& Contents);
00139 
00140     void writeDatastoreToStream(std::ostream& Contents);
00141 
00142     void writeMonitoringToStream(std::ostream& Contents);
00143 
00144   public:
00145 
00146 
00147     FluidXDescriptor(openfluid::base::IOListener* Listener);
00148 
00149     ~FluidXDescriptor();
00150 
00151     void loadFromDirectory(std::string DirPath);
00152 
00153     inline openfluid::fluidx::CoupledModelDescriptor& getModelDescriptor()
00154     { return m_ModelDescriptor; }
00155 
00156     inline openfluid::fluidx::DomainDescriptor& getDomainDescriptor()
00157     { return m_DomainDescriptor; }
00158 
00159     inline openfluid::fluidx::RunDescriptor& getRunDescriptor()
00160     { return m_RunDescriptor; }
00161 
00162     inline openfluid::fluidx::DatastoreDescriptor& getDatastoreDescriptor()
00163     { return m_DatastoreDescriptor; }
00164 
00165     inline openfluid::fluidx::MonitoringDescriptor& getMonitoringDescriptor()
00166     { return m_MonitoringDescriptor; }
00167 
00168     inline const openfluid::fluidx::CoupledModelDescriptor& getModelDescriptor() const
00169     { return m_ModelDescriptor; }
00170 
00171     inline const openfluid::fluidx::DomainDescriptor& getDomainDescriptor() const
00172     { return m_DomainDescriptor; }
00173 
00174     inline const openfluid::fluidx::RunDescriptor& getRunDescriptor() const
00175     { return m_RunDescriptor; }
00176 
00177     inline const openfluid::fluidx::DatastoreDescriptor& getDatastoreDescriptor() const
00178     { return m_DatastoreDescriptor; }
00179 
00180     inline const openfluid::fluidx::MonitoringDescriptor& getMonitoringDescriptor() const
00181     { return m_MonitoringDescriptor; }
00182 
00183     // =====================================================================
00184     // =====================================================================
00185 
00186     void writeToManyFiles(std::string DirPath);
00187 
00188     void writeToSingleFile(std::string FilePath);
00189 };
00190 
00191 }
00192 } // namespaces
00193 #endif /* FLUIDXDESCRIPTOR_HPP_ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines