Nymph Game Engine
Chaiscript based Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
subject.h
Go to the documentation of this file.
1 #ifndef SUBJECT_H
2 #define SUBJECT_H
3 #include <list>
4 #include <memory>
5 #include "events/observer.h"
6 #include "events/event.h"
7 //= SCRIPTABLE
8 
9 namespace Events {
13  class Subject {
14  private:
15  std::list<std::shared_ptr<Observer>> observers;
16  public:
17  virtual ~Subject() = default;
18  //= BEGIN SCRIPTABLE
24  virtual void notify(std::shared_ptr<Event> event);
30  virtual void notifyNow(std::shared_ptr<Event> event);
36  virtual void addObserver(std::shared_ptr<Observer> observer);
42  virtual void removeObserver(std::shared_ptr<Observer> observer);
43  //= END SCRIPTABLE
44  };
45 }
46 #endif
virtual void notify(std::shared_ptr< Event > event)
notify is used to tell observers of an event.
Definition: subject.cpp:13
virtual void addObserver(std::shared_ptr< Observer > observer)
Adds an observer.
Definition: subject.cpp:5
Class for a subject that an observer would observe for changes.
Definition: subject.h:13
virtual ~Subject()=default
virtual void notifyNow(std::shared_ptr< Event > event)
notifyNow is used to tell observers of an event as an interrupt.
Definition: subject.cpp:19
virtual void removeObserver(std::shared_ptr< Observer > observer)
Removes an observer.
Definition: subject.cpp:9