29#ifndef BINARYSTORAGEBUFFER_H
30#define BINARYSTORAGEBUFFER_H
36#define MAX_BUFF 10000000
38#define MAX_BUCKET 500000000
79 void store (
void* stream,
unsigned int nb_bytes);
86 std::cout<<
"BinaryStorageBuffer::set_buff";
95 if(
_buff == NULL)
fatal(
"BinaryStorageBuffer::set_buff::memory exhausted !!\n");
108 std::cout<<
"[ok]"<<std::endl;
118 _buff =
new char [length];
120 memcpy(
_buff, zone, length);
136 std::cout<<
"BinaryStorageBuffer::extend_buff"<<std::flush;
139 char *old_buff, *new_buff;
145 if(new_buff == NULL)
fatal(
"BinaryStorageBuffer::extend_buff::memory exhausted !!\n");
156 std::cout<<
"["<<
_len<<
" B]"<<std::endl;
162 inline void read (
void *out,
unsigned int nb_bytes)
166 fatal(
"BinaryStorageBuffer::read::attempt to read beyond buffer length (asked %i bytes)\n",nb_bytes);
168 char *tab = (
char*)out;
172 for(
unsigned int i = 0; i < nb_bytes; ++i)
179 void BSBread(
void *out,
unsigned int nb_bytes)
180 {
read(out,nb_bytes); }
#define MAX_BUFF
Definition: binarystoragebuffer.h:36
A class to handle simulation data saving in binary format.
Definition: binarydatasaver.h:44
A class to store any kind of data in a char buffer before unloading it in a binary data file.
Definition: binarystoragebuffer.h:44
void read(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:162
off_t getBuffLength() const
Definition: binarystoragebuffer.h:60
off_t _tot_bytes_in
Definition: binarystoragebuffer.h:49
unsigned int _num_buckets
Definition: binarystoragebuffer.h:48
void emptyBuffer()
Definition: binarystoragebuffer.h:71
unsigned int getBytesOut() const
Definition: binarystoragebuffer.h:62
char * _buff
Definition: binarystoragebuffer.h:47
off_t _len
Definition: binarystoragebuffer.h:49
void set_buff(BinaryDataSaver *owner)
Definition: binarystoragebuffer.h:83
void clear()
Definition: binarystoragebuffer.h:63
off_t getTotByteRecorded() const
Definition: binarystoragebuffer.h:61
BinaryDataSaver * _myDataSaver
Definition: binarystoragebuffer.h:51
off_t _bytes_out
Definition: binarystoragebuffer.h:49
BinaryStorageBuffer()
Definition: binarystoragebuffer.h:55
off_t _bytes_in
Definition: binarystoragebuffer.h:49
char * getBuffer() const
Definition: binarystoragebuffer.h:59
void store(void *stream, unsigned int nb_bytes)
Definition: binarystoragebuffer.cc:16
void set_buff(void *zone, size_t length)
Definition: binarystoragebuffer.h:114
void BSBread(void *out, unsigned int nb_bytes)
Definition: binarystoragebuffer.h:179
~BinaryStorageBuffer()
Definition: binarystoragebuffer.h:57
void extend_buff()
Definition: binarystoragebuffer.h:133
void fatal(const char *str,...)
Definition: output.cc:96