-
Notifications
You must be signed in to change notification settings - Fork 0
/
DiskBuffer.h
49 lines (42 loc) · 1.19 KB
/
DiskBuffer.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
/*
* File: DiskBuffer.h
* Class: ICS 451
* Project #: 3
* Team Members: Bryce Groff, Brandon Grant, Emiliano Miranda
* Author: Bryce Groff
* Created Date: 04-23-09
* Desc: Creates a buffer created on disk that can be written to.
*/
#ifndef _DISKBUFFER_H_
#define _DISKBUFFER_H_
#include <iostream>
#include <fstream>
#include <inttypes.h>
#include "Transmission.h"
#include "OutOfSeqCache.h"
#include "Mutex.h"
using namespace std;
/*! \class DiskBuffer
\brief Represents a place to store large amounts of information.
DiskBuffer opens a file on the disk and performs writes to the file.
Allows one to Add data, Get the sequence number of the last processed packet,
and has the ability to flush what is in memory to disk.
*/
class DiskBuffer {
public:
DiskBuffer(string &fileName, uint64_t fileSize, uint64_t nextSeq);
virtual ~DiskBuffer();
uint64_t Add(Data &);
uint64_t GetNextSeq();
uint32_t GetWindowSize();
void Flush();
private:
//Mutex mWriteLock;
OutOfSeqCache mOutOfSeqCache;
fstream mFile;
std::string mFileName;
uint64_t mFileSize;
uint64_t mNextSeq;
uint32_t mWindowSize;
};
#endif