00001 #ifndef __INSTANTIO_DECODER_H
00002 #define __INSTANTIO_DECODER_H
00003
00004 #ifdef _MSC_VER
00005 # pragma once
00006 #endif
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "InstantIODef.h"
00027 #include "BasicDecoder.h"
00028 #include "OutSlot.h"
00029 #include <string>
00030 #ifdef __sgi
00031 # include <assert.h>
00032 #else
00033 # include <cassert>
00034 #endif
00035
00036
00037 namespace InstantIO
00038 {
00039
00040
00041 class BasicOutSlot;
00042
00043
00086 template <class T>
00087 class Decoder: public BasicDecoder
00088 {
00089 public:
00090
00092 virtual ~Decoder()
00093 { delete outSlot_; };
00094
00099 virtual BasicOutSlot *getOutSlot() const
00100 {
00101 assert(outSlot_ != 0);
00102 return outSlot_;
00103 };
00104
00110 virtual void initialize(const std::string &label, const std::string &description)
00111 {
00112 BasicDecoder::initialize(label, description);
00113 outSlot_ = new OutSlot<T>(description);
00114 };
00115
00125 virtual T decode(std::istream &is) = 0;
00126
00127 protected:
00128
00130 inline Decoder(): BasicDecoder(), outSlot_(0) {}
00131
00138 virtual void decodeAndPush(std::istream &is, TimeStamp timeStamp)
00139 {
00140 assert(outSlot_ != 0);
00141 Data<T> data;
00142 data.setValue(decode(is));
00143 data.setTimeStamp(timeStamp);
00144 outSlot_->push(data);
00145 };
00146
00147 private:
00148
00150 Decoder(const Decoder<T> &);
00151
00153 const Decoder<T> &operator=(const Decoder<T> &);
00154
00156 OutSlot<T> *outSlot_;
00157 };
00158
00159
00160 }
00161
00162
00163 #endif // __INSTANTIO_DECODER_H