00001
00002
00003
00004
00005
00006
00007 #ifndef DCFMPBASE_H
00008 #define DCFMPBASE_H
00009
00010 #ifdef USE_STD
00011 #include <vector>
00012 using namespace std;
00013 #else
00014 #include <vector.h>
00015 #endif
00016
00017 #include "utility.h"
00018
00019 class DCFmpBase
00020 {
00021 public:
00022
00023 DCFmpBase(
00024 const int bplen_mpsizeb, const int bplen_coef,
00025 const int bplen_n, const int bplen_a
00026 );
00027 DCFmpBase(
00028 const int bplen_mpsizeb, const int bplen_coef,
00029 const int bplen_n
00030 );
00031 ~DCFmpBase();
00032
00033 virtual void set(
00034 const int bplen_mpsizeb, const int bplen_coef,
00035 const int bplen_n, const int bplen_a
00036 );
00037 virtual void set(
00038 const int bplen_mpsizeb, const int bplen_coef,
00039 const int bplen_n
00040 );
00041 virtual void set( const char mcode, const int n );
00042 virtual void set( const char mcode );
00043 virtual void set( const int n );
00044 virtual void set();
00045 virtual void set(void*);
00046
00047 virtual void clear();
00048
00049 virtual void push_back( const char );
00050 virtual void push_back( bytepack& );
00051
00052 void write( ostream& os );
00053 void read( istream& is );
00054
00055 int mpsizeb();
00056
00057 bool empty();
00058 bool null();
00059
00060 int arraydim() { return _arraydim; }
00061 int bplen_mpsizeb() { return _bplen_mpsizeb; }
00062 int bplen_coef() { return _bplen_coef; }
00063 int bplen_n() { return _bplen_n; }
00064 int bplen_a() { return _bplen_a; }
00065
00066 char mcode();
00067 int m();
00068 int sw();
00069 int rs();
00070 int order();
00071
00072 int n();
00073
00074 int mcode_to_m( const char );
00075 int mcode_to_sw( const char );
00076 int mcode_to_rs( const char );
00077 int mcode_to_order( const char );
00078
00079 protected:
00080
00081 int _arraydim;
00082 int _bplen_mpsizeb;
00083 int _bplen_coef;
00084 int _bplen_n;
00085 int _bplen_a;
00086
00087 int _mpsizeb;
00088
00089 char _mcode;
00090 int _n;
00091
00092 vector<char>* _data;
00093
00094 bool _null;
00095
00096 private:
00097 DCFmpBase() {}
00098
00099 friend
00100 ostream& operator << ( ostream&, DCFmpBase& );
00101
00102 friend
00103 istream& operator >> ( istream&, DCFmpBase& );
00104
00105 };
00106
00107 inline
00108 void DCFmpBase::set( const char mcode )
00109 {
00110 _mcode = mcode;
00111 _null = 0;
00112 }
00113
00114 inline
00115 void DCFmpBase::set( const int n )
00116 {
00117 _n = n;
00118 _null = 0;
00119 }
00120
00121 inline
00122 void DCFmpBase::set( const char mcode, const int n )
00123 {
00124 set(mcode);
00125 set(n);
00126 _null = 0;
00127 }
00128
00129 inline
00130 void DCFmpBase::set() { _null = 0; }
00131
00132 inline
00133 void DCFmpBase::set(void*) { _null = 1; }
00134
00135 inline
00136 void DCFmpBase::clear()
00137 {
00138 if ( _data != 0 ) { delete _data; _data = 0; }
00139 _data = new vector<char>;
00140 }
00141
00142 inline
00143 void DCFmpBase::push_back(const char c) { (*_data).push_back(c); };
00144
00145 inline
00146 void DCFmpBase::push_back( bytepack& bp )
00147 {
00148 for( int i = 0; i < bp.size(); i++ ) { (*_data).push_back(bp[i]); }
00149 }
00150
00151 inline
00152 bool DCFmpBase::null() { return _null; }
00153
00154 inline
00155 bool DCFmpBase::empty() { return ( (*_data).size() == 0 ); }
00156
00157 inline
00158 char DCFmpBase::mcode() { return _mcode; };
00159
00160 inline
00161 int DCFmpBase::m() { return mcode_to_m( _mcode ); }
00162
00163 inline
00164 int DCFmpBase::sw() { return mcode_to_sw( _mcode ); }
00165
00166 inline
00167 int DCFmpBase::rs() { return mcode_to_rs( _mcode ); }
00168
00169 inline
00170 int DCFmpBase::order() { return mcode_to_order( _mcode ); }
00171
00172 inline
00173 int DCFmpBase::n() { return _n; };
00174
00175 inline
00176 int DCFmpBase::mcode_to_m( const char mcode )
00177 {
00178 return int( (unsigned char)( 0x1F & mcode ) );
00179 };
00180
00181 inline
00182 int DCFmpBase::mcode_to_sw( const char mcode )
00183 {
00184 return int( (unsigned char)( ( 0x80 & mcode ) >> 7 ) );
00185 };
00186
00187 inline
00188 int DCFmpBase::mcode_to_rs( const char mcode )
00189 {
00190 return ( ( 0x40 & mcode ) >> 6 );
00191 };
00192
00193 inline
00194 int DCFmpBase::mcode_to_order( const char mcode )
00195 {
00196 return int( (unsigned char)( ( 0x20 & mcode ) >> 5 ) );
00197 };
00198
00199 #endif
00200