2022-05-27 18:26:48 +02:00
|
|
|
#ifndef GCRYPTCLI_DATAINGESTIONLAYER_H
|
|
|
|
#define GCRYPTCLI_DATAINGESTIONLAYER_H
|
|
|
|
|
2022-05-31 14:25:23 +02:00
|
|
|
#include <iosfwd>
|
|
|
|
#include <queue>
|
|
|
|
#include <GCrypt/Block.h>
|
|
|
|
|
|
|
|
using namespace Leonetienne::GCrypt;
|
2022-05-27 18:26:48 +02:00
|
|
|
|
|
|
|
namespace IO {
|
|
|
|
|
|
|
|
// This class is used to read in data.
|
|
|
|
class DataIngestionLayer {
|
|
|
|
public:
|
|
|
|
//! Will initialize the ingestion
|
|
|
|
static void Init();
|
|
|
|
|
2022-05-31 14:25:23 +02:00
|
|
|
//! Will attempt to read a data block.
|
|
|
|
//! Requires Init() to have been called
|
|
|
|
static void ReadBlock();
|
|
|
|
|
|
|
|
//! Have we read in all available blocks?
|
|
|
|
static bool ReachedEOF();
|
|
|
|
|
|
|
|
//! Will return true if there is at least one block to be GetBlock()'ed
|
|
|
|
static bool IsBlockReady();
|
|
|
|
|
|
|
|
//! Will return the next block in the queue
|
|
|
|
static Block GetNextBlock();
|
|
|
|
|
2022-05-27 18:26:48 +02:00
|
|
|
private:
|
|
|
|
static std::istream* in;
|
|
|
|
|
|
|
|
// We have to hold on to a reference to a filestream,
|
|
|
|
// even if we're always just reading from in.
|
|
|
|
// We still have to CLOSE the file handle afterwards!
|
|
|
|
static std::ifstream ifs;
|
|
|
|
static std::istringstream iss;
|
2022-05-31 14:25:23 +02:00
|
|
|
|
|
|
|
// Indicates whether EOF has been reached
|
|
|
|
static bool reachedEof;
|
|
|
|
// Indicates whether this class is initialized
|
|
|
|
static bool initialized;
|
|
|
|
|
|
|
|
// All read blocks, that haven't been given out yet
|
|
|
|
static std::queue<Block> blocks;
|
2022-05-31 14:28:17 +02:00
|
|
|
|
|
|
|
// No instanciation! >:(
|
|
|
|
DataIngestionLayer();
|
2022-05-27 18:26:48 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|