All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ProjectManager.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 
34 /**
35  \file ProjectManager.hpp
36  \brief Header of ...
37 
38  \author Jean-Christophe FABRE <fabrejc@supagro.inra.fr>
39  */
40 
41 
42 #ifndef __PROJECTMANAGER_HPP___
43 #define __PROJECTMANAGER_HPP___
44 
45 
46 #include <openfluid/dllexport.hpp>
47 #include <string>
48 #include <QString>
49 #include <QVariant>
50 #include <QSettings>
51 
52 namespace openfluid { namespace base {
53 
54 
55 // =====================================================================
56 // =====================================================================
57 
59 {
60  private:
61 
62  static ProjectManager* mp_Singleton;
63 
64  QSettings* mp_PrjFile;
65 
66  std::string m_Path;
67 
68  std::string m_Name;
69  std::string m_Description;
70  std::string m_Authors;
71  std::string m_CreationDate;
72  std::string m_LastModDate;
73  bool m_IsIncOutputDir;
74 
75  std::string m_OutputDir;
76  std::string m_InputDir;
77 
78  bool m_IsOpened;
79 
80  static QString m_GroupName;
81 
82 
84 
85  static std::string getNow();
86 
87  static std::string getFilePathFromProjectPath(std::string ProjectPath);
88 
89  static std::string getInputDirFromProjectPath(std::string ProjectPath);
90 
91  static std::string getOuputDirFromProjectPath(std::string ProjectPath);
92 
93  static bool checkProject(const std::string& ProjectPath);
94 
95 
96  public:
97 
98  static ProjectManager* getInstance();
99 
100  ~ProjectManager();
101 
102  std::string getPath() const { return m_Path; };
103 
104  std::string getName() const { return m_Name; };
105 
106  void setName(const std::string& Name) { m_Name = Name; };
107 
108  std::string getDescription() const { return m_Description; };
109 
110  void setDescription(const std::string& Description) { m_Description = Description; };
111 
112  std::string getAuthors() const { return m_Authors; };
113 
114  void setAuthors(const std::string& Authors) { m_Authors = Authors; };
115 
116  std::string getCreationDate() const { return m_CreationDate; };
117 
118  void setCreationDate(const std::string& CreationDate) { m_CreationDate = CreationDate; };
119 
120  void setCreationDateAsNow() { m_CreationDate = getNow(); };
121 
122  std::string getLastModDate() const { return m_LastModDate; };
123 
124  void setLastModDate(const std::string& LastModDate) { m_LastModDate = LastModDate; };
125 
126  std::string getOutputDir() { return m_OutputDir; };
127 
128  std::string getInputDir() const { return m_InputDir; };
129 
130  bool isIncrementalOutputDir() const { return m_IsIncOutputDir; };
131 
132  void setIncrementalOutputDir(const bool Inc) { m_IsIncOutputDir = Inc; };
133 
134  bool open(const std::string& Path);
135 
136  bool create(const std::string& Path, const std::string& Name,
137  const std::string& Description, const std::string& Authors,
138  const bool Inc);
139 
140  bool isOpened() const { return m_IsOpened; };
141 
142  bool save();
143 
144  void close();
145 
146  static bool isProject(const std::string& Path);
147 
148  static bool getProjectInfos(const std::string& Path,
149  std::string& Name, std::string& Description, std::string& Authors,
150  std::string& CreationDate, std::string& LastModDate);
151 
152  void updateOutputDir();
153 
154  QVariant getConfigValue(const QString& Group, const QString& Key) const;
155 
156  void setConfigValue(const QString& Group, const QString& Key, const QVariant& Value);
157 
158 };
159 
160 
161 } } //namespaces
162 
163 
164 #endif /* __PROJECTMANAGER_HPP___ */
std::string getOutputDir()
Definition: ProjectManager.hpp:126
std::string getCreationDate() const
Definition: ProjectManager.hpp:116
std::string getAuthors() const
Definition: ProjectManager.hpp:112
void setCreationDate(const std::string &CreationDate)
Definition: ProjectManager.hpp:118
std::string getPath() const
Definition: ProjectManager.hpp:102
std::string getDescription() const
Definition: ProjectManager.hpp:108
void setAuthors(const std::string &Authors)
Definition: ProjectManager.hpp:114
bool isIncrementalOutputDir() const
Definition: ProjectManager.hpp:130
void setLastModDate(const std::string &LastModDate)
Definition: ProjectManager.hpp:124
std::string getLastModDate() const
Definition: ProjectManager.hpp:122
void setName(const std::string &Name)
Definition: ProjectManager.hpp:106
Definition: ProjectManager.hpp:58
void setCreationDateAsNow()
Definition: ProjectManager.hpp:120
std::string getName() const
Definition: ProjectManager.hpp:104
void setDescription(const std::string &Description)
Definition: ProjectManager.hpp:110
void setIncrementalOutputDir(const bool Inc)
Definition: ProjectManager.hpp:132
std::string getInputDir() const
Definition: ProjectManager.hpp:128
bool isOpened() const
Definition: ProjectManager.hpp:140
#define DLLEXPORT
Definition: dllexport.hpp:51