positional_index.h
Go to the documentation of this file.
1 #ifndef POSITIONAL_INDEX_H
2 #define POSITIONAL_INDEX_H
3 
4 namespace argos {
5  class CVector2;
6  class CVector3;
7  class CRay3;
8 }
9 
10 #include <argos3/core/utility/configuration/base_configurable_resource.h>
11 #include <argos3/core/utility/datatypes/datatypes.h>
12 #include <argos3/core/utility/datatypes/set.h>
13 #include <argos3/core/utility/math/vector2.h>
14 #include <argos3/core/utility/math/vector3.h>
15 #include <argos3/core/simulator/entity/entity.h>
16 
17 #include <string>
18 
19 namespace argos {
20 
29  template<class ENTITY>
31 
32  public:
33 
60  class COperation {
61  public:
62  virtual ~COperation() {}
63  virtual bool operator()(ENTITY&) = 0;
64  };
65 
66  public:
67 
69  virtual ~CPositionalIndex() {}
70 
71  virtual void Init(TConfigurationNode& t_tree) = 0;
72  virtual void Reset() = 0;
73  virtual void Destroy() = 0;
74 
79  virtual void AddEntity(ENTITY& c_entity) = 0;
80 
85  virtual void RemoveEntity(ENTITY& c_entity) = 0;
86 
90  virtual void Update() = 0;
91 
98  const CVector3& c_position) const = 0;
99 
105  virtual void ForAllEntities(COperation& c_operation) = 0;
106 
114  virtual void ForEntitiesInSphereRange(const CVector3& c_center,
115  Real f_radius,
116  COperation& c_operation) = 0;
117 
126  virtual void ForEntitiesInBoxRange(const CVector3& c_center,
127  const CVector3& c_half_size,
128  COperation& c_operation) = 0;
129 
138  virtual void ForEntitiesInCircleRange(const CVector3& c_center,
139  Real f_radius,
140  COperation& c_operation) = 0;
141 
150  virtual void ForEntitiesInRectangleRange(const CVector3& c_center,
151  const CVector2& c_half_size,
152  COperation& c_operation) = 0;
153 
165  virtual void ForEntitiesAlongRay(const CRay3& c_ray,
166  COperation& c_operation,
167  bool b_stop_at_closest_match = false) = 0;
168 
169  };
170 
171 }
172 
173 #endif
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.
A data structure that contains positional entities.
virtual void ForEntitiesInSphereRange(const CVector3 &c_center, Real f_radius, COperation &c_operation)=0
Executes an operation on all entities within the specified sphere range.
virtual void Update()=0
Updates this positional index.
virtual void RemoveEntity(ENTITY &c_entity)=0
Removes an entity from this index.
virtual void Reset()=0
Resets the resource.
virtual void AddEntity(ENTITY &c_entity)=0
Adds an entity to this index.
virtual void GetEntitiesAt(CSet< ENTITY *, SEntityComparator > &c_entities, const CVector3 &c_position) const =0
Puts the entities located at the given point in the passed buffer.
virtual void Destroy()=0
Undoes whatever was done by Init().
virtual void ForEntitiesInRectangleRange(const CVector3 &c_center, const CVector2 &c_half_size, COperation &c_operation)=0
Executes an operation on all entities within the specified rectangle range.
virtual void ForEntitiesInBoxRange(const CVector3 &c_center, const CVector3 &c_half_size, COperation &c_operation)=0
Executes an operation on all entities within the specified box range.
virtual void ForEntitiesInCircleRange(const CVector3 &c_center, Real f_radius, COperation &c_operation)=0
Executes an operation on all entities within the specified circle range.
virtual void Init(TConfigurationNode &t_tree)=0
Initializes the resource.
virtual void ForAllEntities(COperation &c_operation)=0
Executes an operation on all the indexed entities.
virtual void ForEntitiesAlongRay(const CRay3 &c_ray, COperation &c_operation, bool b_stop_at_closest_match=false)=0
Executes an operation on all entities that intersect the given ray.
The operation to perform on each entity found in range.
virtual bool operator()(ENTITY &)=0
This class is the base of all XML-configurable ARGoS interface.
Defines a very simple double-linked list that stores unique elements.
Definition: set.h:101
A 2D vector class.
Definition: vector2.h:27
A 3D vector class.
Definition: vector3.h:31