Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/presentation2/src/libraries/core/Resource.h @ 6171

Last change on this file since 6171 was 5929, checked in by rgrieder, 15 years ago

Merged core5 branch back to the trunk.
Key features include clean level unloading and an extended XML event system.

Two important notes:
Delete your keybindings.ini files! * or you will still get parser errors when loading the key bindings.
Delete build_dir/lib/modules/libgamestates.module! * or orxonox won't start.
Best thing to do is to delete the build folder ;)

  • Property svn:eol-style set to native
File size: 4.5 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#ifndef _Core_Resource_H__
30#define _Core_Resource_H__
31
32#include "CorePrereqs.h"
33
34#include <boost/shared_ptr.hpp>
35#include <OgreDataStream.h>
36
37namespace orxonox
38{
39    // Import the Ogre::DataStreamList
40    using Ogre::DataStreamList;
41    using Ogre::DataStreamListPtr;
42
43    //! Stores basic information about a Resource from Ogre
44    struct ResourceInfo
45    {
46        //! The file's fully qualified name
47        std::string filename;
48        //! Path name; separated by '/' and ending with '/'
49        std::string path;
50        //! Base filename
51        std::string basename;
52        //! Resource group the file is in
53        std::string group;
54        //! Uncompressed size
55        size_t size;
56    };
57
58    /**
59    @brief
60        Provides simple functions to easily access the Ogre::ResourceGroupManager
61    */
62    class _CoreExport Resource
63    {
64        // Docs by Ogre::ResourceGroupManager.h
65    public:
66        /**
67        @brief
68            Open a single resource by name and return a DataStream
69            pointing at the source of the data.
70        @param name
71            The name of the resource to locate.
72            Even if resource locations are added recursively, you
73            must provide a fully qualified name to this method.
74        @param groupName
75            The name of the resource group; this determines which
76            locations are searched.
77        @param searchGroupsIfNotFound
78            If true, if the resource is not found in
79            the group specified, other groups will be searched.
80        @return
81            Shared pointer to data stream containing the data. Will be
82            destroyed automatically when no longer referenced.
83        */
84        static DataStreamPtr open(const std::string& name,
85            const std::string& group = Resource::DEFAULT_GROUP,
86            bool bSearchGroupsIfNotFound = false);
87
88        /**
89        @brief
90            Open all resources matching a given pattern (which can contain
91            the character '*' as a wildcard), and return a collection of
92            DataStream objects on them.
93        @param pattern
94            The pattern to look for. If resource locations have been
95            added recursively, subdirectories will be searched too so this
96            does not need to be fully qualified.
97        @param groupName
98            The resource group; this determines which locations
99            are searched.
100        @return
101            Shared pointer to a data stream list , will be
102            destroyed automatically when no longer referenced
103        */
104        static DataStreamListPtr openMulti(const std::string& pattern, const std::string& group = Resource::DEFAULT_GROUP);
105
106        /**
107            Find out if the named file exists in a group.
108        @param filename
109            Fully qualified name of the file to test for
110        @param group
111            The name of the resource group
112        */
113        static bool exists(const std::string& name, const std::string& group = Resource::DEFAULT_GROUP);
114
115        /**
116            Get struct with information about group, path and size.
117        @param filename
118            Fully qualified name of the file to test for
119        @param group
120            The name of the resource group
121        */
122        static shared_ptr<ResourceInfo> getInfo(const std::string& name, const std::string& group = Resource::DEFAULT_GROUP);
123
124        //! Name of the default resource group (usually "General")
125        static std::string DEFAULT_GROUP;
126
127    private:
128        Resource();
129        ~Resource();
130        Resource(const Resource& instance);
131    };
132}
133
134#endif /* _Core_Resource_H__ */
Note: See TracBrowser for help on using the repository browser.