-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtree.h
38 lines (27 loc) · 848 Bytes
/
tree.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#ifndef TOG_TREE_H
#define TOG_TREE_H
#include <string>
#include <unordered_map>
#include "blob.h"
#include "handle.h"
#include "object.h"
namespace tog {
class Tree : public TogObject {
public:
Tree(std::unordered_map<std::string, Handle<Blob>> &&blobs,
std::unordered_map<std::string, Handle<Tree>> &&trees);
const std::vector<unsigned char> &serialize();
std::unordered_map<std::string, Handle<Blob>> &blobs() {
return _blobs;
}
std::unordered_map<std::string, Handle<Tree>> &trees() {
return _trees;
}
private:
// cached serialized tree, for lazy serialization
std::optional<std::vector<unsigned char>> _serialized;
std::unordered_map<std::string, Handle<Blob>> _blobs;
std::unordered_map<std::string, Handle<Tree>> _trees;
};
} // namespace tog
#endif // TOG_TREE_H