Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/forks/sandbox_light/src/libraries/core/PathConfig.h @ 7908

Last change on this file since 7908 was 7908, checked in by rgrieder, 13 years ago

Stripped down trunk to form a new light sandbox.

  • Property svn:eol-style set to native
File size: 5.1 KB
Line 
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:
23 *      Reto Grieder
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30    @file
31    @ingroup Management Resources
32*/
33
34#ifndef _PathConfig_H__
35#define _PathConfig_H__
36
37#include "CorePrereqs.h"
38
39#include <string>
40#include <vector>
41#include "util/Singleton.h"
42
43//tolua_begin
44namespace orxonox
45{
46//tolua_end
47    /**
48    @brief
49        The PathConfig class is a singleton used to configure different paths.
50    @details
51        The class provides information about the data, config, log, executable,
52        root and module path.
53        It determines those by the use of platform specific functions.
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
58    */
59    class _CoreExport PathConfig //tolua_export
60        : public Singleton<PathConfig>
61    { //tolua_export
62        friend class Singleton<PathConfig>;
63        friend class Core;
64
65        public:
66            /**
67            @brief
68                Retrieves the executable path and sets all hard coded fixed paths (currently only the module path)
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
73                GeneralException
74            */
75            PathConfig();
76            ~PathConfig();
77
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_; }
84            //! Returns the path to the data files as boost::filesystem::path
85            static const boost::filesystem::path& getDataPath()
86                { return getInstance().dataPath_; }
87            //! Returns the path to the config files as boost::filesystem::path
88            static const boost::filesystem::path& getConfigPath()
89                { return getInstance().configPath_; }
90            //! Returns the path to the log files as boost::filesystem::path
91            static const boost::filesystem::path& getLogPath()
92                { return getInstance().logPath_; }
93
94            //! Returns the path to the root folder as std::string
95            static std::string getRootPathString();
96            //! Returns the path to the executable folder as std::string
97            static std::string getExecutablePathString();
98            //! Returns the path to the data files as std::string
99            static std::string getDataPathString();
100            //! Returns the path to the config files as std::string
101            static std::string getConfigPathString(); //tolua_export
102            //! Returns the path to the log files as std::string
103            static std::string getLogPathString();
104
105            //! Return trrue for runs in the build directory (not installed)
106            static bool isDevelopmentRun() { return getInstance().bDevRun_; }
107
108        private:
109            PathConfig(const PathConfig&); //!< Don't use (undefined symbol)
110
111            /**
112            @brief
113                Sets config, log and media path and creates the folders if necessary.
114            @throws
115                GeneralException
116            */
117            void setConfigurablePaths();
118
119            //! Path to the parent directory of the ones above if program was installed with relativ paths
120            boost::filesystem::path& rootPath_;
121            boost::filesystem::path& executablePath_;        //!< Path to the executable
122            boost::filesystem::path& dataPath_;              //!< Path to the data files folder
123            boost::filesystem::path& configPath_;            //!< Path to the config files folder
124            boost::filesystem::path& logPath_;               //!< Path to the log files folder
125
126            bool                     bDevRun_;               //!< True for runs in the build directory (not installed)
127            static PathConfig* singletonPtr_s;
128    }; //tolua_export
129} //tolua_export
130
131#endif /* _PathConfig_H__ */
Note: See TracBrowser for help on using the repository browser.