Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 6868 was 6417, checked in by rgrieder, 15 years ago

Merged presentation2 branch back to trunk.
Major new features:

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