CSCI3081W Drone Delivery System
IEntityDecorator.h
1 #ifndef ENTITY_DECORATOR_H_
2 #define ENTITY_DECORATOR_H_
3 
4 #include <concepts>
5 
6 #include "IEntity.h"
7 
8 template <std::derived_from<IEntity> T = IEntity>
9 
15 class IEntityDecorator : public T {
16  public:
21  IEntityDecorator(T* e) : T(e->getDetails()), sub(e) {}
22 
26  virtual ~IEntityDecorator() {
27  if (sub) delete sub;
28  }
29 
36  virtual void linkModel(SimulationModel* model) {
37  return sub->linkModel(model);
38  }
39 
44  virtual int getId() const { return sub->getId(); }
45 
50  virtual Vector3 getPosition() const { return sub->getPosition(); }
51 
56  virtual Vector3 getDirection() const { return sub->getDirection(); }
57 
62  virtual const JsonObject& getDetails() const { return sub->getDetails(); }
63 
68  virtual std::string getColor() const { return sub->getColor(); }
69 
74  virtual std::string getName() const { return sub->getName(); }
75 
80  virtual double getSpeed() const { return sub->getSpeed(); }
81 
86  virtual void setPosition(Vector3 pos_) { return sub->setPosition(pos_); }
87 
92  virtual void setDirection(Vector3 dir_) { return sub->setDirection(dir_); }
93 
98  virtual void setColor(std::string col_) { return sub->setColor(col_); }
99 
104  virtual void rotate(double angle) { return sub->rotate(angle); }
105 
110  virtual void update(double dt) { return sub->update(dt); }
111  virtual SimulationModel* getModel() const { return sub->getModel(); }
112 
113  protected:
114  T* sub = nullptr;
115 };
116 
117 #endif
Base class decorator for all entities that implements each specific entity in a template,...
Definition: IEntityDecorator.h:15
virtual const JsonObject & getDetails() const
Gets the details of the entity.
Definition: IEntityDecorator.h:62
IEntityDecorator(T *e)
Constructor for IEntityDecorator.
Definition: IEntityDecorator.h:21
virtual void linkModel(SimulationModel *model)
Links this entity to a simulation model, giving it access to the model's public variables and functio...
Definition: IEntityDecorator.h:36
virtual ~IEntityDecorator()
Destructor.
Definition: IEntityDecorator.h:26
virtual Vector3 getDirection() const
Gets the direction of the entity.
Definition: IEntityDecorator.h:56
virtual std::string getColor() const
Gets the color of the entity.
Definition: IEntityDecorator.h:68
virtual Vector3 getPosition() const
Gets the position of the entity.
Definition: IEntityDecorator.h:50
virtual void rotate(double angle)
Rotate the entity around y axis.
Definition: IEntityDecorator.h:104
virtual double getSpeed() const
Gets the speed of the entity.
Definition: IEntityDecorator.h:80
virtual int getId() const
Gets the ID of the entity.
Definition: IEntityDecorator.h:44
virtual std::string getName() const
Gets the name of the entity.
Definition: IEntityDecorator.h:74
virtual void setPosition(Vector3 pos_)
Sets the position of the entity.
Definition: IEntityDecorator.h:86
virtual void setDirection(Vector3 dir_)
Set the direction of the entity.
Definition: IEntityDecorator.h:92
virtual void update(double dt)
Updates the entity's position in the physical system.
Definition: IEntityDecorator.h:110
virtual void setColor(std::string col_)
Sets the color of the entity.
Definition: IEntityDecorator.h:98
Manages a picojson::object, works with JsonValue to provide implicit casting.
Class SimulationModel handling the transit simulation. it can communicate with the controller.
Definition: SimulationModel.h:30
a simple class used for vector math, most function are self explanatory
Definition: vector3.h:12