CSCI3081W Drone Delivery System
SimulationModel.h
1 #ifndef SIMULATION_MODEL_H_
2 #define SIMULATION_MODEL_H_
3 
4 #include <deque>
5 #include <map>
6 #include <set>
7 
8 #include "CompositeFactory.h"
9 #include "Drone.h"
10 #include "MultiDeliveryDecorator.h"
11 #include "IController.h"
12 #include "IEntity.h"
13 #include "IObserver.h"
14 #include "POI.h"
15 #include "Robot.h"
16 #include "Graph.h"
17 
18 class POI;
20 
21 //-------------------- Model ----------------------------
22 
25 
30 class SimulationModel : public IObserver {
31  public:
37 
42 
47  void setGraph(const routing::Graph* graph);
48 
54  IEntity* createEntity(const JsonObject& entity);
55 
61  void removeEntity(int id);
62 
68  void scheduleTrip(const JsonObject& details);
69 
74  void update(double dt);
75 
80  void stop();
81 
87  const routing::Graph* getGraph() const;
88 
94  void notify(const std::string& message) const;
95 
101  std::vector<Vector3> getRechargeStations() const;
102 
111 
120 
121  std::deque<Package*> scheduledDeliveries;
122 
123  std::deque<Drone*> deadDrones;
124 
125  std::deque<Drone*> functionalDrones;
126 
127  std::deque<Drone*> chargingDrones;
128 
129  IController& controller;
130 
131  std::vector<POI*> pois;
132 
133  std::vector<MultiDeliveryDecorator*> drones;
134 
135  protected:
136  // Keeps track of all pois and drones in the simulation
137  std::map<int, IEntity*> entities;
138  std::set<int> removed;
143  void removeFromSim(int id);
144  const routing::Graph* graph = nullptr;
145  CompositeFactory entityFactory;
146  std::vector<Vector3> rechargeStations;
147 };
148 
149 #endif
Factory method for composite class. Inherits from IEntityFactory.
Definition: CompositeFactory.h:10
class for IController used for transit service. Uses the Model View
Definition: IController.h:15
Represents an entity in a physical system.
Definition: IEntity.h:22
Interface for Observer.
Definition: IObserver.h:10
Manages a picojson::object, works with JsonValue to provide implicit casting.
Decorator allowing for drones to make multiple deliveries, inherits from IObserver and DroneDecorator...
Definition: MultiDeliveryDecorator.h:15
Represents a point of interest in a physical system. Drones are able to make pitstops at these POIs i...
Definition: POI.h:15
Class SimulationModel handling the transit simulation. it can communicate with the controller.
Definition: SimulationModel.h:30
IEntity * createEntity(const JsonObject &entity)
Creates a new simulation entity.
void removeRechargeStation(Vector3 station)
remove a recharge station position from the list mainly used by recharge drones when they leave after...
void notify(const std::string &message) const
Notifies observer with specific message.
void stop()
Stops the simulation.
void removeFromSim(int id)
Removes the model from the simulation.
void scheduleTrip(const JsonObject &details)
Schedule a trip for an object in the scene.
std::vector< Vector3 > getRechargeStations() const
Get all the Recharge Station positions.
void update(double dt)
Update the simulation.
void addRechargeStation(Vector3 station)
add a recharge station position to the list mainly used by recharge drones when they arrive near the ...
void removeEntity(int id)
Removes entity with given ID from the simulation.
void setGraph(const routing::Graph *graph)
Set the Graph for the SimulationModel.
~SimulationModel()
Destructor.
SimulationModel(IController &controller)
Default constructor that create the SimulationModel object.
const routing::Graph * getGraph() const
Returns the graph of the map.
a simple class used for vector math, most function are self explanatory
Definition: vector3.h:12
Definition: Graph.h:23