CSCI 3081 - Drone Delivery System
Public Member Functions | Protected Attributes | List of all members
csci3081::ASubject Class Referenceabstract

This is the Abstract Subject class from which our subjects will inherit Implements the Observer/subject pattern. More...

#include <asubject.h>

Inheritance diagram for csci3081::ASubject:
Inheritance graph

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.
 

Detailed Description

This is the Abstract Subject class from which our subjects will inherit Implements the Observer/subject pattern.

Member Function Documentation

◆ Attach()

void csci3081::ASubject::Attach ( entity_project::IEntityObserver observer)

Adds an observer to the list of observers for this subject.

Parameters
IEntityObserver*observer

◆ Detach()

void csci3081::ASubject::Detach ( entity_project::IEntityObserver observer)

Deletes an observer from the list of observers for this subject.

Parameters
IEntityObserver*observer

◆ GetList()

std::vector< entity_project::IEntityObserver * > csci3081::ASubject::GetList ( )

Getter function for the list of observers (mostly used in testing)

Returns
std::vector <entity_project::IEntityObserver*> list

◆ GetStatus()

virtual void csci3081::ASubject::GetStatus ( )
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.

Parameters
picojson::value&event
constentity_project::IEntity& entity

Implemented in csci3081::RechargeDrone, csci3081::Carrier, and csci3081::Package.

◆ Notify()

void csci3081::ASubject::Notify ( picojson::value &  event,
const entity_project::IEntity entity 
)

Sends out Notification to the observer watching this subject.

Parameters
picojson::value&event
constentity_project::IEntity& entity

◆ Update()

virtual void csci3081::ASubject::Update ( float  dt)
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.

Parameters
floatdt 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.


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