MarketPackage.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  @file MarketPackage.hpp
35 
36  @author Jean-Christophe FABRE <jean-christophe.fabre@supagro.inra.fr>
37  */
38 
39 
40 #ifndef __OPENFLUID_MARKET_MARKETPACKAGE_HPP__
41 #define __OPENFLUID_MARKET_MARKETPACKAGE_HPP__
42 
43 
44 #include <openfluid/dllexport.hpp>
47 
48 
49 namespace openfluid { namespace market {
50 
51 
53 {
54  protected:
55 
56  static const std::string BUILDS_SUBDIR;
57 
58  static const std::string DLOADS_SUBDIR;
59 
60  static const std::string LOG_FILENAME;
61 
62 
63  /*
64  * Temporary dir for openfluid-market
65  */
66  static std::string m_TempDir;
67 
68  /**
69  * Temporary dir for building packages
70  */
71  static std::string m_TempBuildsDir;
72 
73  /**
74  * Temporary dir for downloaded packages
75  */
76  static std::string m_TempDownloadsDir;
77 
78  /**
79  * Market-bag dir for simulators
80  */
81  static std::string m_MarketBagSimulatorDir;
82 
83  /**
84  * Market-bag dir for observers
85  */
86  static std::string m_MarketBagObserverDir;
87 
88  /**
89  * Market-bag dir for builder extensions
90  */
91  static std::string m_MarketBagBuilderextDir;
92 
93  /**
94  * Market-bag dir for datasets
95  */
96  static std::string m_MarketBagDatasetDir;
97 
98  /**
99  * Market-bag subdir for binary packages of current type
100  */
101  static std::string m_MarketBagBinSubDir;
102 
103  /**
104  * Market-bag subdir for source packages of current type
105  */
106  static std::string m_MarketBagSrcSubDir;
107 
108  /**
109  * Common build options for simulators
110  */
111  static std::string m_SimulatorBuildConfigOptions;
112 
113  /**
114  * Common build options for observers
115  */
116  static std::string m_ObserverBuildConfigOptions;
117 
118  /**
119  * Common build options for builder extensions
120  */
121  static std::string m_BuilderextBuildConfigOptions;
122 
123  static std::string m_LogFile;
124 
125  static bool m_IsLogEnabled;
126 
127  static bool m_Initialized;
128 
129 
130 
132 
133  std::string m_PackageURL;
134 
135  std::string m_PackageFilename;
136 
137  std::string m_PackageDest;
138 
140 
141  static void resetLogFile();
142 
143  static void appendToLogFile(const std::string& PackageName,
144  const PackageInfo::PackageType& Type,
145  const std::string& Action,
146  const std::string& Str);
147 
148  static void appendToLogFile(const std::string& Str);
149 
150 
151  public:
152 
153  MarketPackage(const openfluid::ware::WareID_t& ID, const std::string& PackageURL);
154 
155  virtual ~MarketPackage();
156 
157  static void initialize(bool EnableLog);
158 
159  /**
160  Set directory paths attributes with paths passed as parameter
161  */
162  static void setWorksDirs(const std::string& TempDir, const std::string& MarketBagSimulatorDir,
163  const std::string& MarketBagObserverDir, const std::string& MarketBagBuilderextDir,
164  const std::string& MarketBagDatasetDir, const std::string& MarketBagBinSubDir,
165  const std::string& MarketBagSrcSubDir);
166 
167  static std::string getMarketBagSimulatorDir() { return m_MarketBagSimulatorDir; };
168 
169  static std::string getMarketBagObserverDir() { return m_MarketBagObserverDir; };
170 
171  static std::string getMarketBagBuilderextDir() { return m_MarketBagBuilderextDir; };
172 
173  static std::string getMarketBagDatasetDir() { return m_MarketBagDatasetDir; };
174 
175  static std::string getMarketBagBinSubDir() { return m_MarketBagBinSubDir; };
176 
177  static std::string getMarketBagSrcSubDir() { return m_MarketBagSrcSubDir; };
178 
179  static std::string getTempDir() { return m_TempDir; };
180 
181  static std::string getTempBuildsDir() { return m_TempBuildsDir; };
182 
183  static std::string getTempDownloadsDir() { return m_TempDownloadsDir; };
184 
185  static std::string getLogFile() { return m_LogFile; };
186 
187  /**
188  @return build options of package type passed as parameter
189  @param Type of options
190  */
191  static std::string getCommonBuildOptions(const PackageInfo::PackageType& Type);
192 
193  /**
194  Sets build options of package type passed as parameter with BuildOptions
195  @param Type of options
196  @param BuildOptions options to store
197  */
198  static void setCommonBuildOptions(const PackageInfo::PackageType& Type, const std::string& BuildOptions);
199 
200  /**
201  Adds BuildOptions to options of package type
202  @return Common build options of package type with BuildOptions
203  @param Type of package
204  @param BuildOptions to add
205  */
206  static std::string composeFullBuildOptions(const PackageInfo::PackageType& Type, const std::string& BuildOptions);
207 
208  openfluid::ware::WareID_t getID() const { return m_ID; };
209 
210  virtual MetaPackageInfo::SelectionType getFormat() const = 0;
211 
212 
213  /**
214  @return the market-bag path directory for the package type class
215  */
216  virtual std::string getInstallPath() const = 0;
217 
218  /**
219  @return type of current package
220  */
221  virtual PackageInfo::PackageType getPackageType() const = 0;
222 
223  virtual void process() = 0;
224 
225  void download();
226 
227 
228 };
229 
230 
231 
232 
233 } } // namespaces
234 
235 
236 #endif /* __OPENFLUID_MARKET_MARKETPACKAGE_HPP__ */
static std::string getMarketBagSrcSubDir()
Definition: MarketPackage.hpp:177
static std::string getTempBuildsDir()
Definition: MarketPackage.hpp:181
static std::string m_SimulatorBuildConfigOptions
Definition: MarketPackage.hpp:111
static const std::string DLOADS_SUBDIR
Definition: MarketPackage.hpp:58
SelectionType
Definition: MarketInfos.hpp:128
static std::string getTempDownloadsDir()
Definition: MarketPackage.hpp:183
PackageType
Definition: MarketInfos.hpp:93
static std::string m_MarketBagBinSubDir
Definition: MarketPackage.hpp:101
std::string WareID_t
Definition: TypeDefs.hpp:50
bool m_Downloaded
Definition: MarketPackage.hpp:139
static std::string getMarketBagBuilderextDir()
Definition: MarketPackage.hpp:171
std::string m_PackageDest
Definition: MarketPackage.hpp:137
static bool m_IsLogEnabled
Definition: MarketPackage.hpp:125
std::string m_PackageURL
Definition: MarketPackage.hpp:133
static std::string m_MarketBagSrcSubDir
Definition: MarketPackage.hpp:106
static std::string getLogFile()
Definition: MarketPackage.hpp:185
static std::string getMarketBagObserverDir()
Definition: MarketPackage.hpp:169
static std::string m_TempDir
Definition: MarketPackage.hpp:66
static std::string m_MarketBagBuilderextDir
Definition: MarketPackage.hpp:91
static std::string m_MarketBagSimulatorDir
Definition: MarketPackage.hpp:81
static std::string m_TempDownloadsDir
Definition: MarketPackage.hpp:76
static std::string m_MarketBagObserverDir
Definition: MarketPackage.hpp:86
openfluid::ware::WareID_t getID() const
Definition: MarketPackage.hpp:208
std::string m_PackageFilename
Definition: MarketPackage.hpp:135
static std::string m_LogFile
Definition: MarketPackage.hpp:123
static std::string getMarketBagSimulatorDir()
Definition: MarketPackage.hpp:167
static std::string getMarketBagBinSubDir()
Definition: MarketPackage.hpp:175
Definition: ApplicationException.hpp:47
static const std::string BUILDS_SUBDIR
Definition: MarketPackage.hpp:56
#define OPENFLUID_API
Definition: dllexport.hpp:87
static std::string m_MarketBagDatasetDir
Definition: MarketPackage.hpp:96
static std::string getTempDir()
Definition: MarketPackage.hpp:179
static bool m_Initialized
Definition: MarketPackage.hpp:127
static std::string m_TempBuildsDir
Definition: MarketPackage.hpp:71
static std::string m_ObserverBuildConfigOptions
Definition: MarketPackage.hpp:116
static std::string getMarketBagDatasetDir()
Definition: MarketPackage.hpp:173
openfluid::ware::WareID_t m_ID
Definition: MarketPackage.hpp:131
static const std::string LOG_FILENAME
Definition: MarketPackage.hpp:60
Definition: MarketPackage.hpp:52
static std::string m_BuilderextBuildConfigOptions
Definition: MarketPackage.hpp:121