// (C) 2017 University of Bristol. See License.txt /* * Buffer.h * */ #ifndef PROCESSOR_BUFFER_H_ #define PROCESSOR_BUFFER_H_ #include using namespace std; #include "Math/Share.h" #include "Math/field_types.h" #include "Tools/time-func.h" #ifndef BUFFER_SIZE #define BUFFER_SIZE 101 #endif class BufferBase { protected: static bool rewind; ifstream* file; int next; const char* data_type; Timer timer; int tuple_length; public: bool eof; BufferBase() : file(0), next(BUFFER_SIZE), data_type(0), tuple_length(-1), eof(false) {}; void setup(ifstream* f, int length, const char* type = 0); void seekg(int pos); bool is_up() { return file != 0; } }; template class Buffer : public BufferBase { T buffer[BUFFER_SIZE]; void read(char* read_buffer); public: ~Buffer(); void input(U& a); void fill_buffer(); }; template < template class U, template class V > class BufferHelper { public: Buffer< U, V > bufferp; Buffer< U, V > buffer2; ifstream* files[N_DATA_FIELD_TYPE]; BufferHelper() { memset(files, 0, sizeof(files)); } void input(V& a) { bufferp.input(a); } void input(V& a) { buffer2.input(a); } BufferBase& get_buffer(DataFieldType field_type); void setup(DataFieldType field_type, string filename, int tuple_length, const char* data_type = 0); void close(); }; #endif /* PROCESSOR_BUFFER_H_ */