00001
00002
00003 #ifndef TessToolDataStream_h
00004 #define TessToolDataStream_h
00005
00006 #include <string>
00007 #include <cc++/thread.h>
00008 #include <mpi.h>
00009 #include <sstream>
00010 #include "RecordStream_Ascii.h"
00011
00012 #include <RecordType.h>
00013
00014 #ifdef CCXX_NAMESPACES
00015 using namespace std;
00016 using namespace ost;
00017 #endif
00018
00019 namespace BIE {
00020
00021
00023 class TessToolDataStream: public Thread
00024 {
00025 public:
00026
00027
00028 TessToolDataStream();
00029
00030 virtual void run() = 0;
00031
00032 RecordType *GetRecordType() { return _rtype; }
00033 int readBuffer(unsigned char* val, int size);
00034 Semaphore *getSemaphore() { return _tsem; }
00035 void setConsumerSemaphore(Semaphore *consumer) { _consumerSem = consumer; }
00036
00037 void SynchronizeCommand();
00038 virtual bool isConnectedToTessToolSender() { return false; }
00039
00040 protected:
00041
00042 virtual void GetData() = 0;
00043 virtual void Synchronize() = 0;
00044 void notifyConsumer();
00045 bool parse_command();
00046
00047 char *_name;
00048 bool _first;
00049
00050 int _bufSizeInWords;
00051 int _numRecordsInBuffer;
00052
00053 RecordType *_rtype;
00054 int _typeSizeInBytes;
00055 char *_scratchDtypeBuffer;
00056 int _scratchBufferSizeInWords;
00057
00058 int filter_recordSize;
00059
00060 void *_currentBuffer;
00061 void *_currentBufferPointer;
00062 void *_currentBufferEnd;
00063
00064
00065 string _str;
00066 istringstream *_iss;
00067 RecordInputStream_Ascii * _ris;
00068
00069 Semaphore *_tsem;
00070 Semaphore *_consumerSem;
00071
00072 char _tcmd[1024];
00073 };
00074 }
00075 #endif