CSCI 3081 - Drone Delivery System
|
This is the Abstract Subject class from which our subjects will inherit Implements the Observer/subject pattern. More...
#include <asubject.h>
Public Member Functions | |
void | Attach (entity_project::IEntityObserver *observer) |
Adds an observer to the list of observers for this subject. More... | |
void | Detach (entity_project::IEntityObserver *observer) |
Deletes an observer from the list of observers for this subject. More... | |
std::vector< entity_project::IEntityObserver * > | GetList () |
Getter function for the list of observers (mostly used in testing) More... | |
void | Notify (picojson::value &event, const entity_project::IEntity &entity) |
Sends out Notification to the observer watching this subject. More... | |
virtual void | GetStatus ()=0 |
Pure virtual function GetStatus that needs to implemented by derived class based on their types of notification. This function creates the arguments required by Notify function and makes call to Notify function. More... | |
virtual void | Update (float dt)=0 |
Pure virtual function Update that needs to implemented by derived class based on their entity type. This function is used to advance time in the simulation. More... | |
Protected Attributes | |
std::vector< entity_project::IEntityObserver * > | list |
List of pointers to the observers for this subject. | |
This is the Abstract Subject class from which our subjects will inherit Implements the Observer/subject pattern.
void csci3081::ASubject::Attach | ( | entity_project::IEntityObserver * | observer | ) |
Adds an observer to the list of observers for this subject.
IEntityObserver* | observer |
void csci3081::ASubject::Detach | ( | entity_project::IEntityObserver * | observer | ) |
Deletes an observer from the list of observers for this subject.
IEntityObserver* | observer |
std::vector< entity_project::IEntityObserver * > csci3081::ASubject::GetList | ( | ) |
Getter function for the list of observers (mostly used in testing)
|
pure virtual |
Pure virtual function GetStatus that needs to implemented by derived class based on their types of notification. This function creates the arguments required by Notify function and makes call to Notify function.
picojson::value& | event |
const | entity_project::IEntity& entity |
Implemented in csci3081::RechargeDrone, csci3081::Carrier, and csci3081::Package.
void csci3081::ASubject::Notify | ( | picojson::value & | event, |
const entity_project::IEntity & | entity | ||
) |
Sends out Notification to the observer watching this subject.
picojson::value& | event |
const | entity_project::IEntity& entity |
|
pure virtual |
Pure virtual function Update that needs to implemented by derived class based on their entity type. This function is used to advance time in the simulation.
float | dt refers to the amount of time the update call should advance the simulation by. For instance if a drone moves 1 unit of distance per unit of time, and Update is called with dt=.05, then the drone should move 1 * .05 = .05 units of distance. |
Some things that should happen in the Update function: move drones, check if packages have been delivered to customers, etc.
Implemented in csci3081::Carrier, csci3081::RechargeDrone, and csci3081::Package.