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

MCFsbistream.h

Go to the documentation of this file.
00001 // MCFsbistream.h
00002 //////////////////////////////////////////////////////////////////////
00003 //          (c) Copyright 2001-2002 Brown Deer Technology, LLC.
00004 //                        All rights reserved.
00005 //////////////////////////////////////////////////////////////////////
00006 
00007 #ifndef MCFSBISTREAM_H
00008 #define MCFSBISTREAM_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 "MCFsbistreamBase.h"
00020 #include "MCFmp.h"
00021 #include "MCF_Code.h"
00022 
00023 template <class Rtmra_t>
00024 class MCFsbistream : public MCFsbistreamBase 
00025 {
00026    public:
00027       typedef typename Rtmra_t::DataType Data_t;
00028       MCFsbistream( istream& is = cin );
00029       ~MCFsbistream() {}
00030       MCFsbistream<Rtmra_t>& operator>>( Rtmra_t& );
00031       MCFsbistream<Rtmra_t>& jump_read( int, Rtmra_t& );
00032 };
00033 
00034 template < class Rtmra_t >
00035 MCFsbistream<Rtmra_t>::MCFsbistream( istream& is) 
00036   : MCFsbistreamBase( is ) 
00037 {
00038    _datatype_code = DataType_Code<Data_t>::eval(); 
00039 }
00040 
00041 template < class Rtmra_t >
00042 MCFsbistream<Rtmra_t>& MCFsbistream<Rtmra_t>::operator>>( Rtmra_t& x ) 
00043 {
00044 
00045    MCFmp<Rtmra_t> mp( _bplen_mpsizeb, _bplen_coef, _bplen_n, _bplen_a );
00046 
00047    int m = x.imcycle();
00048    bool bob = ( m == x.mmax() );
00049 
00050 #ifdef STORM_DEBUG
00051    cout << "MCFsbistream<Rtmra_t>::operator>>(): m bob "
00052         << m << ' ' << bob << '\n';
00053 #endif
00054 
00055    if (bob) {
00056       _sbn = ( ( x.mrastep() + 1 ) >> x.mmax() );
00057       open();
00058       if ( ! _openfail ) {
00059          mp.set( _bplen_mpsizeb, _bplen_coef, _bplen_n, _bplen_a );
00060          findmpacket( mp, char(m), 0 );
00061          mp.replace(x);
00062       }
00063    }
00064 
00065    if ( ! _openfail ) {
00066       int n;
00067       while (m) {
00068          n = ( ( x.mrastep() + 1 ) & ( ( 1 << x.mmax() ) - 1 ) ) >> m;
00069          findmpacket( mp, char( 0x80 | m ), n );
00070          mp.replace(x);
00071          m--;
00072       }
00073    }
00074    return *this;
00075 };
00076 
00077 template < class Rtmra_t >
00078 MCFsbistream<Rtmra_t>& MCFsbistream<Rtmra_t>::jump_read( 
00079   int mrastep, Rtmra_t& x 
00080 ) 
00081 {
00082    x.mrastep( mrastep-1 );
00083 
00084    MCFmp<Rtmra_t> mp( _bplen_mpsizeb, _bplen_coef, _bplen_n, _bplen_a );
00085 
00086    int m = x.imcycle();
00087    bool bob = ( m == x.mmax() );
00088 
00089 #ifdef STORM_DEBUG
00090    cout << "MCFsbistream<Rtmra_t>::jump_read(): m bob "
00091         << m << ' ' << bob << '\n';
00092 #endif
00093 
00094    _sbn = ( ( x.mrastep() + 1 ) >> x.mmax() );
00095    open();
00096 
00097    if ( ! _openfail ) {
00098       mp.set( _bplen_mpsizeb, _bplen_coef, _bplen_n, _bplen_a );
00099       findmpacket( mp, char( x.mmax() ), 0 );
00100       mp.replace(x);
00101 
00102       int n;
00103       for( int m = x.mmax(); m > 0; --m ) {
00104          n = ( ( x.mrastep() + 1 ) & ( ( 1 << x.mmax() ) - 1 ) ) >> m;
00105          findmpacket( mp, char( 0x80 | m ), n );
00106          mp.replace(x);
00107       }
00108    }
00109 
00110    return *this;
00111 };
00112 
00113 #endif
00114 

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