Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/core/ConfigurablePaths.h @ 11993

Last change on this file since 11993 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.0 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 _ConfigurablePaths_H__
35#define _ConfigurablePaths_H__
36
37#include "CorePrereqs.h"
38
39#include <string>
40#include "util/Singleton.h"
41
42//tolua_begin
43namespace orxonox
44{
45//tolua_end
46    /**
47    @brief
48        The ConfigurablePaths class is a singleton used to configure different paths.
49    @details
50        The class provides information about the data, config, and log path.
51    @remarks
52        Not all paths are always available:
53        - externalData only for development builds in the build tree
54    */
55    class _CoreExport ConfigurablePaths //tolua_export
56        : public Singleton<ConfigurablePaths>
57    { //tolua_export
58        friend class Singleton<ConfigurablePaths>;
59
60        public:
61            ConfigurablePaths();
62            ~ConfigurablePaths();
63
64            //! Returns the path to the data files as boost::filesystem::path
65            static const boost::filesystem::path& getDataPath()
66                { return getInstance().dataPath_; }
67            //! Returns the path to the external data files as boost::filesystem::path
68            static const boost::filesystem::path& getExternalDataPath()
69                { return getInstance().externalDataPath_; }
70            //! Returns the path to the config files as boost::filesystem::path
71            static const boost::filesystem::path& getConfigPath()
72                { return getInstance().configPath_; }
73            //! Returns the path to the log files as boost::filesystem::path
74            static const boost::filesystem::path& getLogPath()
75                { return getInstance().logPath_; }
76
77            //! Returns the path to the data files as std::string
78            static std::string getDataPathString();
79            //! Returns the path to the external data files as std::string
80            static std::string getExternalDataPathString();
81            //! Returns the path to the config files as std::string
82            static std::string getConfigPathString(); //tolua_export
83            //! Returns the path to the log files as std::string
84            static std::string getLogPathString();
85
86            /**
87            @brief
88                Sets config, log and media path and creates the folders if necessary.
89            @throws
90                GeneralException
91            */
92            void setConfigurablePaths(const ApplicationPaths& applicationPaths);
93
94        private:
95            // non-copyable:
96            ConfigurablePaths(const ConfigurablePaths&) = delete;
97            ConfigurablePaths& operator=(const ConfigurablePaths&) = delete;
98
99            boost::filesystem::path& dataPath_;              //!< Path to the data files folder
100            boost::filesystem::path& externalDataPath_;      //!< Path to the external data files folder
101            boost::filesystem::path& configPath_;            //!< Path to the config files folder
102            boost::filesystem::path& logPath_;               //!< Path to the log files folder
103
104            static ConfigurablePaths* singletonPtr_s;
105    }; //tolua_export
106} //tolua_export
107
108#endif /* _ConfigurablePaths_H__ */
Note: See TracBrowser for help on using the repository browser.