File: HDFWriteBuffer.hpp

package info (click to toggle)
pbseqlib 5.3.5%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,020 kB
  • sloc: cpp: 77,250; python: 331; sh: 103; makefile: 41
file content (49 lines) | stat: -rw-r--r-- 928 bytes parent folder | download | duplicates (4)
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
#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