led_entity.h
Go to the documentation of this file.
1 
7 #ifndef LED_ENTITY_H
8 #define LED_ENTITY_H
9 
10 namespace argos {
11  class CLEDEntity;
12  class CLEDMedium;
13 }
14 
15 #include <argos3/core/simulator/entity/positional_entity.h>
16 #include <argos3/core/utility/datatypes/set.h>
17 #include <argos3/core/utility/datatypes/color.h>
18 #include <argos3/core/utility/math/vector3.h>
19 #include <argos3/core/simulator/space/positional_indices/space_hash.h>
20 #include <argos3/core/simulator/space/positional_indices/grid.h>
21 
22 namespace argos {
23 
24  class CLEDEntity : public CPositionalEntity {
25 
26  public:
27 
29 
30  typedef std::vector<CLEDEntity*> TList;
32 
33  public:
34 
35  CLEDEntity(CComposableEntity* pc_parent);
36 
37  CLEDEntity(CComposableEntity* pc_parent,
38  const std::string& str_id,
39  const CVector3& c_position,
40  const CColor& c_color);
41 
42  virtual ~CLEDEntity() {}
43 
44  virtual void Init(TConfigurationNode& t_tree);
45 
46  virtual void Reset();
47 
48  virtual void Destroy();
49 
50  virtual void SetEnabled(bool b_enabled);
51 
58  inline const CColor& GetColor() const {
59  return m_cColor;
60  }
61 
69  inline const CColor& GetInitColor() const {
70  return m_cInitColor;
71  }
72 
78  void SetColor(const CColor& c_color);
79 
87  inline void SetInitColor(const CColor& c_color) {
88  m_cInitColor = c_color;
89  }
90 
91  virtual std::string GetTypeDescription() const {
92  return "led";
93  }
94 
100  inline bool HasMedium() const {
101  return m_pcMedium != NULL;
102  }
103 
109  CLEDMedium& GetMedium() const;
110 
116  void SetMedium(CLEDMedium& c_medium);
117 
118  protected:
119 
123 
124  };
125 
126  /****************************************/
127  /****************************************/
128 
129  class CLEDEntitySpaceHashUpdater : public CSpaceHashUpdater<CLEDEntity> {
130 
131  public:
132 
133  virtual void operator()(CAbstractSpaceHash<CLEDEntity>& c_space_hash,
134  CLEDEntity& c_element);
135 
136  private:
137 
138  SInt32 m_nI, m_nJ, m_nK;
139 
140  };
141 
142  /****************************************/
143  /****************************************/
144 
145  class CLEDEntityGridUpdater : public CGrid<CLEDEntity>::COperation {
146 
147  public:
148 
150  virtual bool operator()(CLEDEntity& c_entity);
151 
152  private:
153 
154  CGrid<CLEDEntity>& m_cGrid;
155  SInt32 m_nI, m_nJ, m_nK;
156 
157  };
158 
159  /****************************************/
160  /****************************************/
161 
162 }
163 
164 #endif
signed int SInt32
32-bit signed integer.
Definition: datatypes.h:93
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
Basic class for an entity that contains other entities.
The abstract definition of a space hash.
Definition: space_hash.h:34
Defines the basic cell updater of the space hash.
Definition: space_hash.h:269
The basic color type.
Definition: color.h:25
Defines a very simple double-linked list that stores unique elements.
Definition: set.h:101
A 3D vector class.
Definition: vector3.h:31
void SetInitColor(const CColor &c_color)
Sets the initialization color for this LED.
Definition: led_entity.h:87
bool HasMedium() const
Returns true if this LED is associated to a medium.
Definition: led_entity.h:100
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or the standalone constructor was call...
Definition: led_entity.cpp:55
CLEDMedium * m_pcMedium
Definition: led_entity.h:122
void SetColor(const CColor &c_color)
Sets the current color of the LED.
Definition: led_entity.cpp:87
virtual std::string GetTypeDescription() const
Returns a string label for this class.
Definition: led_entity.h:91
CSet< CLEDEntity * > TSet
Definition: led_entity.h:31
virtual void SetEnabled(bool b_enabled)
Enables or disables an entity.
Definition: led_entity.cpp:69
CLEDEntity(CComposableEntity *pc_parent)
Definition: led_entity.cpp:17
virtual void Destroy()
Destroys the entity, undoing whatever was done by Init() or by the standalone constructor.
Definition: led_entity.cpp:62
CLEDMedium & GetMedium() const
Returns the medium associated to this LED.
Definition: led_entity.cpp:94
void SetMedium(CLEDMedium &c_medium)
Sets the medium associated to this entity.
Definition: led_entity.cpp:104
const CColor & GetColor() const
Returns the current color of the LED.
Definition: led_entity.h:58
const CColor & GetInitColor() const
Returns the color with which the LED was initialized.
Definition: led_entity.h:69
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
Definition: led_entity.cpp:40
virtual ~CLEDEntity()
Definition: led_entity.h:42
std::vector< CLEDEntity * > TList
Definition: led_entity.h:30
virtual void operator()(CAbstractSpaceHash< CLEDEntity > &c_space_hash, CLEDEntity &c_element)
Updates the necessary cells of a space hash.
Definition: led_entity.cpp:113
virtual bool operator()(CLEDEntity &c_entity)
Definition: led_entity.cpp:133
CLEDEntityGridUpdater(CGrid< CLEDEntity > &c_grid)
Definition: led_entity.cpp:127