#ifndef INTERFACE_H #define INTERFACE_H #include #include #include #include "math.h" // filters to select which objects/variables (not) to select typedef std::set IfObjectFilter; typedef std::set IfElementFilter; // interface-class .. holds long-time stuff for reflecting on a per class (template), per file (instance) and per direction (class) basis template class InputInterface { public: // A. the methods you want to call // creation InputInterface(int fd, bool binary, IfObjectFilter ifo, IfElementFilter ife); bool readEntireFile(); bool readFileUntil(double time); double peekNextTime(); // read a line ahead (if possible) and check at what time it occurs // B. internal state bool binary; int fd; std::string buf; size_t rpos, npos, wpos; static const size_t buf_size = 32768; bool eof; IfObjectFilter ifo; IfElementFilter ife; // C. internal functions bool garantueeBuf(size_t size); // returns only after wpos - rpos >= size, but reads as much as possible without blocking bool garantueeLine(); template bool bufRead(Tval &val, bool proccedRPos); }; template class OutputInterface { public: OutputInterface(int fd, bool binary, IfObjectFilter *ifo, IfElementFilter *ife); bool pushObject(T *o); // serialize one object bool pushClass(); // serialize the entire class (selective by filter) bool isContained(typename T::id_type id); // internal state int fd; std::string buf; bool binary; IfObjectFilter *ifo; IfElementFilter *ife; // internal functions template bool bufWrite(Tval &val); }; #endif // INTERFACE_H