It has been a while since I last worked on Aesalon proper.
[aesalon.git] / module / modules / dynamicMemory / renderer / TreeHead.h
blob9417855f602b2be224d4591de40e4c390232d2de
1 #ifndef TreeHead_H
2 #define TreeHead_H
4 #include <list>
6 #include "DataTypes.h"
7 #include "TreeNode.h"
9 class TreeHead {
10 public:
11 typedef std::list<Block *> BlockList;
12 TreeHead(uint32_t headID);
13 ~TreeHead();
14 private:
15 enum LookupMode {
16 CREATE = 0x01,
17 REMOVE = 0x02
20 uint32_t m_headID;
21 TreeNode *m_headNode;
22 BlockList m_changedList;
23 Timestamp m_timestamp;
24 public:
25 TreeNode *headNode() const { return m_headNode; }
26 Timestamp timestamp() const { return m_timestamp; }
27 void updateTimestamp(Timestamp timestamp) { m_timestamp = timestamp; }
29 void attachTo(TreeHead *tree);
31 const BlockList &changedList() const { return m_changedList; }
32 void appendChanged(Block *block) { m_changedList.push_back(block); }
34 /** Looks up a tree node.
35 @param address The address of the node to look up.
36 @return The node at @a address, or NULL if there is no block at that location.
38 TreeNode *lookup(uint64_t address);
40 /** Creates a tree node.
41 @param address The address of the new node.
42 @return A new node at @a address, or NULL if the node alreay exists.
44 TreeNode *create(uint64_t address);
46 /** Removes a tree node.
47 @param address The address of the node to remove.
48 @return True if the node was removed, false if removing the node would destroy data.
50 bool remove(uint64_t address);
52 /** Marks an address as changed.
53 @param address The address to mark.
55 void mark(uint64_t address);
56 private:
57 TreeNode *lookup(uint64_t address, int lookupMode);
60 #endif