-
Notifications
You must be signed in to change notification settings - Fork 2
/
DataBlockList.h
80 lines (65 loc) · 1.88 KB
/
DataBlockList.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* File: DataBlockList.h
* Author: Tobias Fleig <tobifleig@gmail.com>
*
* Created on September 16, 2015, 11:44 PM
*/
#ifndef SDI4FS_DATABLOCKLIST_H
#define SDI4FS_DATABLOCKLIST_H
#include "Block.h"
#include <cstdint>
#include <list>
#include <vector>
#include "StreamSelectorHeader.inc"
namespace SDI4FS {
/**
* A DataBlockList is a block that contains links to file contents (DataBlocks).
* A DataBlockList must always be referenced by exactly one FileINode.
*/
class DataBlockList : public Block {
public:
/**
* Creates a DataBlockList by reading contents from the stream.
* Will read up to SDI4FS_BLOCK_SIZE bytes from the stream.
* The caller must call seekg beforehand.
* @param input the stream to read from
*/
DataBlockList(STREAM &input);
/**
* Creates a new DataBlockList with the given parameters.
* @param id the new unique block id
*/
DataBlockList(uint32_t id);
/**
* Adds the given blockID to this DataBlockList.
* @param id the blockID to add
* @return true, iff successful (DataBlockList not full)
*/
bool pushDataBlock(uint32_t id);
/**
* Removes and returns the last stored blockID.
* @return the now removed blockID
*/
uint32_t popDataBlock();
/**
* Returns the stored DataBlock blockID with the given index.
* @param index the requested index
* @return stored blockID or zero
*/
uint32_t getDataBlock(size_t index);
/**
* Fills the given list with the blockIDs of all blocks currently
* stored in this DataBlockList.
* @param result the list to fill
*/
void blocks(std::list<uint32_t> &result);
virtual void save(STREAM &output);
virtual ~DataBlockList();
private:
/**
* Content of this DataBlockList.
*/
std::vector<uint32_t> entries;
};
} // SDI4FS
#endif // SDI4FS_DATABLOCKLIST_H