Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/core/Resource.h @ 11663

Last change on this file since 11663 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.8 KB
RevLine 
[5653]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
[7401]29/**
30    @defgroup Resources Resources
31    @ingroup Management
32*/
33
34/**
35    @file
36    @ingroup Management Resources
37*/
38
[5653]39#ifndef _Core_Resource_H__
40#define _Core_Resource_H__
41
42#include "CorePrereqs.h"
43
[11071]44#include <memory>
45
[5653]46#include <OgreDataStream.h>
[6417]47#include <OgreStringVector.h>
[5653]48
49namespace orxonox
50{
51    // Import the Ogre::DataStreamList
52    using Ogre::DataStreamList;
53    using Ogre::DataStreamListPtr;
[6417]54    using Ogre::StringVector;
55    using Ogre::StringVectorPtr;
[5653]56
57    //! Stores basic information about a Resource from Ogre
58    struct ResourceInfo
59    {
60        //! The file's fully qualified name
61        std::string filename;
62        //! Path name; separated by '/' and ending with '/'
63        std::string path;
64        //! Base filename
65        std::string basename;
66        //! Resource group the file is in
67        std::string group;
68        //! Uncompressed size
69        size_t size;
[6746]70        //! Absolute file path ("" for files not on filesystem)
71        std::string fileSystemPath;
[5653]72    };
73
[6417]74    /** Provides simple functions to easily access the Ogre::ResourceGroupManager.
75        The wrapper functions also avoid having to deal with resource groups.
[5653]76    */
77    class _CoreExport Resource
78    {
79        // Docs by Ogre::ResourceGroupManager.h
80    public:
[5929]81        /**
[5653]82        @brief
83            Open a single resource by name and return a DataStream
84            pointing at the source of the data.
85        @param name
86            The name of the resource to locate.
87            Even if resource locations are added recursively, you
88            must provide a fully qualified name to this method.
89        @return
90            Shared pointer to data stream containing the data. Will be
91            destroyed automatically when no longer referenced.
[5929]92        */
[6417]93        static DataStreamPtr open(const std::string& name);
[5653]94
[6417]95        //! Similar to open(string, string, bool), but with a fileInfo struct
[11071]96        static DataStreamPtr open(std::shared_ptr<ResourceInfo> fileInfo)
[6417]97        {
98            return open(fileInfo->filename);
99        }
100
[5929]101        /**
[5653]102        @brief
103            Open all resources matching a given pattern (which can contain
[6417]104            the character '*' as a wildcard), and return a collection of
[5653]105            DataStream objects on them.
106        @param pattern
107            The pattern to look for. If resource locations have been
108            added recursively, subdirectories will be searched too so this
109            does not need to be fully qualified.
110        @return
111            Shared pointer to a data stream list , will be
112            destroyed automatically when no longer referenced
[5929]113        */
[6417]114        static DataStreamListPtr openMulti(const std::string& pattern);
[5653]115
116        /**
[6417]117            Find out if the named file exists.
[7401]118        @param name
[5653]119            Fully qualified name of the file to test for
120        */
[6417]121        static bool exists(const std::string& name);
[5653]122
123        /**
[6417]124            Get struct with information about path and size.
[7401]125        @param name
[5653]126            Fully qualified name of the file to test for
127        */
[11071]128        static std::shared_ptr<ResourceInfo> getInfo(const std::string& name);
[5653]129
[6417]130        /**
131            Retrieves a list with all resources matching a certain pattern.
132        @param pattern
133            The pattern to look for. If resource locations have been
134            added recursively, subdirectories will be searched too so this
135            does not need to be fully qualified.
136        */
137        static StringVectorPtr findResourceNames(const std::string& pattern);
138
[5653]139        //! Name of the default resource group (usually "General")
[8351]140        static const std::string& getDefaultResourceGroup();
[5653]141
142    private:
[11071]143        // static class, no instances allowed:
144        Resource() = delete;
145        Resource(const Resource&) = delete;
146        Resource& operator=(const Resource&) = delete;
147        ~Resource() = delete;
[5653]148    };
149}
150
151#endif /* _Core_Resource_H__ */
Note: See TracBrowser for help on using the repository browser.