src/graph/example/FileReader.h

00001 #ifndef HT_EXAMPLE_FILE_READER_
00002 #define HT_EXAMPLE_FILE_READER_
00003 
00004 #include <graph/NodeBase.h>
00005 #include <fstream>
00006 
00007 namespace ht {
00008     namespace example {
00009 
00011         struct ByteBuffer
00012         {
00014             char buffer[1024];
00016             size_t count;
00017         };
00018 
00020         class BlockReader : public ht::graph::NodeBase
00021         {
00022         public:
00024             virtual void process(const ByteBuffer & buf) = 0;
00025         };
00026 
00028         class FileReader : public ht::graph::NodeBase
00029         {
00030             std::fstream stream_;
00031             BlockReader * next_;
00032         public:
00033             FileReader();
00034 
00035             /* Configure our input file, or use stdin. */
00036             void configure(const ht::options::Config *);
00037 
00038             /* Read blocks of data from the input and send it to the next node. */
00039             void start();
00040 
00041             /* Verify that we have somewhere to send blocks of data. */
00042             void configured();
00043 
00044             /* Connect this node to the next node in the graph. */
00045             void connect(ht::graph::Node *n);
00046         };
00047     }
00048 }
00049 
00050 
00051 #endif

Generated on Thu Jan 3 15:26:45 2008 by  doxygen 1.5.2