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

MCFTPquote.cpp

Go to the documentation of this file.
00001 // MCFTPquote.cpp
00002 //////////////////////////////////////////////////////////////////////
00003 //          (c) Copyright 2002 Brown Deer Technology, LLC.
00004 //                        All rights reserved.
00005 //////////////////////////////////////////////////////////////////////
00006 
00007 #ifdef USE_STD
00008 #include <iostream>
00009 #include <string>
00010 using namespace std;
00011 #else
00012 #include <iostream.h>
00013 #include <string.h>
00014 #endif
00015 
00016 #include "utility.h"
00017 #include "MRAmspec.h"
00018 #include "MRAcspec.h"
00019 #include "MCFTPrequest.h"
00020 
00021 #include "MCFTPquote.h"
00022 
00023 MCFTPquote::MCFTPquote( int grid_dim, int array_dim )
00024   : _grid_dim(grid_dim), _array_dim(array_dim),
00025     _name("")
00026 {
00027    _sbn(_grid_dim);
00028    _mspec(_grid_dim);
00029 }
00030 
00031 MCFTPquote::MCFTPquote( const MCFTPquote& quote )
00032 {
00033    _grid_dim = quote._grid_dim;
00034    _array_dim = quote._array_dim;
00035    _name = quote._name;
00036    _sbn = quote._sbn;
00037    _mspec = quote._mspec;
00038    _cspec = quote._cspec;
00039 }
00040 
00041 MCFTPquote::MCFTPquote( const MCFTPrequest& request )
00042 {
00043    _grid_dim = request._grid_dim;
00044    _array_dim = request._array_dim;
00045    _name = request._name;
00046    _sbn = request._sbn;
00047    _mspec = request._mspec;
00048    _cspec = request._cspec;
00049 }
00050 
00051 MCFTPquote& MCFTPquote::operator () ()
00052 {
00053    _grid_dim = 0;
00054    _array_dim = 0;
00055    _name = "";
00056    _sbn(0);
00057    _mspec(0);
00058    return *this;
00059 }
00060 
00061 MCFTPquote& MCFTPquote::operator () ( int grid_dim, int array_dim )
00062 {
00063    _grid_dim = grid_dim;
00064    _array_dim = array_dim;
00065    _name = "";
00066    _sbn(_grid_dim) = 0;
00067    _mspec(_grid_dim);
00068    return *this;
00069 }
00070 
00071 MCFTPquote& MCFTPquote::operator () ( const MCFTPrequest& request )
00072 {
00073    _grid_dim = request._grid_dim;
00074    _array_dim = request._array_dim;
00075    _name = request._name;
00076    _sbn(_grid_dim) = request._sbn;
00077    _mspec(_grid_dim) = request._mspec;
00078    _cspec = request._cspec;
00079    return *this;
00080 }
00081 
00082 MCFTPquote& MCFTPquote::operator () ( const MCFTPquote& quote )
00083 {
00084    _grid_dim = quote._grid_dim;
00085    _array_dim = quote._array_dim;
00086    _sbn( _grid_dim ) = quote._sbn;
00087    _mspec(_grid_dim) = quote._mspec;
00088    _cspec = quote._cspec;
00089    return *this;
00090 }
00091 
00092 MCFTPquote& MCFTPquote::copy( const MCFTPquote& quote )
00093 {
00094    if ( this != &quote ) {
00095       _grid_dim = quote._grid_dim;
00096       _array_dim = quote._array_dim;
00097       _name = quote._name;
00098       _sbn( _grid_dim ) = quote._sbn;
00099       _mspec(_grid_dim) = quote._mspec;
00100       _cspec = quote._cspec;
00101    }
00102    return *this;
00103 }
00104 
00105 MCFTPquote& MCFTPquote::copy( const MCFTPrequest& rhs )
00106 {
00107    _grid_dim = rhs._grid_dim;
00108    _array_dim = rhs._array_dim;
00109    _name = rhs._name;
00110    _sbn(_grid_dim) = rhs._sbn;
00111    _mspec(_grid_dim) = rhs._mspec;
00112    _cspec = rhs._cspec;
00113    return *this;
00114 }
00115 
00116 bool MCFTPquote::is_equal( const MCFTPquote& quote )
00117 {
00118    if ( this != &quote ) {
00119       if ( _grid_dim != quote._grid_dim ) return false;
00120       if ( _array_dim != quote._array_dim ) return false;
00121       if ( _name != quote._name ) return false;
00122       if ( _sbn != quote._sbn ) return false;
00123       if ( _mspec != quote._mspec ) return false;
00124       if ( _cspec != quote._cspec ) return false;
00125    }
00126    return true;
00127 }
00128 
00129 bool MCFTPquote::is_equal( const MCFTPrequest& request )
00130 {
00131    if ( _grid_dim != request._grid_dim ) return false;
00132    if ( _array_dim != request._array_dim ) return false;
00133    if ( _name != request._name ) return false;
00134    if ( _sbn != request._sbn ) return false;
00135    if ( _mspec != request._mspec ) return false;
00136    if ( _cspec != request._cspec ) return false;
00137    return true;
00138 }
00139 
00140 void MCFTPquote::write( BufferBase& buffer )
00141 {
00142    bytepack bp;
00143    buffer >> bp( 0, 1 ); _grid_dim = int(bp);
00144    buffer >> bp( 0, 1 ); _array_dim = int(bp);
00145    buffer >> bp( 0, 1 ); int namesize = int(bp);
00146    _name = "";
00147    for( int i = 0; i < namesize; ++i ) _name += buffer.get();
00148    _sbn(_grid_dim);
00149    buffer >> _sbn;
00150    _mspec(_grid_dim);
00151    buffer >> _mspec;
00152    buffer >> _cspec;
00153 }
00154 
00155 void MCFTPquote::read( BufferBase& buffer )
00156 {
00157    bytepack bp;
00158    buffer << bp( _grid_dim, 1 );
00159    buffer << bp( _array_dim, 1 );
00160    buffer << bp( int(_name.size()), 1 );
00161    for(unsigned int i = 0; i < _name.size(); ++i ) buffer.put( _name[i] );
00162    buffer << _sbn;
00163    buffer << _mspec;
00164    buffer << _cspec;
00165 }
00166 
00167 void MCFTPquote::write( istream& is )
00168 {
00169    bytepack bp;
00170    is >> bp( 0, 1 ); _grid_dim = int(bp);
00171    is >> bp( 0, 1 ); _array_dim = int(bp);
00172    is >> bp( 0, 1 ); int namesize = int(bp);
00173    _name = "";
00174    for( int i = 0; i < namesize; ++i ) _name += is.get();
00175    _sbn(_grid_dim);
00176    is >> _sbn;
00177    _mspec(_grid_dim);
00178    is >> _mspec;
00179    is >> _cspec;
00180 }
00181 
00182 void MCFTPquote::read( ostream& os )
00183 
00184 {
00185    bytepack bp;
00186    os << bp( _grid_dim, 1 );
00187    os << bp( _array_dim, 1 );
00188    os << bp( int(_name.size()), 1 );
00189    for(unsigned int i = 0; i < _name.size(); ++i ) os.put( _name[i] );
00190    os << _sbn;
00191    os << _mspec;
00192    os << _cspec;
00193 }
00194 
00195 int MCFTPquote::sizeb() 
00196 { 
00197    return 3 + _name.size() + _sbn.sizeb() + _mspec.sizeb() + _cspec.sizeb();
00198 }
00199 
00200 void MCFTPquote::report( ostream& os ) 
00201 {
00202    os << "MCFTPquote::report(){\n";
00203    os << "grid_dim = " << _grid_dim << '\n';
00204    os << "array_dim = " << _array_dim << '\n';
00205    os << "name.size() = " << _name.size() << '\n';
00206    os << "name = " << _name << '\n';
00207    os << "sbn =\n";
00208    _sbn.report(os);
00209    os << "mspec =\n";
00210    _mspec.report(os);
00211    os << "cspec =\n";
00212    _cspec.report(os);
00213    os << "}\n";
00214 }
00215 // ##### friends #####
00216 
00217 BufferBase& operator << ( BufferBase& buffer, MCFTPquote& quote )
00218 {
00219    quote.read(buffer);
00220    return buffer;
00221 }
00222 
00223 BufferBase& operator >> ( BufferBase& buffer, MCFTPquote& quote )
00224 {
00225    quote.write(buffer);
00226    return buffer;
00227 }
00228 
00229 ostream& operator << ( ostream& os, MCFTPquote& quote )
00230 {
00231    quote.read(os);
00232    return os;
00233 }
00234 
00235 istream& operator >> ( istream& is, MCFTPquote& quote )
00236 {
00237    quote.write(is);
00238    return is;
00239 }
00240 

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