CSCI3081W Drone Delivery System
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
SimulationModel Class Reference

Class SimulationModel handling the transit simulation. it can communicate with the controller. More...

#include <SimulationModel.h>

Inheritance diagram for SimulationModel:
Inheritance graph
[legend]
Collaboration diagram for SimulationModel:
Collaboration graph
[legend]

Public Member Functions

 SimulationModel (IController &controller)
 Default constructor that create the SimulationModel object. More...
 
 ~SimulationModel ()
 Destructor.
 
void setGraph (const routing::Graph *graph)
 Set the Graph for the SimulationModel. More...
 
IEntitycreateEntity (const JsonObject &entity)
 Creates a new simulation entity. More...
 
void removeEntity (int id)
 Removes entity with given ID from the simulation. More...
 
void scheduleTrip (const JsonObject &details)
 Schedule a trip for an object in the scene. More...
 
void update (double dt)
 Update the simulation. More...
 
void stop ()
 Stops the simulation. More...
 
const routing::GraphgetGraph () const
 Returns the graph of the map. More...
 
void notify (const std::string &message) const
 Notifies observer with specific message. More...
 
std::vector< Vector3getRechargeStations () const
 Get all the Recharge Station positions. More...
 
void addRechargeStation (Vector3 station)
 add a recharge station position to the list mainly used by recharge drones when they arrive near the dead drone More...
 
void removeRechargeStation (Vector3 station)
 remove a recharge station position from the list mainly used by recharge drones when they leave after dead drone is fully charged More...
 

Public Attributes

std::deque< Package * > scheduledDeliveries
 
std::deque< Drone * > deadDrones
 
std::deque< Drone * > functionalDrones
 
std::deque< Drone * > chargingDrones
 
IControllercontroller
 
std::vector< POI * > pois
 
std::vector< MultiDeliveryDecorator * > drones
 

Protected Member Functions

void removeFromSim (int id)
 Removes the model from the simulation. More...
 

Protected Attributes

std::map< int, IEntity * > entities
 
std::set< int > removed
 
const routing::Graphgraph = nullptr
 
CompositeFactory entityFactory
 
std::vector< Vector3rechargeStations
 

Detailed Description

Class SimulationModel handling the transit simulation. it can communicate with the controller.

Simulation Model handling the transit simulation. The model can communicate with the controller.

Constructor & Destructor Documentation

◆ SimulationModel()

SimulationModel::SimulationModel ( IController controller)

Default constructor that create the SimulationModel object.

Parameters
controllerThe specified Controller to be initialized in the model

Member Function Documentation

◆ addRechargeStation()

void SimulationModel::addRechargeStation ( Vector3  station)

add a recharge station position to the list mainly used by recharge drones when they arrive near the dead drone

Parameters
stationposition of the recharge station to be added

◆ createEntity()

IEntity* SimulationModel::createEntity ( const JsonObject entity)

Creates a new simulation entity.

Parameters
entityType JsonObject contain the entity's reference to decide which entity to create

◆ getGraph()

const routing::Graph* SimulationModel::getGraph ( ) const

Returns the graph of the map.

Returns
Graph* graph pointer

◆ getRechargeStations()

std::vector<Vector3> SimulationModel::getRechargeStations ( ) const

Get all the Recharge Station positions.

Returns
std::vector<Vector3> a vector of recharge station positions

◆ notify()

void SimulationModel::notify ( const std::string &  message) const
virtual

Notifies observer with specific message.

Parameters
messageThe specific message

Implements IObserver.

◆ removeEntity()

void SimulationModel::removeEntity ( int  id)

Removes entity with given ID from the simulation.

Parameters
idof the entity to be removed

◆ removeFromSim()

void SimulationModel::removeFromSim ( int  id)
protected

Removes the model from the simulation.

Parameters
idThe id of the model to be removed

◆ removeRechargeStation()

void SimulationModel::removeRechargeStation ( Vector3  station)

remove a recharge station position from the list mainly used by recharge drones when they leave after dead drone is fully charged

Parameters
stationposition of the recharge station to be removed

◆ scheduleTrip()

void SimulationModel::scheduleTrip ( const JsonObject details)

Schedule a trip for an object in the scene.

Parameters
detailType JsonObject contain the entity's reference to schedule the detail of the trip being scheduled

◆ setGraph()

void SimulationModel::setGraph ( const routing::Graph graph)

Set the Graph for the SimulationModel.

Parameters
graphType Graph* contain the new graph for SimulationModel

◆ stop()

void SimulationModel::stop ( )

Stops the simulation.

Returns
Void

◆ update()

void SimulationModel::update ( double  dt)

Update the simulation.

Parameters
dtType double comodel.reRouteClose();ntain the time since update was last called.

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