source: GTP/trunk/Lib/Geom/OgreStuff/include/OgrePlatformManager.h @ 1809

Revision 1809, 6.7 KB checked in by gumbau, 18 years ago (diff)
Line 
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 __PlatformManager_H__
26#define __PlatformManager_H__
27
28#include "OgrePrerequisites.h"
29
30#include "OgreSingleton.h"
31
32namespace Ogre {
33    typedef void (*DLL_CREATECONFIGDIALOG)(ConfigDialog** ppDlg);
34    typedef void (*DLL_CREATEERRORDIALOG)(ErrorDialog** ppDlg);
35    typedef void (*DLL_CREATEINPUTREADER)(InputReader** ppReader);
36        typedef void (*DLL_CREATETIMER)(Timer** ppTimer);
37
38    typedef void (*DLL_DESTROYCONFIGDIALOG)(ConfigDialog* ppDlg);
39    typedef void (*DLL_DESTROYERRORDIALOG)(ErrorDialog* ppDlg);
40    typedef void (*DLL_DESTROYINPUTREADER)(InputReader* ppReader);
41    typedef void (*DLL_DESTROYTIMER)(Timer* ppTimer);
42
43        typedef void (*DLL_MESSAGEPUMP)(RenderWindow* rw);
44
45    /** Class which manages the platform settings Ogre runs on.
46        @remarks
47            Because Ogre is designed to be platform-independent, it
48            dynamically loads a library containing all the platform-specific
49            elements like dialogs etc.
50        @par
51            This class manages that load and provides a simple interface to
52            the platform.
53    */
54    class _OgreExport PlatformManager : public Singleton<PlatformManager>
55    {
56    protected:
57        DLL_CREATECONFIGDIALOG mpfCreateConfigDialog;
58        DLL_CREATEERRORDIALOG mpfCreateErrorDialog;
59        DLL_CREATEINPUTREADER mpfCreateInputReader;
60                DLL_CREATETIMER mpfCreateTimer;
61               
62                DLL_DESTROYCONFIGDIALOG mpfDestroyConfigDialog;
63        DLL_DESTROYERRORDIALOG mpfDestroyErrorDialog;
64        DLL_DESTROYINPUTREADER mpfDestroyInputReader;
65        DLL_DESTROYTIMER mpfDestroyTimer;
66
67                DLL_MESSAGEPUMP mpfMessagePump;
68               
69    public:
70        /** Default constructor.
71        */
72        PlatformManager();
73
74        /** Gets a new instance of a platform-specific config dialog.
75            @remarks
76                The instance returned from this method will be a
77                platform-specific subclass of ConfigDialog, and must be
78                destroyed by the caller when required.
79        */
80        ConfigDialog* createConfigDialog();
81
82        /** Destroys an instance of a platform-specific config dialog.
83            @remarks
84                Required since deletion of objects must be performed on the
85                correct heap.
86        */
87        void destroyConfigDialog(ConfigDialog* dlg);
88
89        /** Gets a new instance of a platform-specific config dialog.
90            @remarks
91                The instance returned from this method will be a
92                platform-specific subclass of ErrorDialog, and must be
93                destroyed by the caller when required.
94        */
95        ErrorDialog* createErrorDialog();
96
97        /** Destroys an instance of a platform-specific error dialog.
98            @remarks
99                Required since deletion of objects must be performed on the
100                correct heap.
101        */
102        void destroyErrorDialog(ErrorDialog* dlg);
103
104        /** Gets a new instance of a platform-specific input reader.
105            @remarks
106                The instance returned from this method will be a
107                platform-specific subclass of InputReader, and must be
108                destroyed by the caller when required.
109        */
110        InputReader* createInputReader();
111
112        /** Destroys an instance of a platform-specific input reader.
113            @remarks
114                Required since deletion of objects must be performed on the
115                correct heap.
116        */
117        void destroyInputReader(InputReader* reader);
118               
119                /** Creates a new Timer instance
120                */
121                Timer* createTimer();
122
123        /** Destroys an instance of a timer. */
124        void destroyTimer(Timer* timer);
125
126                /**
127                @remarks
128                        Allows platform to provide Platform specific Event
129                        updating/dispatching per frame (ie. Win32 Message Pump) as called
130                        from Root::startRendering . If you are not using Root::startRendering,
131                        you can call this function yourself, or run your own event pump
132                */
133                void messagePump(RenderWindow* rw);
134
135        /** Override standard Singleton retrieval.
136        @remarks
137        Why do we do this? Well, it's because the Singleton
138        implementation is in a .h file, which means it gets compiled
139        into anybody who includes it. This is needed for the
140        Singleton template to work, but we actually only want it
141        compiled into the implementation of the class based on the
142        Singleton, not all of them. If we don't change this, we get
143        link errors when trying to use the Singleton-based class from
144        an outside dll.
145        @par
146        This method just delegates to the template version anyway,
147        but the implementation stays in this single compilation unit,
148        preventing link errors.
149        */
150        static PlatformManager& getSingleton(void);
151        /** Override standard Singleton retrieval.
152        @remarks
153        Why do we do this? Well, it's because the Singleton
154        implementation is in a .h file, which means it gets compiled
155        into anybody who includes it. This is needed for the
156        Singleton template to work, but we actually only want it
157        compiled into the implementation of the class based on the
158        Singleton, not all of them. If we don't change this, we get
159        link errors when trying to use the Singleton-based class from
160        an outside dll.
161        @par
162        This method just delegates to the template version anyway,
163        but the implementation stays in this single compilation unit,
164        preventing link errors.
165        */
166        static PlatformManager* getSingletonPtr(void);
167
168
169    };
170
171
172}
173
174#endif
Note: See TracBrowser for help on using the repository browser.