Nymph Game Engine
Chaiscript based Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Events::Observer Class Referenceabstract

Interface to be notified of an item's changes. More...

#include <observer.h>

Inheritance diagram for Events::Observer:
Component Input::InputSystem Script::ScriptObject Utility::DebugParser Game::SpriteMovement Graphics::Camera Graphics::Light Graphics::Renderable Graphics::TileAnimator< StateType > Graphics::UI::Text Physics::CollisionData Sound::SoundInstance

Public Member Functions

virtual ~Observer ()
 
void onNotify (std::shared_ptr< Event > event)
 When receiving an event that is non-immediate, onNotify is used. The event is added to the event queue that is processed when processEventQueue is called. More...
 
virtual void onNotifyNow (std::shared_ptr< Event > event)=0
 When receiving an event that is immediate, onNotifyNow is used. It acts as an interrupt to make sure the object is notified before another engine loop. This is pure virtual and is implemented on a case by case basis in derived classes. More...
 
virtual void handleQueuedEvent (std::shared_ptr< Event > event)=0
 HandleQueuedEvent allows derived classes to define behaviour for when queuedEvents are received. More...
 
void processEventQueue ()
 This should be called once ever loop for every Observer to properly use queued events. More...
 

Protected Member Functions

std::shared_ptr< EventgetEvent ()
 
bool eventsWaiting () const noexcept
 

Detailed Description

Interface to be notified of an item's changes.

Constructor & Destructor Documentation

virtual Events::Observer::~Observer ( )
inlinevirtual

Member Function Documentation

bool Events::Observer::eventsWaiting ( ) const
inlineprotectednoexcept
std::shared_ptr<Event> Events::Observer::getEvent ( )
inlineprotected
virtual void Events::Observer::handleQueuedEvent ( std::shared_ptr< Event event)
pure virtual
void Events::Observer::onNotify ( std::shared_ptr< Event event)
inline

When receiving an event that is non-immediate, onNotify is used. The event is added to the event queue that is processed when processEventQueue is called.

Parameters
[in]eventThe event
virtual void Events::Observer::onNotifyNow ( std::shared_ptr< Event event)
pure virtual

When receiving an event that is immediate, onNotifyNow is used. It acts as an interrupt to make sure the object is notified before another engine loop. This is pure virtual and is implemented on a case by case basis in derived classes.

Parameters
[in]eventThe event

Implemented in Game::SpriteMovement, Graphics::Renderable, Graphics::TileAnimator< StateType >, Graphics::Camera, Graphics::UI::Element, Component, Script::ScriptObject, Graphics::UI::Text, Graphics::UI::WrappableText, Graphics::UI::TextArea, Graphics::UI::TextField, Graphics::UI::Area, Input::InputSystem, Graphics::UI::Button, Sound::SoundInstance, and Utility::DebugParser.

void Events::Observer::processEventQueue ( )
inline

This should be called once ever loop for every Observer to properly use queued events.

References eventsWaiting(), getEvent(), and handleQueuedEvent().

Referenced by Utility::DebugParser::handleEvents(), and Script::ScriptObject::onUpdate().


The documentation for this class was generated from the following file: