Warning: include(php/utility.php): Failed to open stream: No such file or directory in /home/argos/argos3/doc/api/embedded/a00777_source.php on line 2

Warning: include(): Failed opening 'php/utility.php' for inclusion (include_path='.:/usr/lib64/php') in /home/argos/argos3/doc/api/embedded/a00777_source.php on line 2
The ARGoS Website

radio_entity.h
Go to the documentation of this file.
1 
7 #ifndef RADIO_ENTITY_H
8 #define RADIO_ENTITY_H
9 
10 namespace argos {
11  class CRadioEntity;
12  class CRadioMedium;
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/utility/datatypes/byte_array.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 
25 
26  public:
27 
28  ENABLE_VTABLE();
29 
30  public:
31 
32  typedef std::vector<CRadioEntity*> TList;
33 
34  public:
35 
36  CRadioEntity(CComposableEntity* pc_parent);
37 
39  const std::string& str_id,
40  Real f_transmit_range);
41 
42  virtual ~CRadioEntity() {}
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 
57  inline const std::vector<std::pair<CVector3, CByteArray> >& GetData() const {
58  return m_vecData;
59  }
60 
66  inline std::vector<std::pair<CVector3, CByteArray> >& GetData() {
67  return m_vecData;
68  }
69 
75  inline void ReceiveData(const CVector3& c_tx_location, const CByteArray& c_tx_data) {
76  m_vecData.emplace_back(c_tx_location, c_tx_data);
77  }
78 
85  inline bool HasData() const {
86  return !m_vecData.empty();
87  }
88 
94  inline Real GetRange() const {
95  return m_fRange;
96  }
97 
103  inline void SetRange(Real f_range) {
104  m_fRange = f_range;
105  }
106 
107  virtual std::string GetTypeDescription() const {
108  return "radio";
109  }
110 
116  inline bool HasMedium() const {
117  return m_pcMedium != nullptr;
118  }
119 
125  CRadioMedium& GetMedium() const;
126 
132  void SetMedium(CRadioMedium& c_medium);
133 
134  protected:
135 
137  std::vector<std::pair<CVector3, CByteArray> > m_vecData;
139 
140  };
141 
142  /****************************************/
143  /****************************************/
144 
145  class CRadioEntitySpaceHashUpdater : public CSpaceHashUpdater<CRadioEntity> {
146 
147  public:
148 
149  virtual void operator()(CAbstractSpaceHash<CRadioEntity>& c_space_hash,
150  CRadioEntity& c_element);
151 
152  private:
153 
154  SInt32 m_nI, m_nJ, m_nK;
155 
156  };
157 
158  /****************************************/
159  /****************************************/
160 
161  class CRadioEntityGridUpdater : public CGrid<CRadioEntity>::COperation {
162 
163  public:
164 
166  virtual bool operator()(CRadioEntity& c_entity);
167 
168  private:
169 
170  CGrid<CRadioEntity>& m_cGrid;
171  SInt32 m_nI, m_nJ, m_nK;
172 
173  };
174 
175  /****************************************/
176  /****************************************/
177 
178 }
179 
180 #endif
CRadioMedium * m_pcMedium
Definition: radio_entity.h:138
std::vector< std::pair< CVector3, CByteArray > > m_vecData
Definition: radio_entity.h:137
signed int SInt32
32-bit signed integer.
Definition: datatypes.h:93
A 3D vector class.
Definition: vector3.h:29
std::vector< CRadioEntity * > TList
Definition: radio_entity.h:32
void ReceiveData(const CVector3 &c_tx_location, const CByteArray &c_tx_data)
Adds data received by the radio.
Definition: radio_entity.h:75
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
The abstract definition of a space hash.
Definition: space_hash.h:34
virtual void Reset()
Resets the state of the entity to whatever it was after Init() or the standalone constructor was call...
Real GetRange() const
Returns the transmission range of the radio.
Definition: radio_entity.h:94
void SetMedium(CRadioMedium &c_medium)
Sets the medium associated to this entity.
ticpp::Element TConfigurationNode
The ARGoS configuration XML node.
virtual ~CRadioEntity()
Definition: radio_entity.h:42
CRadioMedium & GetMedium() const
Returns the medium associated to this radio.
virtual void Init(TConfigurationNode &t_tree)
Initializes the state of the entity from the XML configuration tree.
virtual void SetEnabled(bool b_enabled)
Enables or disables an entity.
Basic class for an entity that contains other entities.
bool HasMedium() const
Returns true if this radio is associated to a medium.
Definition: radio_entity.h:116
void SetRange(Real f_range)
Sets the tranmission range of the radio.
Definition: radio_entity.h:103
CRadioEntity(CComposableEntity *pc_parent)
virtual std::string GetTypeDescription() const
Returns a string label for this class.
Definition: radio_entity.h:107
Defines the basic cell updater of the space hash.
Definition: space_hash.h:269
Byte array utility class.
Definition: byte_array.h:28
virtual void Destroy()
Destroys the entity, undoing whatever was done by Init() or by the standalone constructor.
virtual void operator()(CAbstractSpaceHash< CRadioEntity > &c_space_hash, CRadioEntity &c_element)
Updates the necessary cells of a space hash.
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
CRadioEntityGridUpdater(CGrid< CRadioEntity > &c_grid)
bool HasData() const
Checks if there has been data received by the radio.
Definition: radio_entity.h:85
std::vector< std::pair< CVector3, CByteArray > > & GetData()
Returns a reference to the received data.
Definition: radio_entity.h:66
virtual bool operator()(CRadioEntity &c_entity)
const std::vector< std::pair< CVector3, CByteArray > > & GetData() const
Returns a constant reference to the received data.
Definition: radio_entity.h:57