Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals

DCFsbistream.h

Go to the documentation of this file.
00001 // DCFsbistream.h
00002 //////////////////////////////////////////////////////////////////////
00003 //          (c) Copyright 2001-2002 Brown Deer Technology, LLC.
00004 //                        All rights reserved.
00005 //////////////////////////////////////////////////////////////////////
00006 
00007 #ifndef DCFSBISTREAM_H
00008 #define DCFSBISTREAM_H
00009 
00010 #ifdef USE_STD
00011 #include <iostream>
00012 #include <string>
00013 using namespace std;
00014 #else
00015 #include <iostream.h>
00016 #include <string.h>
00017 #endif
00018 
00019 #include "DCFsbistreamBase.h"
00020 #include "DCFencode.h"
00021 #include "DCFmpacket.h"
00022 
00023 template <class Data_t>
00024 class DCFsbistream : public DCFsbistreamBase 
00025 {
00026    public:
00027       DCFsbistream( istream& is = cin );
00028       ~DCFsbistream();
00029       void descr();
00030       virtual void open();
00031       DCFsbistream<Data_t>& operator>>( Data_t& );
00032       DCFencode<Data_t> _enc;
00033 };
00034 
00035 template < class Data_t >
00036 DCFsbistream<Data_t>::DCFsbistream( istream& is) 
00037   : DCFsbistreamBase( is ) 
00038 {
00039    _enctype = _enc.enctype();
00040    _encsizeb = _enc.encsizeb();
00041 }
00042 
00043 template < class Data_t >
00044 DCFsbistream<Data_t>::~DCFsbistream() { }
00045 
00046 template < class Data_t >
00047 void DCFsbistream<Data_t>::descr() 
00048 {
00049     DCFsbistreamBase::descr();
00050     _enc.descr();
00051 }
00052 
00053 template < class Data_t >
00054 void DCFsbistream<Data_t>::open() 
00055 {
00056    DCFsbistreamBase::open();
00057    (*_is) >> _enc;
00058 }
00059 
00060 template < class Data_t >
00061 DCFsbistream<Data_t>& DCFsbistream<Data_t>::operator>>( Data_t& x) 
00062 {
00063    DCFmpacket<Data_t> mp( DCF_DEFAULT_MPACKET, _bplen_sizeb, _bplen_n,_enc );
00064    int m = x.imcycle();
00065    bool bob = ( m == x.mmax() );
00066 
00067 #ifdef STORM_DEBUG
00068    cout << "DCFsbistream<Data_t>::operator>>(): m bob "
00069         << m << ' ' << bob << '\n';
00070 #endif
00071 
00072    if (bob) {
00073       _blocknum = ( ( x.mrastep() + 1 ) >> x.mmax() );
00074       open();
00075       mp.setencode( DCF_DEFAULT_MPACKET, bplen_sizeb(), bplen_n(), _enc );
00076       findmpacket( mp, char(m), 0 );
00077       mp.replace(x);
00078    }
00079 
00080    int n;
00081    while (m) {
00082       n = ( ( x.mrastep() + 1 ) & ( ( 1 << x.mmax() ) - 1 ) ) >> m;
00083       findmpacket( mp, char( 0x80 | m ), n );
00084       mp.replace(x);
00085       m--;
00086    }
00087 
00088    return *this;
00089 };
00090 
00091 #endif

Generated on Mon May 31 21:38:44 2004 for SR2k4 Assembler by doxygen 1.3.6