All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RunContextManager.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 RunContextManager.hpp
36 
37  @author Jean-Christophe FABRE <jean-christophe.fabre@supagro.inra.fr>
38  */
39 
40 
41 #ifndef __OPENFLUID_BASE_RUNCONTEXTMANAGER_HPP__
42 #define __OPENFLUID_BASE_RUNCONTEXTMANAGER_HPP__
43 
44 
45 #include <string>
46 
47 #include <QString>
48 #include <QVariant>
49 #include <QSettings>
50 
51 #include <openfluid/dllexport.hpp>
54 #include <openfluid/ware/TypeDefs.hpp>
56 
57 
58 namespace openfluid { namespace base {
59 
60 
62 {
63 
65 
66  private:
67 
68  std::string m_OutputDir;
69 
70  std::string m_InputDir;
71 
72  bool m_IsClearOutputDir;
73 
74  bool m_IsProfiling;
75 
76  unsigned int m_ValuesBufferSize;
77 
78  unsigned int m_WaresMaxNumThreads;
79 
80  openfluid::core::MapValue m_WaresSharedEnvironment;
81 
82  openfluid::core::MapValue m_ExtraProperties;
83 
84  QSettings* mp_ProjectFile;
85 
86  std::string m_ProjectPath;
87 
88  std::string m_ProjectName;
89 
90  std::string m_ProjectDescription;
91 
92  std::string m_ProjectAuthors;
93 
94  std::string m_ProjectCreationDate;
95 
96  std::string m_ProjectLastModDate;
97 
98  bool m_ProjectIncOutputDir;
99 
100  bool m_ProjectIsOpen;
101 
102  static QString m_ProjectFileGroupName;
103 
105 
107 
108  static std::string getNow();
109 
110  void updateWaresEnvironment();
111 
112  static std::string getFilePathFromProjectPath(const std::string& ProjectPath);
113 
114  static std::string getInputDirFromProjectPath(const std::string& ProjectPath);
115 
116  static std::string getOuputDirFromProjectPath(const std::string& ProjectPath);
117 
118  static bool checkProject(const std::string& ProjectPath);
119 
120 
121  public:
122 
123  std::string getInputDir() const
124  { return m_InputDir; }
125 
126  std::string getInputFullPath(const std::string& Filename) const
127  { return m_InputDir + "/" + Filename; }
128 
129  void setInputDir(const std::string& InputDir);
130 
131  std::string getOutputDir() const
132  { return m_OutputDir; }
133 
134  std::string getOutputFullPath(const std::string& Filename) const
135  { return m_OutputDir + "/" + Filename; }
136 
137  void setOutputDir(const std::string& OutputDir);
138 
139  void setDateTimeOutputDir();
140 
141  bool isClearOutputDir() const
142  { return m_IsClearOutputDir; }
143 
144  void setClearOutputDir(bool Enabled)
145  { m_IsClearOutputDir = Enabled; }
146 
147  bool isProfiling() const
148  { return m_IsProfiling; }
149 
150  void setProfiling(bool Enabled)
151  { m_IsProfiling = Enabled; }
152 
153  unsigned int getValuesBufferUserSize() const
154  { return m_ValuesBufferSize; }
155 
156  void setValuesBufferUserSize(unsigned int Size)
157  { m_ValuesBufferSize = Size; }
158 
160  { m_ValuesBufferSize = 0; }
161 
163  { return (m_ValuesBufferSize > 0); }
164 
165  unsigned int getWaresMaxNumThreads() const
166  { return m_WaresMaxNumThreads; }
167 
168  void setWaresMaxNumThreads(unsigned int Num)
169  { m_WaresMaxNumThreads = Num; }
170 
171  void resetWaresMaxNumThreads();
172 
174  { return m_ExtraProperties; }
175 
177  { return m_WaresSharedEnvironment; }
178 
179  void processWareParams(openfluid::ware::WareParams_t& Params) const;
180 
181  std::string getProjectPath() const
182  { return m_ProjectPath; }
183 
184  std::string getProjectName() const
185  { return m_ProjectName; }
186 
187  void setProjectName(const std::string& Name)
188  { m_ProjectName = Name; }
189 
190  std::string getProjectDescription() const
191  { return m_ProjectDescription; }
192 
193  void setProjectDescription(const std::string& Description)
194  { m_ProjectDescription = Description; }
195 
196  std::string getProjectAuthors() const
197  { return m_ProjectAuthors; }
198 
199  void setProjectAuthors(const std::string& Authors)
200  { m_ProjectAuthors = Authors; }
201 
202  std::string getProjectCreationDate() const
203  { return m_ProjectCreationDate; }
204 
205  void setProjectCreationDate(const std::string& CreationDate)
206  { m_ProjectCreationDate = CreationDate; }
207 
209  { m_ProjectCreationDate = getNow(); }
210 
211  std::string getProjectLastModDate() const
212  { return m_ProjectLastModDate; }
213 
214  void setProjectLastModDate(const std::string& LastModDate)
215  { m_ProjectLastModDate = LastModDate; }
216 
218  { return m_ProjectIncOutputDir; }
219 
220  void setProjectIncrementalOutputDir(const bool Inc)
221  { m_ProjectIncOutputDir = Inc; }
222 
223  bool openProject(const std::string& Path);
224 
225  bool createProject(const std::string& Path, const std::string& Name,
226  const std::string& Description, const std::string& Authors,
227  const bool Inc);
228 
229  bool isProjectOpen() const
230  { return m_ProjectIsOpen; }
231 
232  bool saveProject();
233 
234  void closeProject();
235 
236  static bool isProject(const std::string& Path);
237 
238  static bool getProjectInfos(const std::string& Path,
239  std::string& Name, std::string& Description, std::string& Authors,
240  std::string& CreationDate, std::string& LastModDate);
241 
242  void updateProjectOutputDir();
243 
244  QVariant getProjectConfigValue(const QString& Group, const QString& Key) const;
245 
246  void setProjectConfigValue(const QString& Group, const QString& Key, const QVariant& Value);
247 
248 };
249 
250 
251 } } //namespaces
252 
253 
254 #endif /* __OPENFLUID_BASE_RUNCONTEXTMANAGER_HPP__ */
std::string getProjectPath() const
Definition: RunContextManager.hpp:181
Definition: Environment.hpp:52
void setClearOutputDir(bool Enabled)
Definition: RunContextManager.hpp:144
std::map< WareParamKey_t, WareParamValue_t > WareParams_t
Definition: TypeDefs.hpp:130
void setProjectDescription(const std::string &Description)
Definition: RunContextManager.hpp:193
void setProfiling(bool Enabled)
Definition: RunContextManager.hpp:150
bool isClearOutputDir() const
Definition: RunContextManager.hpp:141
bool isProfiling() const
Definition: RunContextManager.hpp:147
void setProjectName(const std::string &Name)
Definition: RunContextManager.hpp:187
void setWaresMaxNumThreads(unsigned int Num)
Definition: RunContextManager.hpp:168
bool isValuesBufferUserSize() const
Definition: RunContextManager.hpp:162
std::string getInputDir() const
Definition: RunContextManager.hpp:123
unsigned int getValuesBufferUserSize() const
Definition: RunContextManager.hpp:153
std::string getOutputDir() const
Definition: RunContextManager.hpp:131
std::string getProjectDescription() const
Definition: RunContextManager.hpp:190
void setProjectCreationDateAsNow()
Definition: RunContextManager.hpp:208
std::string getProjectLastModDate() const
Definition: RunContextManager.hpp:211
#define OPENFLUID_API
Definition: dllexport.hpp:87
void setProjectAuthors(const std::string &Authors)
Definition: RunContextManager.hpp:199
void unsetValuesBufferUserSize()
Definition: RunContextManager.hpp:159
const openfluid::core::MapValue & getWaresEnvironment() const
Definition: RunContextManager.hpp:176
void setProjectLastModDate(const std::string &LastModDate)
Definition: RunContextManager.hpp:214
void setValuesBufferUserSize(unsigned int Size)
Definition: RunContextManager.hpp:156
std::string getInputFullPath(const std::string &Filename) const
Definition: RunContextManager.hpp:126
bool isProjectOpen() const
Definition: RunContextManager.hpp:229
std::string getProjectAuthors() const
Definition: RunContextManager.hpp:196
Definition: RunContextManager.hpp:61
unsigned int getWaresMaxNumThreads() const
Definition: RunContextManager.hpp:165
std::string getProjectCreationDate() const
Definition: RunContextManager.hpp:202
bool isProjectIncrementalOutputDir() const
Definition: RunContextManager.hpp:217
void setProjectCreationDate(const std::string &CreationDate)
Definition: RunContextManager.hpp:205
#define OPENFLUID_SINGLETON_DEFINITION(T)
Definition: SingletonMacros.hpp:78
openfluid::core::MapValue & extraProperties()
Definition: RunContextManager.hpp:173
std::string getOutputFullPath(const std::string &Filename) const
Definition: RunContextManager.hpp:134
Definition: MapValue.hpp:134
std::string getProjectName() const
Definition: RunContextManager.hpp:184
void setProjectIncrementalOutputDir(const bool Inc)
Definition: RunContextManager.hpp:220