Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/sound5/src/libraries/core/Resource.h @ 8086

Last change on this file since 8086 was 6417, checked in by rgrieder, 15 years ago

Merged presentation2 branch back to trunk.
Major new features:

  • Actual GUI with settings, etc.
  • Improved space ship steering (human interaction)
  • Rocket fire and more particle effects
  • Advanced sound framework
  • Property svn:eol-style set to native
File size: 4.4 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#include <OgreStringVector.h>
37
38namespace orxonox
39{
40    // Import the Ogre::DataStreamList
41    using Ogre::DataStreamList;
42    using Ogre::DataStreamListPtr;
43    using Ogre::StringVector;
44    using Ogre::StringVectorPtr;
45
46    //! Stores basic information about a Resource from Ogre
47    struct ResourceInfo
48    {
49        //! The file's fully qualified name
50        std::string filename;
51        //! Path name; separated by '/' and ending with '/'
52        std::string path;
53        //! Base filename
54        std::string basename;
55        //! Resource group the file is in
56        std::string group;
57        //! Uncompressed size
58        size_t size;
59    };
60
61    /** Provides simple functions to easily access the Ogre::ResourceGroupManager.
62        The wrapper functions also avoid having to deal with resource groups.
63    */
64    class _CoreExport Resource
65    {
66        // Docs by Ogre::ResourceGroupManager.h
67    public:
68        /**
69        @brief
70            Open a single resource by name and return a DataStream
71            pointing at the source of the data.
72        @param name
73            The name of the resource to locate.
74            Even if resource locations are added recursively, you
75            must provide a fully qualified name to this method.
76        @return
77            Shared pointer to data stream containing the data. Will be
78            destroyed automatically when no longer referenced.
79        */
80        static DataStreamPtr open(const std::string& name);
81
82        //! Similar to open(string, string, bool), but with a fileInfo struct
83        static DataStreamPtr open(shared_ptr<ResourceInfo> fileInfo)
84        {
85            return open(fileInfo->filename);
86        }
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        @return
98            Shared pointer to a data stream list , will be
99            destroyed automatically when no longer referenced
100        */
101        static DataStreamListPtr openMulti(const std::string& pattern);
102
103        /**
104            Find out if the named file exists.
105        @param filename
106            Fully qualified name of the file to test for
107        */
108        static bool exists(const std::string& name);
109
110        /**
111            Get struct with information about path and size.
112        @param filename
113            Fully qualified name of the file to test for
114        */
115        static shared_ptr<ResourceInfo> getInfo(const std::string& name);
116
117        /**
118            Retrieves a list with all resources matching a certain pattern.
119        @param pattern
120            The pattern to look for. If resource locations have been
121            added recursively, subdirectories will be searched too so this
122            does not need to be fully qualified.
123        */
124        static StringVectorPtr findResourceNames(const std::string& pattern);
125
126        //! Name of the default resource group (usually "General")
127        static std::string DEFAULT_GROUP;
128
129    private:
130        Resource();
131        ~Resource();
132        Resource(const Resource& instance);
133    };
134}
135
136#endif /* _Core_Resource_H__ */
Note: See TracBrowser for help on using the repository browser.