source: OGRE/trunk/ogrenew/OgreMain/include/OgreCodec.h @ 657

Revision 657, 4.2 KB checked in by mattausch, 19 years ago (diff)

added ogre dependencies and patched ogre sources

RevLine 
[657]1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25#ifndef _Codec_H__
26#define _Codec_H__
27
28#include "OgrePrerequisites.h"
29#include "OgreSharedPtr.h"
30#include "OgreDataStream.h"
31
32namespace Ogre {
33
34    /** Abstract class that defines a 'codec'.
35        @remarks
36            A codec class works like a two-way filter for data - data entered on
37            one end (the decode end) gets processed and transformed into easily
38            usable data while data passed the other way around codes it back.
39        @par
40            The codec concept is a pretty generic one - you can easily understand
41            how it can be used for images, sounds, archives, even compressed data.
42    */
43    class _OgreExport Codec
44    {
45    protected:
46        typedef std::map< String, Codec* > CodecList;
47        /** A map that contains all the registered codecs.
48        */
49        static CodecList ms_mapCodecs;
50
51    public:
52        class _OgrePrivate CodecData
53        {
54        public:
55            virtual ~CodecData() {};
56
57            /** Returns the type of the data.
58            */
59            virtual String dataType() const { return "CodecData"; };
60        };
61        typedef SharedPtr<CodecData> CodecDataPtr;
62
63    public:
64        virtual ~Codec();
65       
66        /** Registers a new codec in the database.
67        */
68        static void registerCodec( Codec *pCodec )
69        {
70            ms_mapCodecs[pCodec->getType()] = pCodec;
71        }
72
73        /** Unregisters a codec from the database.
74        */
75        static void unRegisterCodec( Codec *pCodec )
76        {
77            ms_mapCodecs.erase(pCodec->getType());
78        }
79
80        /** Gets the codec registered for the passed in file extension. */
81        static Codec* getCodec(const String& extension);
82
83        /** Codes the data in the input stream and saves the result in the output
84            stream.
85        */
86        virtual DataStreamPtr code(MemoryDataStreamPtr& input, CodecDataPtr& pData) const = 0;
87        /** Codes the data in the input chunk and saves the result in the output
88            filename provided. Provided for efficiency since coding to memory is
89            progressive therefore memory required is unknown leading to reallocations.
90        @param input The input data
91        @param outFileName The filename to write to
92        @param pData Extra information to be passed to the codec (codec type specific)
93        */
94        virtual void codeToFile(MemoryDataStreamPtr& input, const String& outFileName, CodecDataPtr& pData) const = 0;
95
96        /// Result of a decoding; both a decoded data stream and CodecData metadata
97        typedef std::pair<MemoryDataStreamPtr, CodecDataPtr> DecodeResult;
98        /** Codes the data from the input chunk into the output chunk.
99            @param input Stream containing the encoded data
100            @note
101                Has a variable number of arguments, which depend on the codec type.
102        */
103        virtual DecodeResult decode(DataStreamPtr& input) const = 0;
104
105        /** Returns the type of the codec as a String
106        */
107        virtual String getType() const = 0;
108    };
109
110} // namespace
111
112#endif
Note: See TracBrowser for help on using the repository browser.