~ubuntu-branches/ubuntu/precise/openwalnut/precise

« back to all changes in this revision

Viewing changes to src/core/common/WPathHelper.h

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Eichelbaum
  • Date: 2011-06-21 10:26:54 UTC
  • Revision ID: james.westby@ubuntu.com-20110621102654-rq0zf436q949biih
Tags: upstream-1.2.5
ImportĀ upstreamĀ versionĀ 1.2.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//---------------------------------------------------------------------------
 
2
//
 
3
// Project: OpenWalnut ( http://www.openwalnut.org )
 
4
//
 
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
 
6
// For more information see http://www.openwalnut.org/copying
 
7
//
 
8
// This file is part of OpenWalnut.
 
9
//
 
10
// OpenWalnut is free software: you can redistribute it and/or modify
 
11
// it under the terms of the GNU Lesser General Public License as published by
 
12
// the Free Software Foundation, either version 3 of the License, or
 
13
// (at your option) any later version.
 
14
//
 
15
// OpenWalnut is distributed in the hope that it will be useful,
 
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
// GNU Lesser General Public License for more details.
 
19
//
 
20
// You should have received a copy of the GNU Lesser General Public License
 
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
 
22
//
 
23
//---------------------------------------------------------------------------
 
24
 
 
25
#ifndef WPATHHELPER_H
 
26
#define WPATHHELPER_H
 
27
 
 
28
#include <vector>
 
29
 
 
30
// Use filesystem version 2 for compatibility with newer boost versions.
 
31
#ifndef BOOST_FILESYSTEM_VERSION
 
32
    #define BOOST_FILESYSTEM_VERSION 2
 
33
#endif
 
34
#include <boost/filesystem.hpp>
 
35
#include <boost/shared_ptr.hpp>
 
36
 
 
37
#include "WExportCommon.h"
 
38
 
 
39
/**
 
40
 * Singleton class helping to find files and paths. It is a useful to to search for resources and the central place to "hardcode" relative paths.
 
41
 * It contains global paths only. Modules have their OWN local paths.
 
42
 */
 
43
class OWCOMMON_EXPORT WPathHelper // NOLINT
 
44
{
 
45
public:
 
46
 
 
47
    /**
 
48
     * Destructor.
 
49
     */
 
50
    virtual ~WPathHelper();
 
51
 
 
52
    /**
 
53
     * Returns instance of the path helper. If it does not exists, it will be created.
 
54
     *
 
55
     * \return the running path helper instance.
 
56
     */
 
57
    static boost::shared_ptr< WPathHelper > getPathHelper();
 
58
 
 
59
    /**
 
60
     * Set the current application path. This should be called only once.
 
61
     *
 
62
     * \param appPath the application path
 
63
     */
 
64
    void setAppPath( boost::filesystem::path appPath );
 
65
 
 
66
    /**
 
67
     * The path where the binary file resides in. This is for example /usr/bin.
 
68
     *
 
69
     * \return the application path.
 
70
     */
 
71
    static boost::filesystem::path getAppPath();
 
72
 
 
73
    /**
 
74
     * The path where font files reside in.
 
75
     *
 
76
     * \return the font path.
 
77
     */
 
78
    static boost::filesystem::path getFontPath();
 
79
 
 
80
    /**
 
81
     * Paths to all known fonts.
 
82
     */
 
83
    typedef struct
 
84
    {
 
85
        /**
 
86
         * The default font to use in most cases.
 
87
         */
 
88
        boost::filesystem::path Default;
 
89
 
 
90
        /**
 
91
         * The Regular font (not bold, not italic)
 
92
         */
 
93
        boost::filesystem::path Regular;
 
94
 
 
95
        /**
 
96
         * Italic font.
 
97
         */
 
98
        boost::filesystem::path Italic;
 
99
 
 
100
        /**
 
101
         * Bold font.
 
102
         */
 
103
        boost::filesystem::path Bold;
 
104
    }
 
105
    Fonts;
 
106
 
 
107
    /**
 
108
     * The paths to all fonts supported.
 
109
     *
 
110
     * \return the file paths to all fonts
 
111
     */
 
112
    static Fonts getAllFonts();
 
113
 
 
114
    /**
 
115
     * The path to the global shaders. Modules usually have their own local shader directory.
 
116
     *
 
117
     * \return global shader path.
 
118
     */
 
119
    static boost::filesystem::path getShaderPath();
 
120
 
 
121
    /**
 
122
     * The path to the globally installed modules. This does not respect any environment variables or config options! Use this only to search
 
123
     * global modules. To get a list of all module search paths, including user defined ones, use getAllModulePaths().
 
124
     *
 
125
     * \return path to globally installed modules.
 
126
     */
 
127
    static boost::filesystem::path getModulePath();
 
128
 
 
129
    /**
 
130
     * This returns a list of search paths for modules. This list is defined by the environment variable "OW_MODULE_PATH". All of these
 
131
     * directories CAN contain modules. On startup, they get searched in the specified order.
 
132
     *
 
133
     * \return list of search paths for modules
 
134
     */
 
135
    static std::vector< boost::filesystem::path > getAllModulePaths();
 
136
 
 
137
    /**
 
138
     * The path to the OW libs. You normally should not need this.
 
139
     *
 
140
     * \return the path to the libs.
 
141
     */
 
142
    static boost::filesystem::path getLibPath();
 
143
 
 
144
    /**
 
145
     * The path where shared files reside in.
 
146
     *
 
147
     * \return the shared files path.
 
148
     */
 
149
    static boost::filesystem::path getSharePath();
 
150
 
 
151
    /**
 
152
     * The path where the doc files reside in.
 
153
     *
 
154
     * \return the doc file path.
 
155
     */
 
156
    static boost::filesystem::path getDocPath();
 
157
 
 
158
    /**
 
159
     * The path where the config files reside in.
 
160
     *
 
161
     * \return the config file path.
 
162
     */
 
163
    static boost::filesystem::path getConfigPath();
 
164
 
 
165
protected:
 
166
 
 
167
    /**
 
168
     * Constructors are protected because this is a Singleton.
 
169
     */
 
170
    WPathHelper();
 
171
 
 
172
private:
 
173
 
 
174
    /**
 
175
     * Application path. NOT the path of the binary. The application path is the directory in which the binary is placed.
 
176
     * The binary path is m_appPath+"/openwalnut".
 
177
     */
 
178
    boost::filesystem::path m_appPath;
 
179
 
 
180
    /**
 
181
     * The path where all the shared files reside in.
 
182
     */
 
183
    boost::filesystem::path m_sharePath;
 
184
 
 
185
    /**
 
186
     * The path where all the documentation files reside in.
 
187
     */
 
188
    boost::filesystem::path m_docPath;
 
189
 
 
190
    /**
 
191
     * The path where all the config files reside in.
 
192
     */
 
193
    boost::filesystem::path m_configPath;
 
194
 
 
195
    /**
 
196
     * The path to the globally installed modules.
 
197
     */
 
198
    boost::filesystem::path m_modulePath;
 
199
 
 
200
    /**
 
201
     * The path to the OW libs.
 
202
     */
 
203
    boost::filesystem::path m_libPath;
 
204
 
 
205
    /**
 
206
     * Singleton instance of WPathHelper.
 
207
     */
 
208
    static boost::shared_ptr< WPathHelper > m_instance;
 
209
};
 
210
 
 
211
#endif  // WPATHHELPER_H
 
212