market/MarketPackage.hpp
Go to the documentation of this file.
00001 /*
00002 
00003   This file is part of OpenFLUID software
00004   Copyright(c) 2007, INRA - Montpellier SupAgro
00005 
00006 
00007  == GNU General Public License Usage ==
00008 
00009   OpenFLUID is free software: you can redistribute it and/or modify
00010   it under the terms of the GNU General Public License as published by
00011   the Free Software Foundation, either version 3 of the License, or
00012   (at your option) any later version.
00013 
00014   OpenFLUID is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017   GNU General Public License for more details.
00018 
00019   You should have received a copy of the GNU General Public License
00020   along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
00021 
00022 
00023  == Other Usage ==
00024 
00025   Other Usage means a use of OpenFLUID that is inconsistent with the GPL
00026   license, and requires a written agreement between You and INRA.
00027   Licensees for Other Usage of OpenFLUID may use this file in accordance
00028   with the terms contained in the written agreement between You and INRA.
00029   
00030 */
00031 
00032 
00033 /**
00034   \file MarketPackage.hpp
00035   \brief Header of ...
00036 
00037   \author Jean-Christophe FABRE <fabrejc@supagro.inra.fr>
00038  */
00039 
00040 
00041 #ifndef __MARKETPACKAGE_HPP__
00042 #define __MARKETPACKAGE_HPP__
00043 
00044 
00045 #include <openfluid/dllexport.hpp>
00046 #include <openfluid/base/RuntimeEnv.hpp>
00047 #include <openfluid/market/MarketInfos.hpp>
00048 #include <openfluid/tools/ExternalProgram.hpp>
00049 
00050 
00051 namespace openfluid { namespace market {
00052 
00053 
00054 class DLLEXPORT MarketPackage
00055 {
00056   protected:
00057 
00058     static const std::string BUILDS_SUBDIR;
00059 
00060     static const std::string DLOADS_SUBDIR;
00061 
00062     static const std::string LOG_FILENAME;
00063 
00064 
00065     /*
00066      * Temporary dir for openfluid-market
00067     */
00068     static std::string m_TempDir;
00069 
00070     /**
00071      * Temporary dir for building packages
00072     */
00073     static std::string m_TempBuildsDir;
00074 
00075     /**
00076      * Temporary dir for downloaded packages
00077     */
00078     static std::string m_TempDownloadsDir;
00079 
00080     /**
00081      * Market-bag dir for simulators
00082     */
00083     static std::string m_MarketBagSimulatorDir;
00084 
00085     /**
00086      * Market-bag dir for observers
00087     */
00088     static std::string m_MarketBagObserverDir;
00089 
00090     /**
00091      * Market-bag dir for builder extensions
00092     */
00093     static std::string m_MarketBagBuilderextDir;
00094 
00095     /**
00096      * Market-bag dir for datasets
00097     */
00098     static std::string m_MarketBagDatasetDir;
00099 
00100     /**
00101      * Market-bag subdir for binary packages of current type
00102     */
00103     static std::string m_MarketBagBinSubDir;
00104 
00105     /**
00106      * Market-bag subdir for source packages of current type
00107     */
00108     static std::string m_MarketBagSrcSubDir;
00109 
00110     static openfluid::tools::ExternalProgram m_CMakeProgram;
00111 
00112     /**
00113      * Common build options for simulators
00114     */
00115     static std::string m_SimulatorBuildConfigOptions;
00116 
00117     /**
00118      * Common build options for observers
00119     */
00120     static std::string m_ObserverBuildConfigOptions;
00121 
00122     /**
00123      * Common build options for builder extensions
00124     */
00125     static std::string m_BuilderextBuildConfigOptions;
00126 
00127     static std::string m_LogFile;
00128 
00129     static bool m_IsLogEnabled;
00130 
00131     static bool m_Initialized;
00132 
00133 
00134 
00135     openfluid::ware::WareID_t m_ID;
00136 
00137     std::string m_PackageURL;
00138 
00139     std::string m_PackageFilename;
00140 
00141     std::string m_PackageDest;
00142 
00143     bool m_Downloaded;
00144 
00145     static void resetLogFile();
00146 
00147     static void appendToLogFile(const std::string& PackageName,
00148         const PackageInfo::PackageType& Type,
00149         const std::string& Action,
00150         const std::string& Str);
00151 
00152     static void appendToLogFile(const std::string& Str);
00153 
00154 
00155   public:
00156 
00157     MarketPackage(const openfluid::ware::WareID_t& ID, const std::string& PackageURL);
00158 
00159     virtual ~MarketPackage();
00160 
00161     static void initialize(bool EnableLog);
00162 
00163     /**
00164      Set directory paths attributes with paths passed as parameter
00165     */
00166     static void setWorksDirs(const std::string& TempDir, const std::string& MarketBagSimulatorDir,
00167                              const std::string& MarketBagObserverDir, const std::string& MarketBagBuilderextDir,
00168                              const std::string& MarketBagDatasetDir, const std::string& MarketBagBinSubDir,
00169                              const std::string& MarketBagSrcSubDir);
00170 
00171     static std::string getMarketBagSimulatorDir() { return m_MarketBagSimulatorDir; };
00172 
00173     static std::string getMarketBagObserverDir() { return m_MarketBagObserverDir; };
00174 
00175     static std::string getMarketBagBuilderextDir() { return m_MarketBagBuilderextDir; };
00176 
00177     static std::string getMarketBagDatasetDir() { return m_MarketBagDatasetDir; };
00178 
00179     static std::string getMarketBagBinSubDir() { return m_MarketBagBinSubDir; };
00180 
00181     static std::string getMarketBagSrcSubDir() { return m_MarketBagSrcSubDir; };
00182 
00183     static std::string getTempDir() { return m_TempDir; };
00184 
00185     static std::string getTempBuildsDir() { return m_TempBuildsDir; };
00186 
00187     static std::string getTempDownloadsDir() { return m_TempDownloadsDir; };
00188 
00189     static std::string getLogFile() { return m_LogFile; };
00190 
00191     /**
00192      @return build options of package type passed as parameter
00193      @param Type of options
00194     */
00195     static std::string getCommonBuildOptions(const PackageInfo::PackageType& Type);
00196 
00197     /**
00198      Sets build options of package type passed as parameter with BuildOptions
00199      @param Type of options
00200      @param BuildOptions options to store
00201     */
00202     static void setCommonBuildOptions(const PackageInfo::PackageType& Type, const std::string& BuildOptions);
00203 
00204     /**
00205      Adds BuildOptions to options of package type
00206      @return Common build options of package type with BuildOptions
00207      @param Type of package
00208      @param BuildOptions to add
00209     */
00210     static std::string composeFullBuildOptions(const PackageInfo::PackageType& Type, const std::string& BuildOptions);
00211 
00212     openfluid::ware::WareID_t getID() const { return m_ID; };
00213 
00214     virtual MetaPackageInfo::SelectionType getFormat() const = 0;
00215 
00216 
00217     /**
00218      @return the market-bag path directory for the package type class
00219     */
00220     virtual std::string getInstallPath() const = 0;
00221 
00222     /**
00223      @return type of current package
00224     */
00225     virtual PackageInfo::PackageType getPackageType() const = 0;
00226 
00227     virtual void process() = 0;
00228 
00229     void download();
00230 
00231 
00232 };
00233 
00234 
00235 
00236 
00237 } } // namespaces
00238 
00239 
00240 #endif /* __MARKETPACKAGE_HPP__ */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines