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

MCFsbifstream< Rtmra_t > Class Template Reference

#include <MCFsbifstream.h>

Inheritance diagram for MCFsbifstream< Rtmra_t >:

Inheritance graph
[legend]
Collaboration diagram for MCFsbifstream< Rtmra_t >:

Collaboration graph
[legend]

Public Member Functions

void close ()
void filenamebase (const string &)
void findmpacket (MCFmpBase &, const char mcode, const int n)
void initmfilepos ()
bool isopen ()
 MCFsbifstream (const string &="_\0")
void open ()
 ~MCFsbifstream ()

Private Attributes

string _filenamebase
string _filenamesb
int_mfilepos

template<class Rtmra_t>
class MCFsbifstream< Rtmra_t >


Constructor & Destructor Documentation

template<class Rtmra_t>
MCFsbifstream< Rtmra_t >::MCFsbifstream const string &  = "_\0"  ) 
 

Definition at line 41 of file MCFsbifstream.h.

00042   : MCFsbistream<Rtmra_t>( *( new ifstream ) ) 
00043 {
00044     _filenamebase = filenamebase;
00045     _mfilepos = new int[256];
00046 };

template<class Rtmra_t>
MCFsbifstream< Rtmra_t >::~MCFsbifstream  ) 
 

Definition at line 49 of file MCFsbifstream.h.

References MCFsbifstream< Rtmra_t >.close(), and MCFsbifstream< Rtmra_t >.isopen().

00050 {
00051    if ( isopen() ) close();
00052    if ( _mfilepos != 0 ) { delete [] _mfilepos; _mfilepos = 0; }
00053 };


Member Function Documentation

template<class Rtmra_t>
void MCFsbifstream< Rtmra_t >::close  )  [virtual]
 

Reimplemented from MCFsbistreamBase.

Definition at line 88 of file MCFsbifstream.h.

Referenced by MCFsbifstream< Rtmra_t >.open(), and MCFsbifstream< Rtmra_t >.~MCFsbifstream().

00089 { 
00090    (*static_cast<ifstream*>(_is)).close(); 
00091 }

template<class Rtmra_t>
void MCFsbifstream< Rtmra_t >::filenamebase const string &   ) 
 

Definition at line 56 of file MCFsbifstream.h.

00057 {
00058     _filenamebase = filenamebase;
00059 };

template<class Rtmra_t>
void MCFsbifstream< Rtmra_t >::findmpacket MCFmpBase ,
const char  mcode,
const int  n
[virtual]
 

Reimplemented from MCFsbistreamBase.

Definition at line 103 of file MCFsbifstream.h.

References MCFmpBase.clear(), and MCFmpBase.empty().

00106 {
00107    bool found = false;
00108    bool missing = false;
00109    bool eof = false;
00110    int nextfilepos;
00111    bytepack bp;
00112 
00113 #ifdef STORM_DEBUG
00114    cout << "MCFsbifstream.findmpacket(): SEARCHING FOR : mcode "
00115         << int( (unsigned char)(mcode) ) << '\n';
00116 #endif
00117 
00118    mp.clear();
00119    (*_is).seekg( _mfilepos[ int( (unsigned char)(mcode) ) ], ios::beg );
00120    int i0 = (*_is).tellg();
00121 
00122    while ( (*_is).good() & !found & !missing & !eof ) {
00123       nextfilepos = (*_is).tellg();
00124       (*_is) >> mp; 
00125 #ifdef STORM_DEBUG
00126       cout << "MCFsbifstream.findmpacket(): mp.mcode() mp.empty() "
00127            << int( (unsigned char)(mp.mcode()) ) << ' ' << mp.empty() << '\n';
00128 #endif
00129 //      if ( mp.empty() ) { 
00130       if ( mp.null() ) { 
00131          (*_is) >> bp( 0, 4 ); 
00132          (*_is) >> bp( 0, 4 );
00133          (*_is) >> bp( 0, _bplen_n ); _finalstep = bp;
00134 #ifdef STORM_DEBUG
00135          cout << "FINALSTEP " << _finalstep << '\n';
00136 #endif
00137          eof = true; 
00138             missing=true;       // TEST
00139             mp.set( mcode, n ); // TEST
00140             mp.clear();         // TEST
00141       }
00142       else {
00143          if ( ( mp.mcode() == mcode ) && ( mp.n() == n ) ) {
00144             found=true; 
00145          }
00146          if ( ( mp.mcode() == mcode ) && ( mp.n() > n ) ) {
00147             missing=true; 
00148 //            mp.reset();       HACK ?
00149             mp.clear(); 
00150          }
00151       }
00152    }
00153 
00154    int i1=(*_is).tellg();
00155    if (found) {
00156       _mfilepos[ int( (unsigned char)(mcode) ) ] = (*_is).tellg();
00157    }
00158    else {
00159       _mfilepos[ int( (unsigned char)(mcode) ) ] = nextfilepos;
00160    }
00161 
00162 #ifdef STORM_DEBUG
00163    cout << "MCFsbifstream.findmpacket(): mcode _result_ _mfilepos[mcode] "
00164         << int( (unsigned char)(mcode) );
00165    if (found)  cout << " FOUND ";
00166    if (missing) cout << " MISSING ";
00167    if (eof) cout << " EOF ";
00168    cout << _mfilepos[ int( (unsigned char)(mcode) ) ] << ' ' << n << '\n';
00169 #endif
00170 };

