tag_entity.h
Go to the documentation of this file.
1 
7 #ifndef TAG_ENTITY_H
8 #define TAG_ENTITY_H
9 
10 namespace argos {
11  class CTagEntity;
12  class CTagMedium;
13 }
14 
15 #include <argos3/core/simulator/entity/positional_entity.h>
16 #include <argos3/core/utility/datatypes/set.h>
17 #include <argos3/core/utility/math/vector3.h>
18 #include <argos3/core/simulator/space/positional_indices/space_hash.h>
19 #include <argos3/core/simulator/space/positional_indices/grid.h>
20 
21 namespace argos {
22 
23  class CTagEntity : public CPositionalEntity {
24 
25  public:
26 
28 
29  typedef std::vector<CTagEntity*> TList;
31 
32  public:
33 
34  CTagEntity(CComposableEntity* pc_parent);
35 
36  CTagEntity(CComposableEntity* pc_parent,
37  const std::string& str_id,
38  const CVector3& c_position,
39  const CQuaternion& c_orientation,
40  const CRadians& c_observable_angle,
41  Real f_side_length,
42  const std::string& str_payload);
43 
44  virtual ~CTagEntity() {}
45 
46  virtual void Init(TConfigurationNode& t_tree);
47 
48  virtual void Reset();
49 
50  virtual void Destroy();
51 
52  virtual void SetEnabled(bool b_enabled);
53 
60  inline const std::string& GetPayload() const {
61  return m_strPayload;
62  }
63 
68  inline const CRadians& GetObservableAngle() const {
69  return m_cObservableAngle;
70  }
71 
76  inline Real GetSideLength() const {
77  return m_fSideLength;
78  }
79 
87  inline const std::string& GetInitPayload() const {
88  return m_strInitPayload;
89  }
90 
96  void SetPayload(const std::string& str_payload);
97 
105  inline void SetInitPayload(const std::string& str_payload) {
106  m_strInitPayload = str_payload;
107  }
108 
109  virtual std::string GetTypeDescription() const {
110  return "tag";
111  }
112 
118  inline bool HasMedium() const {
119  return m_pcMedium != nullptr;
120  }
121 
127  CTagMedium& GetMedium() const;
128 
134  void SetMedium(CTagMedium& c_medium);
135 
136 
137  protected:
138 
141  std::string m_strPayload;
142  std::string m_strInitPayload;
144 
145  };
146 
147  /****************************************/
148  /****************************************/
149 
150  class CTagEntitySpaceHashUpdater : public CSpaceHashUpdater<CTagEntity> {
151 
152  public:
153 
154  virtual void operator()(CAbstractSpaceHash<CTagEntity>& c_space_hash,
155  CTagEntity& c_element);
156 
157  private:
158 
159  SInt32 m_nI, m_nJ, m_nK;
160 
161  };
162 
163  /****************************************/
164  /****************************************/
165 
166  class CTagEntityGridUpdater : public CGrid<CTagEntity>::COperation {
167 
168  public:
169 
171  virtual bool operator()(CTagEntity& c_entity);
172 
173  private:
174 
175  CGrid<CTagEntity>& m_cGrid;
176  SInt32 m_nI, m_nJ, m_nK;
177 
178  };
179 
180  /****************************************/
181  /****************************************/
182 
183 }
184 
185 #endif
signed int SInt32
32-bit signed integer.
Definition: datatypes.h:93
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
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
Defines a very simple double-linked list that stores unique elements.
Definition: set.h:101
It defines the basic type CRadians, used to store an angle value in radians.
Definition: angles.h:42
A 3D vector class.
Definition: vector3.h:31
virtual void SetEnabled(bool b_enabled)
Enables or disables an entity.
Definition: tag_entity.cpp:80
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or the standalone constructor was call...
Definition: tag_entity.cpp:66
CTagMedium & GetMedium() const
Returns the medium associated to this tag.
Definition: tag_entity.cpp:105
void SetPayload(const std::string &str_payload)
Sets the current payload of the tag.
Definition: tag_entity.cpp:98
void SetInitPayload(const std::string &str_payload)
Sets the initialization payload for this tag.
Definition: tag_entity.h:105
const std::string & GetPayload() const
Returns the current payload of the tag.
Definition: tag_entity.h:60
const CRadians & GetObservableAngle() const
Returns the observable angle of the tag.
Definition: tag_entity.h:68
void SetMedium(CTagMedium &c_medium)
Sets the medium associated to this entity.
Definition: tag_entity.cpp:116
CRadians m_cObservableAngle
Definition: tag_entity.h:139
CSet< CTagEntity * > TSet
Definition: tag_entity.h:30
virtual void Destroy()
Destroys the entity, undoing whatever was done by Init() or by the standalone constructor.
Definition: tag_entity.cpp:73
bool HasMedium() const
Returns true if this tag is associated to a medium.
Definition: tag_entity.h:118
virtual std::string GetTypeDescription() const
Returns a string label for this class.
Definition: tag_entity.h:109
CTagEntity(CComposableEntity *pc_parent)
Definition: tag_entity.cpp:17
std::string m_strPayload
Definition: tag_entity.h:141
std::string m_strInitPayload
Definition: tag_entity.h:142
CTagMedium * m_pcMedium
Definition: tag_entity.h:143
std::vector< CTagEntity * > TList
Definition: tag_entity.h:29
virtual ~CTagEntity()
Definition: tag_entity.h:44
const std::string & GetInitPayload() const
Returns the payload with which the tag was initialized.
Definition: tag_entity.h:87
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
Definition: tag_entity.cpp:47
Real GetSideLength() const
Returns the side length of the tag.
Definition: tag_entity.h:76
virtual void operator()(CAbstractSpaceHash< CTagEntity > &c_space_hash, CTagEntity &c_element)
Updates the necessary cells of a space hash.
Definition: tag_entity.cpp:125
CTagEntityGridUpdater(CGrid< CTagEntity > &c_grid)
Definition: tag_entity.cpp:136
virtual bool operator()(CTagEntity &c_entity)
Definition: tag_entity.cpp:142