8#include "daq/slc/system/BufferedWriter.h"
10#include <daq/slc/base/IOException.h>
16BufferedWriter::BufferedWriter()
17 : m_memory(NULL), m_size(0), m_pos(0), m_allocated(false) {}
19BufferedWriter::BufferedWriter(
size_t size,
unsigned char* memory)
20 : m_memory(memory), m_size(size), m_pos(0), m_allocated(false)
23 m_memory =
new unsigned char[size];
29 : m_memory(NULL), m_size(writer.m_size),
30 m_pos(writer.m_pos), m_allocated(writer.m_allocated)
33 m_memory =
new unsigned char [writer.m_size];
34 ::memcpy(m_memory, writer.m_memory, writer.m_size);
36 m_memory = writer.m_memory;
38 m_size = writer.m_size;
42BufferedWriter::~BufferedWriter()
44 if (m_allocated && m_memory != NULL)
delete [] m_memory;
52 m_allocated = writer.m_allocated;
54 m_memory =
new unsigned char [writer.m_size];
55 ::memcpy(m_memory, writer.m_memory, writer.m_size);
57 m_memory = writer.m_memory;
59 m_size = writer.m_size;
64size_t BufferedWriter::write(
const void* buf,
const size_t count)
66 if (m_pos + count > m_size) {
68 (
int)m_pos, (
int)count, (
int)m_size));
70 memcpy((m_memory + m_pos), buf, count);
Abstract base class for different kinds of events.