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