Overte C++ Documentation
DeleteEntityOperator.h
1 //
2 // DeleteEntityOperator.h
3 // libraries/entities/src
4 //
5 // Created by Brad Hefta-Gaub on 8/11/2014.
6 // Copyright 2014 High Fidelity, Inc.
7 //
8 // Distributed under the Apache License, Version 2.0.
9 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
10 //
11 
12 #ifndef hifi_DeleteEntityOperator_h
13 #define hifi_DeleteEntityOperator_h
14 
15 #include <QSet>
16 
17 #include <AACube.h>
18 
19 #include "EntityItem.h"
20 
21 class EntityToDeleteDetails {
22 public:
23  EntityItemPointer entity;
24  AACube cube;
25  EntityTreeElementPointer containingElement;
26 };
27 
28 typedef QSet<EntityToDeleteDetails> RemovedEntities;
29 
30 inline uint qHash(const EntityToDeleteDetails& a, uint seed) {
31  return qHash(a.entity->getEntityItemID(), seed);
32 }
33 
34 inline bool operator==(const EntityToDeleteDetails& a, const EntityToDeleteDetails& b) {
35  return a.entity->getEntityItemID() == b.entity->getEntityItemID();
36 }
37 
38 class DeleteEntityOperator : public RecurseOctreeOperator {
39 public:
40  DeleteEntityOperator(EntityTreePointer tree);
41  DeleteEntityOperator(EntityTreePointer tree, const EntityItemID& searchEntityID);
42  ~DeleteEntityOperator();
43 
44  void addEntityIDToDeleteList(const EntityItemID& searchEntityID);
45  void addEntityToDeleteList(const EntityItemPointer& entity);
46  virtual bool preRecursion(const OctreeElementPointer& element) override;
47  virtual bool postRecursion(const OctreeElementPointer& element) override;
48 
49  const RemovedEntities& getEntities() const { return _entitiesToDelete; }
50 private:
51  EntityTreePointer _tree;
52  RemovedEntities _entitiesToDelete;
53  quint64 _changeTime;
54  int _foundCount;
55  int _lookingCount;
56  bool subTreeContainsSomeEntitiesToDelete(const OctreeElementPointer& element);
57 };
58 
59 #endif // hifi_DeleteEntityOperator_h
Abstract ID for editing model items. Used in EntityItem JS API.
Definition: EntityItemID.h:28
derive from this class to use the Octree::recurseTreeWithOperator() method
Definition: Octree.h:43