Fire Core  8.0.0.alpha
GIS framework per tutti gli usi
 Tutto Classi Namespace Funzioni Variabili Ridefinizioni di tipo (typedef) Tipi enumerati (enum) Valori del tipo enumerato Friend
Group.hpp
1 // Copyright 2015 GEOSYSTEMS SRL
2 // All Rights Reserved.
3 
4 #ifndef FIRE_GEAR_GROUP__HPP_INCLUDED
5 #define FIRE_GEAR_GROUP__HPP_INCLUDED
6 
7 #include <geos/index/SpatialIndex.h>
8 
9 #include <boost/smart_ptr/shared_ptr.hpp>
10 
11 #include <exception>
12 #include <vector>
13 
14 #include "fire/export.hpp"
15 
16 #include "fire/Group.hpp"
17 #include "fire/gear/geom/SpatialIndexType.hpp"
18 #include "fire/gear/Filter.hpp"
19 #include "fire/gear/event/EntityEventListener.hpp"
20 #include "fire/gear/event/EntityEvent.hpp"
21 
22 namespace fire {
23 namespace gear {
24 class Entity;
25 } // namespace gear
26 } // namespace fire
27 
34 namespace fire {
41 namespace gear {
48 class FIRE_ENGINE_DLL Group : public fire::Group< Entity* > {
49  private:
56  class EntityEventListener : public gear::event::EntityEventListener {
57  private:
64  Group* _group;
65 
66  public:
78  explicit EntityEventListener(Group* group) {
79  try {
80  _group = group;
81  } catch (const std::exception& exception) {
82  throw;
83  }
84  }
85 
91  void handle(const gear::event::EntityEvent& entityEvent) {
92  try {
93  Entity* entity = entityEvent.getEntity();
94  switch (entityEvent.getType()) {
95  case gear::event::EntityEventType::Unknown:
96  case gear::event::EntityEventType::AfterDestroy: {
97  break;
98  }
99  case gear::event::EntityEventType::BeforeUpdate: {
100  _group->beforeUpdate(entity);
101  break;
102  }
103  case gear::event::EntityEventType::AfterUpdate: {
104  _group->afterUpdate(entity);
105  break;
106  }
107  case gear::event::EntityEventType::BeforeDestroy: {
108  _group->exclude(entity);
109  break;
110  }
111  }
112  } catch (const std::exception& exception) {
113  throw;
114  }
115  }
116  };
117 
118  private:
132  boost::shared_ptr< geos::index::SpatialIndex > _spatialIndex;
139  int _srid;
146  Group::EntityEventListener* _entityEventListener;
163  void InitSpatialIndexSrid(const geom::SpatialIndexType::SpatialIndexType& spatialIndexType, const int& srid);
164 
165  public:
170  Group();
179  explicit Group(const geom::SpatialIndexType::SpatialIndexType& spatialIndexType);
189  Group(const geom::SpatialIndexType::SpatialIndexType& spatialIndexType, const int& srid);
196  explicit Group(fire::Group< Entity* > group);
203  Group(const Group& group);
210  Group& operator=(const Group& group);
215  virtual ~Group();
227  void include(Entity* entity);
240  void exclude(Entity* entity);
248  void clear();
266  bool contains(Entity* entity) const;
284  Group filter(const Filter& filter) const;
302  Group operator%(const Filter& filter) const;
315  void applySpatialIndex(const geom::SpatialIndexType::SpatialIndexType& spatialIndexType);
332  void applySpatialIndex(const geom::SpatialIndexType::SpatialIndexType& spatialIndexType, const int& srid);
339  void revokeSpatialIndex();
351  bool isIndexed();
363  void setSrid(int srid);
375  void beforeUpdate(Entity* entity);
387  void afterUpdate(Entity* entity);
399  std::vector< geom::Geometry* > toGeometryVector() const;
416  std::vector< Entity* > spatialIndexQuery(Entity* entity, int& spatialSize, int& depth);
417 };
418 } // namespace gear
419 } // namespace fire
420 
421 #endif
fire::gear::event::EntityEventType::EntityEventType getType() const
Restituisce il tipo dell'evento di entità
fire::gear::Entity * getEntity() const
Restituisce l'entità dell'evento.
Definition: Entity.hpp:44
Definition: Group.hpp:48
Classe per la gestione di un ascoltatore di un evento di entità
Definition: EntityEventListener.hpp:34
Classe per la gestione di un eventi di entità
Definition: EntityEvent.hpp:39
Classe per la gestione di un gruppo di oggetti generici.
Definition: Group.hpp:33
classe che specializza la classe template fire::Filter con la classe Entity la classe Filter e' utili...
Definition: Filter.hpp:47
SpatialIndexType
Definition: SpatialIndexType.hpp:41