File: HDFWriteBuffer.hpp

package info (click to toggle)
pbseqlib 0~20161219-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 5,924 kB
  • ctags: 5,123
  • sloc: cpp: 82,727; makefile: 305; python: 239; sh: 8
file content (53 lines) | stat: -rw-r--r-- 985 bytes parent folder | download | duplicates (2)
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
#ifndef _BLASR_HDF_WRITE_BUFFER_HPP_
#define _BLASR_HDF_WRITE_BUFFER_HPP_

#include <cstddef>
#include "../pbdata/utils.hpp"

template<typename T>
class HDFWriteBuffer {
public:
    T         *writeBuffer;
    int       bufferIndex;
    DSLength       bufferSize;

    HDFWriteBuffer() {
        writeBuffer = NULL;
        bufferIndex = 0;
        bufferSize  = 0;
    }

    void InitializeBuffer(int pBufferSize) {
        Free(); // Free before reusing the buffer.
        bufferSize = pBufferSize;
        if (bufferSize > 0) {
            writeBuffer = ProtectedNew<T>(bufferSize);
        }
        else {
            writeBuffer = NULL;
        }
    }		

    void Free() {
        if (writeBuffer) {
            delete[] writeBuffer;
            writeBuffer = NULL;
        }
    }

    ~HDFWriteBuffer() {
        Free();
    }

    void ResetWriteBuffer() {
        bufferIndex = 0;
    }

    bool WriteBufferEmpty() {
        return (bufferIndex == 0);
    }

};


#endif