Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6140 was 5929, checked in by rgrieder, 15 years ago

Merged core5 branch back to the trunk.
Key features include clean level unloading and an extended XML event system.

Two important notes:
Delete your keybindings.ini files! * or you will still get parser errors when loading the key bindings.
Delete build_dir/lib/modules/libgamestates.module! * or orxonox won't start.
Best thing to do is to delete the build folder ;)

  • Property svn:eol-style set to native
File size: 5.9 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
[5836]29#ifndef _PathConfig_H__
30#define _PathConfig_H__
[1505]31
32#include "CorePrereqs.h"
33
[5836]34#include <string>
[5865]35#include <vector>
[3370]36#include "util/Singleton.h"
[1505]37
38namespace orxonox
39{
[3196]40    /**
41    @brief
[5836]42        The PathConfig class is a singleton used to configure different paths.
[3196]43    @details
[5836]44        The class provides information about the data, config, log, executable,
45        root and module path.
[3196]46        It determines those by the use of platform specific functions.
[5836]47    @remarks
48        Not all paths are always available:
49        - root only when installed copyable
50        - externalData only for development builds in the build tree
[3196]51    */
[5836]52    class _CoreExport PathConfig : public Singleton<PathConfig>
[1505]53    {
[5836]54        friend class Singleton<PathConfig>;
55        friend class Core;
[3370]56
[1505]57        public:
[3196]58            /**
59            @brief
[5836]60                Retrievs the executable path and sets all hard coded fixed paths (currently only the module path)
61                Also checks for "orxonox_dev_build.keep_me" in the executable diretory.
62                If found it means that this is not an installed run, hence we
63                don't write the logs and config files to ~/.orxonox
64            @throw
[3196]65                GeneralException
66            */
[5836]67            PathConfig();
68            ~PathConfig();
[2896]69
[5836]70            //! Returns the path to the root folder as boost::filesystem::path
71            static const boost::filesystem::path& getRootPath()
72                { return getInstance().rootPath_; }
73            //! Returns the path to the executable folder as boost::filesystem::path
74            static const boost::filesystem::path& getExecutablePath()
75                { return getInstance().executablePath_; }
[5695]76            //! Returns the path to the data files as boost::filesystem::path
[5836]77            static const boost::filesystem::path& getDataPath()
78                { return getInstance().dataPath_; }
[5695]79            //! Returns the path to the external data files as boost::filesystem::path
[5836]80            static const boost::filesystem::path& getExternalDataPath()
81                { return getInstance().externalDataPath_; }
[3196]82            //! Returns the path to the config files as boost::filesystem::path
[5836]83            static const boost::filesystem::path& getConfigPath()
84                { return getInstance().configPath_; }
[3196]85            //! Returns the path to the log files as boost::filesystem::path
[5836]86            static const boost::filesystem::path& getLogPath()
87                { return getInstance().logPath_; }
88            //! Returns the path to the modules as boost::filesystem::path
89            static const boost::filesystem::path& getModulePath()
90                { return getInstance().modulePath_; }
91
92            //! Returns the path to the root folder as std::string
93            static std::string getRootPathString();
94            //! Returns the path to the executable folder as std::string
95            static std::string getExecutablePathString();
[3196]96            //! Returns the path to the data files as std::string
[5695]97            static std::string getDataPathString();
98            //! Returns the path to the external data files as std::string
99            static std::string getExternalDataPathString();
[3196]100            //! Returns the path to the config files as std::string
[2710]101            static std::string getConfigPathString();
[3196]102            //! Returns the path to the log files as std::string
[2710]103            static std::string getLogPathString();
[5836]104            //! Returns the path to the modules as std::string
105            static std::string getModulePathString();
[2710]106
[5836]107            //! Return trrue for runs in the build directory (not installed)
[3370]108            static bool isDevelopmentRun() { return getInstance().bDevRun_; }
109
[1505]110        private:
[5836]111            PathConfig(const PathConfig&); //!< Don't use (undefined symbol)
[2896]112
[5836]113            /**
114            @brief
115                Sets config, log and media path and creates the folders if necessary.
116            @throws
117                GeneralException
118            */
[5693]119            void setConfigurablePaths();
[5836]120            //! Returns a list with all modules declared by a *.module file in the module folder.
121            std::vector<std::string> getModulePaths();
[2896]122
[5836]123            //! Path to the parent directory of the ones above if program was installed with relativ paths
124            boost::filesystem::path& rootPath_;
125            boost::filesystem::path& executablePath_;        //!< Path to the executable
126            boost::filesystem::path& modulePath_;            //!< Path to the modules
127            boost::filesystem::path& dataPath_;              //!< Path to the data files folder
128            boost::filesystem::path& externalDataPath_;      //!< Path to the external data files folder
129            boost::filesystem::path& configPath_;            //!< Path to the config files folder
130            boost::filesystem::path& logPath_;               //!< Path to the log files folder
[2710]131
[5836]132            bool                     bDevRun_;               //!< True for runs in the build directory (not installed)
133            static PathConfig* singletonPtr_s;
[1505]134    };
135}
136
[5836]137#endif /* _PathConfig_H__ */
Note: See TracBrowser for help on using the repository browser.