Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/core/PathConfig.h @ 10256

Last change on this file since 10256 was 8366, checked in by rgrieder, 14 years ago

Renamed PathConfig::isDevelopmentRun() to PathConfig::buildDirectoryRun() because that fits better and there is no confusion with Core::inDevMode().
Also used isDevelopmentRun() as default value for Core::inDevMode() instead of ORXONOX_RELEASE.

  • Property svn:eol-style set to native
File size: 6.1 KB
RevLine 
[1505]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
[2896]23 *      Reto Grieder
[1505]24 *   Co-authors:
[2896]25 *      ...
[1505]26 *
27 */
28
[7401]29/**
30    @file
31    @ingroup Management Resources
32*/
33
[5836]34#ifndef _PathConfig_H__
35#define _PathConfig_H__
[1505]36
37#include "CorePrereqs.h"
38
[5836]39#include <string>
[5865]40#include <vector>
[3370]41#include "util/Singleton.h"
[1505]42
[6417]43//tolua_begin
[1505]44namespace orxonox
45{
[6417]46//tolua_end
[3196]47    /**
48    @brief
[5836]49        The PathConfig class is a singleton used to configure different paths.
[3196]50    @details
[5836]51        The class provides information about the data, config, log, executable,
52        root and module path.
[3196]53        It determines those by the use of platform specific functions.
[5836]54    @remarks
55        Not all paths are always available:
56        - root only when installed copyable
57        - externalData only for development builds in the build tree
[3196]58    */
[6417]59    class _CoreExport PathConfig //tolua_export
60        : public Singleton<PathConfig>
61    { //tolua_export
[5836]62        friend class Singleton<PathConfig>;
63        friend class Core;
[3370]64
[1505]65        public:
[3196]66            /**
67            @brief
[7427]68                Retrieves the executable path and sets all hard coded fixed paths (currently only the module path)
[5836]69                Also checks for "orxonox_dev_build.keep_me" in the executable diretory.
70                If found it means that this is not an installed run, hence we
71                don't write the logs and config files to ~/.orxonox
72            @throw
[3196]73                GeneralException
74            */
[5836]75            PathConfig();
76            ~PathConfig();
[2896]77
[5836]78            //! Returns the path to the root folder as boost::filesystem::path
79            static const boost::filesystem::path& getRootPath()
80                { return getInstance().rootPath_; }
81            //! Returns the path to the executable folder as boost::filesystem::path
82            static const boost::filesystem::path& getExecutablePath()
83                { return getInstance().executablePath_; }
[5695]84            //! Returns the path to the data files as boost::filesystem::path
[5836]85            static const boost::filesystem::path& getDataPath()
86                { return getInstance().dataPath_; }
[5695]87            //! Returns the path to the external data files as boost::filesystem::path
[5836]88            static const boost::filesystem::path& getExternalDataPath()
89                { return getInstance().externalDataPath_; }
[3196]90            //! Returns the path to the config files as boost::filesystem::path
[5836]91            static const boost::filesystem::path& getConfigPath()
92                { return getInstance().configPath_; }
[3196]93            //! Returns the path to the log files as boost::filesystem::path
[5836]94            static const boost::filesystem::path& getLogPath()
95                { return getInstance().logPath_; }
96            //! Returns the path to the modules as boost::filesystem::path
97            static const boost::filesystem::path& getModulePath()
98                { return getInstance().modulePath_; }
99
100            //! Returns the path to the root folder as std::string
101            static std::string getRootPathString();
102            //! Returns the path to the executable folder as std::string
103            static std::string getExecutablePathString();
[3196]104            //! Returns the path to the data files as std::string
[5695]105            static std::string getDataPathString();
106            //! Returns the path to the external data files as std::string
107            static std::string getExternalDataPathString();
[3196]108            //! Returns the path to the config files as std::string
[6417]109            static std::string getConfigPathString(); //tolua_export
[3196]110            //! Returns the path to the log files as std::string
[2710]111            static std::string getLogPathString();
[5836]112            //! Returns the path to the modules as std::string
113            static std::string getModulePathString();
[2710]114
[8351]115            //! Return true for runs in the build directory (not installed)
[8366]116            static bool buildDirectoryRun() { return getInstance().bBuildDirectoryRun_; }
[3370]117
[1505]118        private:
[5836]119            PathConfig(const PathConfig&); //!< Don't use (undefined symbol)
[2896]120
[5836]121            /**
122            @brief
123                Sets config, log and media path and creates the folders if necessary.
124            @throws
125                GeneralException
126            */
[5693]127            void setConfigurablePaths();
[5836]128            //! Returns a list with all modules declared by a *.module file in the module folder.
129            std::vector<std::string> getModulePaths();
[2896]130
[8366]131            //! Path to the parent directory of the ones above if program was installed with relative paths
[5836]132            boost::filesystem::path& rootPath_;
133            boost::filesystem::path& executablePath_;        //!< Path to the executable
134            boost::filesystem::path& modulePath_;            //!< Path to the modules
135            boost::filesystem::path& dataPath_;              //!< Path to the data files folder
136            boost::filesystem::path& externalDataPath_;      //!< Path to the external data files folder
137            boost::filesystem::path& configPath_;            //!< Path to the config files folder
138            boost::filesystem::path& logPath_;               //!< Path to the log files folder
[2710]139
[8366]140            bool                     bBuildDirectoryRun_;    //!< True for runs in the build directory (not installed)
[5836]141            static PathConfig* singletonPtr_s;
[6417]142    }; //tolua_export
143} //tolua_export
[1505]144
[5836]145#endif /* _PathConfig_H__ */
Note: See TracBrowser for help on using the repository browser.