base/ProjectManager.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 
00034 /**
00035   \file ProjectManager.hpp
00036   \brief Header of ...
00037 
00038   \author Jean-Christophe FABRE <fabrejc@supagro.inra.fr>
00039  */
00040 
00041 
00042 #ifndef __PROJECTMANAGER_HPP___
00043 #define __PROJECTMANAGER_HPP___
00044 
00045 
00046 #include <openfluid/dllexport.hpp>
00047 #include <string>
00048 #include <QString>
00049 #include <QVariant>
00050 #include <QSettings>
00051 
00052 namespace openfluid { namespace base {
00053 
00054 
00055 // =====================================================================
00056 // =====================================================================
00057 
00058 class DLLEXPORT ProjectManager
00059 {
00060   private:
00061 
00062     static ProjectManager* mp_Singleton;
00063 
00064     QSettings* mp_PrjFile;
00065 
00066     std::string m_Path;
00067 
00068     std::string m_Name;
00069     std::string m_Description;
00070     std::string m_Authors;
00071     std::string m_CreationDate;
00072     std::string m_LastModDate;
00073     bool m_IsIncOutputDir;
00074 
00075     std::string m_OutputDir;
00076     std::string m_InputDir;
00077 
00078     bool m_IsOpened;
00079 
00080     static QString m_GroupName;
00081 
00082 
00083     ProjectManager();
00084 
00085     static std::string getNow();
00086 
00087     static std::string getFilePathFromProjectPath(std::string ProjectPath);
00088 
00089     static std::string getInputDirFromProjectPath(std::string ProjectPath);
00090 
00091     static std::string getOuputDirFromProjectPath(std::string ProjectPath);
00092 
00093     static bool checkProject(const std::string& ProjectPath);
00094 
00095 
00096   public:
00097 
00098     static ProjectManager* getInstance();
00099 
00100     ~ProjectManager();
00101 
00102     std::string getPath() const { return m_Path; };
00103 
00104     std::string getName() const { return m_Name; };
00105 
00106     void setName(const std::string& Name) { m_Name = Name; };
00107 
00108     std::string getDescription() const { return m_Description; };
00109 
00110     void setDescription(const std::string& Description) { m_Description = Description; };
00111 
00112     std::string getAuthors() const { return m_Authors; };
00113 
00114     void setAuthors(const std::string& Authors) { m_Authors = Authors; };
00115 
00116     std::string getCreationDate() const { return m_CreationDate; };
00117 
00118     void setCreationDate(const std::string& CreationDate) { m_CreationDate = CreationDate; };
00119 
00120     void setCreationDateAsNow() { m_CreationDate = getNow(); };
00121 
00122     std::string getLastModDate() const { return m_LastModDate; };
00123 
00124     void setLastModDate(const std::string& LastModDate) { m_LastModDate = LastModDate; };
00125 
00126     std::string getOutputDir() { return m_OutputDir; };
00127 
00128     std::string getInputDir() const { return m_InputDir; };
00129 
00130     bool isIncrementalOutputDir() const { return m_IsIncOutputDir; };
00131 
00132     void setIncrementalOutputDir(const bool Inc) { m_IsIncOutputDir = Inc; };
00133 
00134     bool open(const std::string& Path);
00135 
00136     bool create(const std::string& Path, const std::string& Name,
00137                 const std::string& Description, const std::string& Authors,
00138                 const bool Inc);
00139 
00140     bool isOpened() const { return m_IsOpened; };
00141 
00142     bool save();
00143 
00144     void close();
00145 
00146     static bool isProject(const std::string& Path);
00147 
00148     static bool getProjectInfos(const std::string& Path,
00149                                 std::string& Name, std::string& Description, std::string& Authors,
00150                                 std::string& CreationDate, std::string& LastModDate);
00151 
00152     void updateOutputDir();
00153 
00154     QVariant getConfigValue(const QString& Group, const QString& Key) const;
00155 
00156     void setConfigValue(const QString& Group, const QString& Key, const QVariant& Value);
00157 
00158 };
00159 
00160 
00161 } } //namespaces
00162 
00163 
00164 #endif /* __PROJECTMANAGER_HPP___ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines