Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/strongTurret/src/libraries/core/PathConfig.h @ 10199

Last change on this file since 10199 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
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 external data files as boost::filesystem::path
88            static const boost::filesystem::path& getExternalDataPath()
89                { return getInstance().externalDataPath_; }
90            //! Returns the path to the config files as boost::filesystem::path
91            static const boost::filesystem::path& getConfigPath()
92                { return getInstance().configPath_; }
93            //! Returns the path to the log files as boost::filesystem::path
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();
104            //! Returns the path to the data files as std::string
105            static std::string getDataPathString();
106            //! Returns the path to the external data files as std::string
107            static std::string getExternalDataPathString();
108            //! Returns the path to the config files as std::string
109            static std::string getConfigPathString(); //tolua_export
110            //! Returns the path to the log files as std::string
111            static std::string getLogPathString();
112            //! Returns the path to the modules as std::string
113            static std::string getModulePathString();
114
115            //! Return true for runs in the build directory (not installed)
116            static bool buildDirectoryRun() { return getInstance().bBuildDirectoryRun_; }
117
118        private:
119            PathConfig(const PathConfig&); //!< Don't use (undefined symbol)
120
121            /**
122            @brief
123                Sets config, log and media path and creates the folders if necessary.
124            @throws
125                GeneralException
126            */
127            void setConfigurablePaths();
128            //! Returns a list with all modules declared by a *.module file in the module folder.
129            std::vector<std::string> getModulePaths();
130
131            //! Path to the parent directory of the ones above if program was installed with relative paths
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
139
140            bool                     bBuildDirectoryRun_;    //!< True for runs in the build directory (not installed)
141            static PathConfig* singletonPtr_s;
142    }; //tolua_export
143} //tolua_export
144
145#endif /* _PathConfig_H__ */
Note: See TracBrowser for help on using the repository browser.