Overte C++ Documentation
EntityNodeData.h
1 //
2 // EntityNodeData.h
3 // libraries/entities/src
4 //
5 // Created by Brad Hefta-Gaub on 4/29/14
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_EntityNodeData_h
13 #define hifi_EntityNodeData_h
14 
15 #include <udt/PacketHeaders.h>
16 
17 #include <OctreeQueryNode.h>
18 
19 namespace EntityJSONQueryProperties {
20  static const QString SERVER_SCRIPTS_PROPERTY = "serverScripts";
21  static const QString FLAGS_PROPERTY = "flags";
22  static const QString INCLUDE_ANCESTORS_PROPERTY = "includeAncestors";
23  static const QString INCLUDE_DESCENDANTS_PROPERTY = "includeDescendants";
24 }
25 
26 class EntityNodeData : public OctreeQueryNode {
27 public:
28  virtual PacketType getMyPacketType() const override { return PacketType::EntityData; }
29 
30  quint64 getLastDeletedEntitiesSentAt() const { return _lastDeletedEntitiesSentAt; }
31  void setLastDeletedEntitiesSentAt(quint64 sentAt) { _lastDeletedEntitiesSentAt = sentAt; }
32 
33  // these can only be called from the OctreeSendThread for the given Node
34  void insertSentFilteredEntity(const QUuid& entityID) { _sentFilteredEntities.insert(entityID); }
35  void removeSentFilteredEntity(const QUuid& entityID) { _sentFilteredEntities.remove(entityID); }
36  bool sentFilteredEntity(const QUuid& entityID) const { return _sentFilteredEntities.contains(entityID); }
37  QSet<QUuid> getSentFilteredEntities() { return _sentFilteredEntities; }
38 
39  // the following flagged extra entity methods can only be called from the OctreeSendThread for the given Node
40 
41  // inserts the extra entity and returns a boolean indicating wether the extraEntityID was a new addition
42  bool insertFlaggedExtraEntity(const QUuid& filteredEntityID, const QUuid& extraEntityID);
43 
44  bool isEntityFlaggedAsExtra(const QUuid& entityID) const;
45  void resetFlaggedExtraEntities() { _previousFlaggedExtraEntities = _flaggedExtraEntities; _flaggedExtraEntities.clear(); }
46 
47 private:
48  quint64 _lastDeletedEntitiesSentAt { usecTimestampNow() };
49  QSet<QUuid> _sentFilteredEntities;
50  QHash<QUuid, QSet<QUuid>> _flaggedExtraEntities;
51  QHash<QUuid, QSet<QUuid>> _previousFlaggedExtraEntities;
52 };
53 
54 #endif // hifi_EntityNodeData_h