template<class Rtmra_t>
void MCFsbifstream< Rtmra_t >::initmfilepos  )  [virtual]
 

Reimplemented from MCFsbistreamBase.

Definition at line 94 of file MCFsbifstream.h.

Referenced by MCFsbifstream< Rtmra_t >.open().

00095 {
00096    for( int i = 0; i < 256; i++ ) { _mfilepos[i] = (*_is).tellg(); }
00097 #ifdef STORM_DEBUG
00098    cout << " initial seek pos " << _mfilepos[0] << '\n';
00099 #endif
00100 };

template<class Rtmra_t>
bool MCFsbifstream< Rtmra_t >::isopen  )  [virtual]
 

Reimplemented from MCFsbistreamBase.

Definition at line 62 of file MCFsbifstream.h.

Referenced by MCFsbifstream< Rtmra_t >.open(), and MCFsbifstream< Rtmra_t >.~MCFsbifstream().

00063 { 
00064    return (*static_cast<ifstream*>(_is)).is_open(); 
00065 }

template<class Rtmra_t>
void MCFsbifstream< Rtmra_t >::open  )  [virtual]
 

Reimplemented from MCFsbistreamBase.

Definition at line 68 of file MCFsbifstream.h.

References MCFsbifstream< Rtmra_t >.close(), MCFsbifstream< Rtmra_t >.initmfilepos(), MCFsbifstream< Rtmra_t >.isopen(), mcfsbfilename(), MCFsbistreamBase.open(), and MCFsbistreamBase.report().

00069 {
00070    if ( isopen() ) close();
00071    mcfsbfilename( _sbn, _filenamebase, _filenamesb );
00072 cout << "attempting open " << _filenamesb << endl;
00073    (*static_cast<ifstream*>(_is)).open( _filenamesb.c_str() );
00074 cout << "attempt open " << _filenamesb << endl;
00075    if ( !(static_cast<ifstream*>(_is)->good()) ) { 
00076       _openfail = true; 
00077    } else {
00078       _openfail = false;
00079       MCFsbistream<Rtmra_t>::open();
00080       initmfilepos();
00081 //#ifdef STORM_DEBUG
00082       report();
00083 //#endif
00084    }
00085 };


Field Documentation

template<class Rtmra_t>
string MCFsbifstream< Rtmra_t >._filenamebase [private]
 

Definition at line 35 of file MCFsbifstream.h.

template<class Rtmra_t>
string MCFsbifstream< Rtmra_t >._filenamesb [private]
 

Definition at line 36 of file MCFsbifstream.h.

template<class Rtmra_t>
int* MCFsbifstream< Rtmra_t >._mfilepos [private]
 

Definition at line 37 of file MCFsbifstream.h.


The documentation for this class was generated from the following file:
Generated on Mon May 31 21:41:14 2004 for SR2k4 Assembler by doxygen 1.3.6