RType
IComponent.hpp
Go to the documentation of this file.
1 //
2 // Created by Talleux on 28/12/2023.
3 //
4 
5 #pragma once
6 
7 #include "networking/client/ClientSocket.hpp"
8 #include <SFML/Graphics.hpp>
9 #include <memory>
10 #include <vector>
11 
12 /**
13  * @brief ComponentType, enum of the component type
14  */
15 typedef enum {
23 } ComponentType;
24 
25 class ClientCore;
26 
28 {
29  public:
30 
31  /**
32  * @brief IComponent, constructor of IComponent
33  */
34  explicit IComponent(ClientCore *clientCore) :
35  _clientCore(clientCore)
36  {
37  }
38 
39  /**
40  * @brief ~IComponent, destructor of IComponent
41  */
42  virtual ~IComponent() = default;
43 
44 
45  /**
46  * @brief getType, get the type of the component
47  */
48  [[nodiscard]] virtual ComponentType getType() const = 0;
49 
50  /**
51  * @brief action, action of the component
52  */
53  virtual void action() = 0;
54 
55  /**
56  * @brief display, display the component
57  * @param window
58  */
59  virtual void display(sf::RenderWindow &window) = 0;
60 
61  /**
62  * @brief addActionTarget, add a target to the action
63  * @param component
64  */
65  virtual void addActionTarget(std::shared_ptr<IComponent> component) = 0;
66 
67  /**
68  * @brief addSubComponent, add a sub component
69  * @param component
70  */
71  virtual void addSubComponent(std::shared_ptr<IComponent> component) = 0;
72 
73 
74  /**
75  * @brief handleEvent, handle the event
76  * @param event
77  * @param window
78  */
79  virtual void handleEvent(const sf::Event &event, sf::RenderWindow &window) = 0;
80 
81 
82  /**
83  * @brief setAttribute, set the attribute
84  * @param attribute
85  */
86  virtual void setAttribute(std::string attribute) = 0;
87 
88  /**
89  * @brief getAttribute, get the attribute
90  * @return attribute
91  */
92  [[nodiscard]]
93  virtual std::string getAttribute() = 0;
94 
95  protected:
96  std::string _attribute;
97  ComponentType _type;
101 };