Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/TowerDefense_FS18/src/libraries/core/ApplicationPaths.h @ 11877

Last change on this file since 11877 was 11692, checked in by landauf, 7 years ago

with the latest CMake there are a lot of warnings about the usage of CMP0026. therefore the naming and content of the module/plugin-files had to be changed:
old: <library-filename>.module with content <target-name>
new: <target-name>.module with content <library-filename>
this seems to comply better with cmake and works equally well in c++ (with some small adjustments).
reference: https://cmake.org/cmake/help/v3.0/policy/CMP0026.html

  • Property svn:eol-style set to native
File size: 5.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 _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 map with all modules declared by a *.module file in the module folder; key = module-name, value = library-path (content of the file).
101            std::map<std::string, std::string> getModulePaths();
102            //! Returns a map with all plugins declared by a *.plugin file in the plugin folder; key = plugin-name, value = library-path (content of the file).
103            std::map<std::string, std::string> getPluginPaths();
104
105        private:
106            // non-copyable:
107            ApplicationPaths(const ApplicationPaths&) = delete;
108            ApplicationPaths& operator=(const ApplicationPaths&) = delete;
109
110            std::map<std::string, std::string> getModuleOrPluginPaths(boost::filesystem::path& directory, const std::string& extension);
111
112            //! Path to the parent directory of the ones above if program was installed with relative paths
113            boost::filesystem::path& rootPath_;
114            boost::filesystem::path& executablePath_;        //!< Path to the executable
115            boost::filesystem::path& modulePath_;            //!< Path to the modules
116            boost::filesystem::path& pluginPath_;            //!< Path to the plugins
117
118            bool                     bBuildDirectoryRun_;    //!< True for runs in the build directory (not installed)
119            static ApplicationPaths* singletonPtr_s;
120    }; //tolua_export
121} //tolua_export
122
123#endif /* _ApplicationPaths_H__ */
Note: See TracBrowser for help on using the repository browser.