Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core7/src/libraries/core/ApplicationPaths.h @ 10509

Last change on this file since 10509 was 10509, checked in by landauf, 9 years ago

moved static application paths (root, executable, modules) into new class named ApplicationPaths
moved configurable data paths (data, log, config) into new class named ConfigurablePaths
removed PathConfig

  • Property svn:eol-style set to native
File size: 4.2 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 _ApplicationPaths_H__
35#define _ApplicationPaths_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 ApplicationPaths class is a singleton which provides static paths of the application.
50    @details
51        The class provides information about the executable, root and module 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 ApplicationPaths //tolua_export
58        : public Singleton<ApplicationPaths>
59    { //tolua_export
60        friend class Singleton<ApplicationPaths>;
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 directory.
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            ApplicationPaths();
73            ~ApplicationPaths();
74
75            //! Returns the path to the root folder as boost::filesystem::path
76            static const boost::filesystem::path& getRootPath()
77                { return getInstance().rootPath_; }
78            //! Returns the path to the executable folder as boost::filesystem::path
79            static const boost::filesystem::path& getExecutablePath()
80                { return getInstance().executablePath_; }
81            //! Returns the path to the modules as boost::filesystem::path
82            static const boost::filesystem::path& getModulePath()
83                { return getInstance().modulePath_; }
84
85            //! Returns the path to the root folder as std::string
86            static std::string getRootPathString();
87            //! Returns the path to the executable folder as std::string
88            static std::string getExecutablePathString();
89            //! Returns the path to the modules as std::string
90            static std::string getModulePathString();
91
92            //! Return true for runs in the build directory (not installed)
93            static bool buildDirectoryRun() { return getInstance().bBuildDirectoryRun_; }
94
95            //! Returns a list with all modules declared by a *.module file in the module folder.
96            std::vector<std::string> getModulePaths();
97
98        private:
99            ApplicationPaths(const ApplicationPaths&); //!< Don't use (undefined symbol)
100
101            //! Path to the parent directory of the ones above if program was installed with relative paths
102            boost::filesystem::path& rootPath_;
103            boost::filesystem::path& executablePath_;        //!< Path to the executable
104            boost::filesystem::path& modulePath_;            //!< Path to the modules
105
106            bool                     bBuildDirectoryRun_;    //!< True for runs in the build directory (not installed)
107            static ApplicationPaths* singletonPtr_s;
108    }; //tolua_export
109} //tolua_export
110
111#endif /* _ApplicationPaths_H__ */
Note: See TracBrowser for help on using the repository browser.