Overte C++ Documentation
OctreeDataUtils.h
1 //
2 // OctreeDataUtils.h
3 // libraries/octree/src
4 //
5 // Created by Ryan Huffman 2018-02-26
6 // Copyright 2018 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 #ifndef hifi_OctreeDataUtils_h
12 #define hifi_OctreeDataUtils_h
13 
14 #include <udt/PacketHeaders.h>
15 
16 #include <QJsonObject>
17 #include <QUuid>
18 #include <QJsonArray>
19 
20 namespace OctreeUtils {
21 
22 using Version = int64_t;
23 constexpr Version INITIAL_VERSION = 0;
24 
25 //using PacketType = uint8_t;
26 
27 // RawOctreeData is an intermediate format between JSON and a fully deserialized Octree.
28 class RawOctreeData {
29 public:
30  QUuid id { QUuid() };
31  Version dataVersion { -1 };
32  Version version { -1 };
33 
34  virtual PacketType dataPacketType() const;
35 
36  virtual void readSubclassData(const QVariantMap& root) { }
37  virtual void writeSubclassData(QByteArray& root) const { }
38 
39  void resetIdAndVersion();
40  QByteArray toByteArray();
41  QByteArray toGzippedByteArray();
42 
43  bool readOctreeDataInfoFromData(QByteArray data);
44  bool readOctreeDataInfoFromFile(QString path);
45  bool readOctreeDataInfoFromMap(const QVariantMap& map);
46 };
47 
48 class RawEntityData : public RawOctreeData {
49 public:
50  PacketType dataPacketType() const override;
51  void readSubclassData(const QVariantMap& root) override;
52  void writeSubclassData(QByteArray& root) const override;
53 
54  QVariantList variantEntityData;
55 };
56 
57 }
58 
59 #endif // hifi_OctreeDataUtils_h