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