Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/cpp11_v2/src/libraries/core/ApplicationPaths.h @ 10828

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

merged branch core7 back to trunk

  • Property svn:eol-style set to native
File size: 4.9 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/plugin 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 and the plugin paths)
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            //! Returns the path to the plugins as boost::filesystem::path
85            static const boost::filesystem::path& getPluginPath()
86                { return getInstance().pluginPath_; }
87
88            //! Returns the path to the root folder as std::string
89            static std::string getRootPathString();
90            //! Returns the path to the executable folder as std::string
91            static std::string getExecutablePathString();
92            //! Returns the path to the modules as std::string
93            static std::string getModulePathString();
94            //! Returns the path to the plugins as std::string
95            static std::string getPluginPathString();
96
97            //! Return true for runs in the build directory (not installed)
98            static bool buildDirectoryRun() { return getInstance().bBuildDirectoryRun_; }
99
100            //! Returns a list with all modules declared by a *.module file in the module folder.
101            std::vector<std::string> getModulePaths();
102            //! Returns a list with all plugins declared by a *.plugin file in the plugin folder.
103            std::vector<std::string> getPluginPaths();
104
105        private:
106            ApplicationPaths(const ApplicationPaths&); //!< Don't use (undefined symbol)
107
108            std::vector<std::string> getModuleOrPluginPaths(boost::filesystem::path& directory, const std::string& extension);
109
110            //! Path to the parent directory of the ones above if program was installed with relative paths
111            boost::filesystem::path& rootPath_;
112            boost::filesystem::path& executablePath_;        //!< Path to the executable
113            boost::filesystem::path& modulePath_;            //!< Path to the modules
114            boost::filesystem::path& pluginPath_;            //!< Path to the plugins
115
116            bool                     bBuildDirectoryRun_;    //!< True for runs in the build directory (not installed)
117            static ApplicationPaths* singletonPtr_s;
118    }; //tolua_export
119} //tolua_export
120
121#endif /* _ApplicationPaths_H__ */
Note: See TracBrowser for help on using the repository browser.