Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/core/MemoryArchive.h @ 6497

Last change on this file since 6497 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: 3.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 _MemoryArchive_H__
30#define _MemoryArchive_H__
31
32#include "CorePrereqs.h"
33#include <OgrePrerequisites.h>
34
35#if OGRE_VERSION < 0x010600
36
37#include <map>
38#include <OgreArchive.h>
39#include <OgreArchiveFactory.h>
40#include <boost/shared_array.hpp>
41
42namespace orxonox
43{
44    /**
45    @brief
46        Provides a simple mechanism of 'memory mapped IO', but compatible for Ogre 1.4
47
48        Files are stored as shared_array<char> in a static map with the archive names
49        (imaging the different archives as resource locations). This map then contains
50        yet another map with the actual files.
51        If you want to know why we make such a fuss, contact GraphicsManager::upgradeToGraphics()
52        for more information.
53    */
54    class MemoryArchive : public Ogre::Archive
55    {
56    public:
57        MemoryArchive(const Ogre::String& name, const Ogre::String& archiveType) : Ogre::Archive(name, archiveType) { }
58        ~MemoryArchive() { }
59
60        bool isCaseSensitive(void) const { return true; }
61
62        void load();
63        void unload() { }
64
65        Ogre::DataStreamPtr open(const Ogre::String& filename) const;
66
67        Ogre::StringVectorPtr list(bool recursive = true, bool dirs = false);
68        Ogre::FileInfoListPtr listFileInfo(bool recursive = true, bool dirs = false);
69
70        Ogre::StringVectorPtr find(const Ogre::String& pattern, bool recursive = true,
71            bool dirs = false);
72        Ogre::FileInfoListPtr findFileInfo(const Ogre::String& pattern, bool recursive = true,
73            bool dirs = false);
74
75        bool exists(const Ogre::String& filename);
76
77        static void addFile(const std::string& archiveName, const std::string& filename, shared_array<char> content, size_t size)
78            { archives_s[archiveName][filename] = std::make_pair(content, size); }
79
80    private:
81        void findFiles(const Ogre::String& pattern, bool bRecursive,
82            bool bDirs, Ogre::StringVector* simpleList, Ogre::FileInfoList* detailList);
83
84        typedef std::map<std::string, std::pair<shared_array<char>, size_t> > FileMap;
85        typedef std::map<std::string, FileMap> ArchiveMap;
86        static ArchiveMap archives_s;
87    };
88
89    //! Specialisation of ArchiveFactory for MemoryArchive.
90    class _CoreExport MemoryArchiveFactory : public Ogre::ArchiveFactory
91    {
92    public:
93        const Ogre::String& getType(void) const;
94        Ogre::Archive* createInstance(const Ogre::String& name) { return new MemoryArchive(name, "Memory"); }
95        void destroyInstance(Ogre::Archive* arch)               { delete arch; }
96    };
97}
98
99#endif /* OGRE_VERSION < 0x010600 */
100
101#endif /* _MemoryArchive_H__ */
Note: See TracBrowser for help on using the repository browser.