Nebula
Loading...
Searching...
No Matches
rtpluginregistry.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
11#include "core/refcounted.h"
12#include "core/singleton.h"
14
15//------------------------------------------------------------------------------
16namespace RenderModules
17{
19{
22public:
26 virtual ~RTPluginRegistry();
27
29 void Setup();
31 void Discard();
33 bool IsValid() const;
34
36 void RegisterRTPlugin(const Core::Rtti* rtti);
38 void UnregisterRTPlugin(const Core::Rtti* rtti);
41
43 virtual void OnStageCreated(const Ptr<Graphics::Stage>& stage);
45 virtual void OnDiscardStage(const Ptr<Graphics::Stage>& stage);
47 virtual void OnViewCreated(const Ptr<Graphics::View>& view);
49 virtual void OnDiscardView(const Ptr<Graphics::View>& view);
51 virtual void OnAttachEntity(const Ptr<Graphics::GraphicsEntity>& entity);
53 virtual void OnRemoveEntity(const Ptr<Graphics::GraphicsEntity>& entity);
55 virtual void OnUpdateBefore(IndexT frameId, Timing::Time time);
57 virtual void OnUpdateAfter(IndexT frameId, Timing::Time time);
59 virtual void OnRenderBefore(IndexT frameId, Timing::Time time);
61 virtual void OnRenderAfter(IndexT frameId, Timing::Time time);
63 virtual void OnRender(const Util::StringAtom& filter);
65 virtual void OnFrameBefore(IndexT frameId, Timing::Time time);
67 virtual void OnFrameAfter(IndexT frameId, Timing::Time time);
69 virtual void OnRenderFrame();
71 virtual void OnRenderWithoutView(IndexT frameId, Timing::Time time);
73 virtual void OnWindowResized(IndexT windowId, SizeT width, SizeT height);
74
76 IndexT FindPlugin(const Core::Rtti* rtti) const;
78 template<typename T> const Ptr<T>& GetPluginByRTTI(const Core::Rtti* rtti) const;
79
80private:
81
83 bool isValid;
84};
85
86//------------------------------------------------------------------------------
89inline bool
91{
92 return this->isValid;
93}
94
95//------------------------------------------------------------------------------
98inline const Util::Array<Ptr<RTPlugin> >&
100{
101 return this->plugins;
102}
103
104//------------------------------------------------------------------------------
107template<typename T> const Ptr<T>&
109{
110 n_assert(rtti->IsDerivedFrom(RTPlugin::RTTI));
111 IndexT index = this->FindPlugin(rtti);
112 return this->plugins[index].downcast<T>();
113}
114
115} // namespace RenderModules
116//------------------------------------------------------------------------------
117
118
The common base class of Nebula.
Definition refcounted.h:38
Nebula's runtime type information for one class.
Definition rtti.h:27
bool IsDerivedFrom(const Rtti &other) const
return true if this rtti is equal or derived from to other rtti
Definition rtti.cc:135
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition ptr.h:38
The central registry for render thread plugins.
Definition rtpluginregistry.h:19
IndexT FindPlugin(const Core::Rtti *rtti) const
find plugin index by rtti
Definition rtpluginregistry.cc:99
virtual void OnUpdateAfter(IndexT frameId, Timing::Time time)
called after updating entities
Definition rtpluginregistry.cc:219
virtual void OnDiscardStage(const Ptr< Graphics::Stage > &stage)
called when a stage is discarded
Definition rtpluginregistry.cc:135
virtual void OnFrameAfter(IndexT frameId, Timing::Time time)
called at the end of frame
Definition rtpluginregistry.cc:289
__DeclareSingleton(RTPluginRegistry)
void RegisterRTPlugin(const Core::Rtti *rtti)
register a render plugin
Definition rtpluginregistry.cc:66
virtual void OnAttachEntity(const Ptr< Graphics::GraphicsEntity > &entity)
called when a graphics entity has been registered with the GraphicsServer
Definition rtpluginregistry.cc:177
virtual void OnUpdateBefore(IndexT frameId, Timing::Time time)
called before updating entities
Definition rtpluginregistry.cc:205
virtual void OnRender(const Util::StringAtom &filter)
called from a frame script
Definition rtpluginregistry.cc:261
virtual void OnFrameBefore(IndexT frameId, Timing::Time time)
called at the beginning of frame
Definition rtpluginregistry.cc:275
void Discard()
discard the plugin registry
Definition rtpluginregistry.cc:48
virtual void OnRenderBefore(IndexT frameId, Timing::Time time)
called before rendering entities
Definition rtpluginregistry.cc:233
void UnregisterRTPlugin(const Core::Rtti *rtti)
unregister a render plugin
Definition rtpluginregistry.cc:83
bool isValid
Definition rtpluginregistry.h:83
virtual void OnRenderWithoutView(IndexT frameId, Timing::Time time)
called if no view exists, and no default camera is set in view
Definition rtpluginregistry.cc:316
virtual ~RTPluginRegistry()
destructor
Definition rtpluginregistry.cc:28
virtual void OnRenderFrame()
called from when rendering with a special tag
Definition rtpluginregistry.cc:302
virtual void OnStageCreated(const Ptr< Graphics::Stage > &stage)
called when a new stage has been created
Definition rtpluginregistry.cc:121
__DeclareClass(RTPluginRegistry)
bool IsValid() const
return true if currently valid
Definition rtpluginregistry.h:90
virtual void OnDiscardView(const Ptr< Graphics::View > &view)
called when a view is being discarded
Definition rtpluginregistry.cc:163
Util::Array< Ptr< RTPlugin > > plugins
Definition rtpluginregistry.h:82
virtual void OnViewCreated(const Ptr< Graphics::View > &view)
called when a new view has been created
Definition rtpluginregistry.cc:149
const Ptr< T > & GetPluginByRTTI(const Core::Rtti *rtti) const
get plugin by rtti
void Setup()
setup the plugin registry
Definition rtpluginregistry.cc:38
RTPluginRegistry()
constructor
Definition rtpluginregistry.cc:19
virtual void OnWindowResized(IndexT windowId, SizeT width, SizeT height)
called if the window has been resized
Definition rtpluginregistry.cc:330
const Util::Array< Ptr< RTPlugin > > & GetRTPlugins() const
get all currently registered plugins
Definition rtpluginregistry.h:99
virtual void OnRenderAfter(IndexT frameId, Timing::Time time)
called after rendering entities
Definition rtpluginregistry.cc:247
virtual void OnRemoveEntity(const Ptr< Graphics::GraphicsEntity > &entity)
called when a graphics entity is being removed from a stage
Definition rtpluginregistry.cc:191
Nebula's dynamic array class.
Definition array.h:60
A StringAtom.
Definition stringatom.h:22
#define n_assert(exp)
Definition debug.h:50
Definition rendermodule.cc:11
double Time
the time datatype
Definition time.h:18
int SizeT
Definition types.h:49
int IndexT
Definition types.h:48