Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/core/ApplicationPaths.h @ 11539

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

merged branch cpp11_v3 back to trunk

  • Property svn:eol-style set to native
File size: 4.9 KB
RevLine 
[1505]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:
[2896]23 *      Reto Grieder
[1505]24 *   Co-authors:
[2896]25 *      ...
[1505]26 *
27 */
28
[7401]29/**
30    @file
31    @ingroup Management Resources
32*/
33
[10509]34#ifndef _ApplicationPaths_H__
35#define _ApplicationPaths_H__
[1505]36
37#include "CorePrereqs.h"
38
[5836]39#include <string>
[5865]40#include <vector>
[3370]41#include "util/Singleton.h"
[1505]42
[6417]43//tolua_begin
[1505]44namespace orxonox
45{
[6417]46//tolua_end
[3196]47    /**
48    @brief
[10509]49        The ApplicationPaths class is a singleton which provides static paths of the application.
[3196]50    @details
[10547]51        The class provides information about the executable, root and module/plugin path.
[3196]52        It determines those by the use of platform specific functions.
[5836]53    @remarks
54        Not all paths are always available:
55        - root only when installed copyable
[3196]56    */
[10509]57    class _CoreExport ApplicationPaths //tolua_export
58        : public Singleton<ApplicationPaths>
[6417]59    { //tolua_export
[10509]60        friend class Singleton<ApplicationPaths>;
[3370]61
[1505]62        public:
[3196]63            /**
64            @brief
[10547]65                Retrieves the executable path and sets all hard coded fixed paths (currently only the module and the plugin paths)
[10509]66                Also checks for "orxonox_dev_build.keep_me" in the executable directory.
[5836]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
[3196]70                GeneralException
71            */
[10509]72            ApplicationPaths();
73            ~ApplicationPaths();
[2896]74
[5836]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_; }
[10547]84            //! Returns the path to the plugins as boost::filesystem::path
85            static const boost::filesystem::path& getPluginPath()
86                { return getInstance().pluginPath_; }
[5836]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();
[10547]94            //! Returns the path to the plugins as std::string
95            static std::string getPluginPathString();
[2710]96
[8351]97            //! Return true for runs in the build directory (not installed)
[8366]98            static bool buildDirectoryRun() { return getInstance().bBuildDirectoryRun_; }
[3370]99
[5836]100            //! Returns a list with all modules declared by a *.module file in the module folder.
101            std::vector<std::string> getModulePaths();
[10547]102            //! Returns a list with all plugins declared by a *.plugin file in the plugin folder.
103            std::vector<std::string> getPluginPaths();
[2896]104
[10509]105        private:
[11071]106            // non-copyable:
107            ApplicationPaths(const ApplicationPaths&) = delete;
108            ApplicationPaths& operator=(const ApplicationPaths&) = delete;
[10509]109
[10547]110            std::vector<std::string> getModuleOrPluginPaths(boost::filesystem::path& directory, const std::string& extension);
111
[8366]112            //! Path to the parent directory of the ones above if program was installed with relative paths
[5836]113            boost::filesystem::path& rootPath_;
114            boost::filesystem::path& executablePath_;        //!< Path to the executable
115            boost::filesystem::path& modulePath_;            //!< Path to the modules
[10547]116            boost::filesystem::path& pluginPath_;            //!< Path to the plugins
[2710]117
[8366]118            bool                     bBuildDirectoryRun_;    //!< True for runs in the build directory (not installed)
[10509]119            static ApplicationPaths* singletonPtr_s;
[6417]120    }; //tolua_export
121} //tolua_export
[1505]122
[10509]123#endif /* _ApplicationPaths_H__ */
Note: See TracBrowser for help on using the repository browser.