1 | /* |
---|
2 | ----------------------------------------------------------------------------- |
---|
3 | This source file is part of OGRE |
---|
4 | (Object-oriented Graphics Rendering Engine) |
---|
5 | For the latest info, see http://www.ogre3d.org |
---|
6 | |
---|
7 | Copyright (c) 2000-2006 Torus Knot Software Ltd |
---|
8 | Also see acknowledgements in Readme.html |
---|
9 | |
---|
10 | This program is free software; you can redistribute it and/or modify it under |
---|
11 | the terms of the GNU Lesser General Public License as published by the Free Software |
---|
12 | Foundation; either version 2 of the License, or (at your option) any later |
---|
13 | version. |
---|
14 | |
---|
15 | This program is distributed in the hope that it will be useful, but WITHOUT |
---|
16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
---|
17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
---|
18 | |
---|
19 | You should have received a copy of the GNU Lesser General Public License along with |
---|
20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
---|
21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
---|
22 | http://www.gnu.org/copyleft/lesser.txt. |
---|
23 | |
---|
24 | You may alternatively use this source under the terms of a specific version of |
---|
25 | the OGRE Unrestricted License provided you have obtained such a license from |
---|
26 | Torus Knot Software Ltd. |
---|
27 | ----------------------------------------------------------------------------- |
---|
28 | */ |
---|
29 | #ifndef __OGREPLUGIN_H__ |
---|
30 | #define __OGREPLUGIN_H__ |
---|
31 | |
---|
32 | #include "OgrePrerequisites.h" |
---|
33 | |
---|
34 | namespace Ogre |
---|
35 | { |
---|
36 | /** Class defining a generic OGRE plugin. |
---|
37 | @remarks |
---|
38 | OGRE is very plugin-oriented and you can customise much of its behaviour |
---|
39 | by registering new plugins, dynamically if you are using dynamic linking. |
---|
40 | This class abstracts the generic interface that all plugins must support. |
---|
41 | Within the implementations of this interface, the plugin must call other |
---|
42 | OGRE classes in order to register the detailed customisations it is |
---|
43 | providing, e.g. registering a new SceneManagerFactory, a new |
---|
44 | MovableObjectFactory, or a new RenderSystem. |
---|
45 | @par |
---|
46 | Plugins can be linked statically or dynamically. If they are linked |
---|
47 | dynamically (ie the plugin is in a DLL or Shared Object file), then you |
---|
48 | load the plugin by calling the Root::loadPlugin method (or some other |
---|
49 | mechanism which leads to that call, e.g. plugins.cfg), passing the name of |
---|
50 | the DLL. OGRE will then call a global init function on that DLL, and it |
---|
51 | will be expected to register one or more Plugin implementations using |
---|
52 | Root::installPlugin. The procedure is very similar if you use a static |
---|
53 | linked plugin, except that you simply instantiate the Plugin implementation |
---|
54 | yourself and pass it to Root::installPlugin. |
---|
55 | @note |
---|
56 | Lifecycle of a Plugin instance is very important. The Plugin instance must |
---|
57 | remain valid until the Plugin is uninstalled. Here are the things you |
---|
58 | must bear in mind: |
---|
59 | <ul><li>If your plugin is in a DLL: |
---|
60 | <ul><li>Create the Plugin instance and call Root::installPlugin in dllStartPlugin</li> |
---|
61 | <li>Call Root::uninstallPlugin, then delete it in dllStopPlugin</li></ul> |
---|
62 | <li>If your plugin is statically linked in your app: |
---|
63 | <ul><li>Create the Plugin anytime you like</li> |
---|
64 | <li>Call Root::installPlugin any time whilst Root is valid</li> |
---|
65 | <li>Call Root::uninstallPlugin if you like so long as Root is valid. However, |
---|
66 | it will be done for you when Root is destroyed, so the Plugin instance must |
---|
67 | still be valid at that point if you haven't manually uninstalled it.</li></ul> |
---|
68 | </ul> |
---|
69 | The install and unninstall methods will be called when the plugin is |
---|
70 | installed or uninstalled. The initialise and shutdown will be called when |
---|
71 | there is a system initialisation or shutdown, e.g. when Root::initialise |
---|
72 | or Root::shutdown are called. |
---|
73 | */ |
---|
74 | class _OgreExport Plugin |
---|
75 | { |
---|
76 | public: |
---|
77 | Plugin() {} |
---|
78 | virtual ~Plugin() {} |
---|
79 | |
---|
80 | /** Get the name of the plugin. |
---|
81 | @remarks An implementation must be supplied for this method to uniquely |
---|
82 | identify the plugin. |
---|
83 | */ |
---|
84 | virtual const String& getName() const = 0; |
---|
85 | |
---|
86 | /** Perform the plugin initial installation sequence. |
---|
87 | @remarks An implementation must be supplied for this method. It must perform |
---|
88 | the startup tasks necessary to install any rendersystem customisations |
---|
89 | or anything else that is not dependent on system initialisation, ie |
---|
90 | only dependent on the core of Ogre. It must not perform any |
---|
91 | operations that would create rendersystem-specific objects at this stage, |
---|
92 | that should be done in initialise(). |
---|
93 | */ |
---|
94 | virtual void install() = 0; |
---|
95 | |
---|
96 | /** Perform any tasks the plugin needs to perform on full system |
---|
97 | initialisation. |
---|
98 | @remarks An implementation must be supplied for this method. It is called |
---|
99 | just after the system is fully initialised (either after Root::initialise |
---|
100 | if a window is created then, or after the frist window is created) |
---|
101 | and therefore all rendersystem functionality is available at this |
---|
102 | time. You can use this hook to create any resources which are |
---|
103 | dependent on a rendersystem or have rendersystem-specific implementations. |
---|
104 | */ |
---|
105 | virtual void initialise() = 0; |
---|
106 | |
---|
107 | /** Perform any tasks the plugin needs to perform when the system is shut down. |
---|
108 | @remarks An implementation must be supplied for this method. |
---|
109 | This method is called just before key parts of the system are unloaded, |
---|
110 | such as rendersystems being shut down. You should use this hook to free up |
---|
111 | resources and decouple custom objects from the OGRE system, whilst all the |
---|
112 | instances of other plugins (e.g. rendersystems) still exist. |
---|
113 | */ |
---|
114 | virtual void shutdown() = 0; |
---|
115 | |
---|
116 | /** Perform the final plugin uninstallation sequence. |
---|
117 | @remarks An implementation must be supplied for this method. It must perform |
---|
118 | the cleanup tasks which haven't already been performed in shutdown() |
---|
119 | (e.g. final deletion of custom instances, if you kept them around incase |
---|
120 | the system was reinitialised). At this stage you cannot be sure what other |
---|
121 | plugins are still loaded or active. It must therefore not perform any |
---|
122 | operations that would reference any rendersystem-specific objects - those |
---|
123 | should have been sorted out in the 'shutdown' method. |
---|
124 | */ |
---|
125 | virtual void uninstall() = 0; |
---|
126 | }; |
---|
127 | |
---|
128 | } |
---|
129 | |
---|
130 | #endif |
---|
131 | |
---|
132 | |
---|