Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: sandbox_qt/src/libraries/core/PathConfig.h @ 7421

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

Basic stuff up and running for the Qt sandbox.
No GUI support yet.

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