00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00029 #ifndef SEQPP_PRIMARYCOUNT_H
00030 #define SEQPP_PRIMARYCOUNT_H
00031
00032 #include <seqpp/Coder.h>
00033
00064 class PrimaryCount
00065 {
00066 protected:
00067
00069 short _order;
00071 long _nbvalue;
00073 short _nbinv;
00074
00076 Coder * _coder;
00078 bool _coder_in;
00079
00080
00082 unsigned long * * _count;
00084 bool _count_ok;
00086 short _phase;
00087
00089 void init_count() const;
00090
00091
00093 virtual unsigned long tell_max_count() const = 0;
00095 virtual void compute_count( unsigned long * * extern_count,
00096 short phase,
00097 short initial_phase,
00098 unsigned long beg,
00099 unsigned long end ) const = 0;
00100
00101
00102 public:
00103
00104 PrimaryCount(){
00105
00106 _order = -1;_nbvalue=0;_nbinv=0;_coder=NULL;_coder_in=false;
00107 _count=NULL;_count_ok=false;_phase=0;
00108 };
00109
00110
00112 virtual ~PrimaryCount(){
00113
00114 if (_coder_in)
00115 delete _coder;
00116
00117 this->clear_count();
00118
00119 }
00120
00121
00123 void clear_count() const;
00124
00126 void null_count() const;
00127
00129 short tell_order() const{
00130 return _order;
00131 }
00133 int tell_nb_value() const{
00134 return _nbvalue;
00135 }
00137 long tell_jump() const{
00138 return _coder->tell_jump();
00139 }
00140
00142 long * get_jump() const{
00143 return _coder->get_jump();
00144 }
00145
00147 Coder & get_coder() const{
00148 return *_coder;
00149 }
00150
00151
00153 bool is_count_ok() const{
00154 return _count_ok;
00155 }
00156
00158 unsigned long * * get_p_count() const{
00159 return _count;
00160 }
00161
00163
00166 unsigned long * get_count( short p = 0 ) const{
00167 return _count[p];
00168 }
00169
00171 short tell_phase() const{
00172 return _phase;
00173 }
00174
00175
00177
00183 void count_p_occurencies( short phase,
00184 short initial_phase,
00185 unsigned long beg,
00186 unsigned long end ) const{
00187 compute_count( const_cast< PrimaryCount* >( this )->_count,
00188 phase, initial_phase, beg, end );
00189 }
00190
00192
00199 void count_p_occurencies( unsigned long * * extern_count,
00200 short phase,
00201 short initial_phase,
00202 unsigned long beg,
00203 unsigned long end ) const{
00204 compute_count( extern_count, phase, initial_phase, beg, end );
00205 }
00206
00208
00213 void count_p_occurencies( unsigned long * * extern_count,
00214 short phase,
00215 short initial_phase = 0 ) const{
00216 count_p_occurencies( extern_count, phase, initial_phase, 0, 0 );
00217 }
00218
00220
00224 void count_p_occurencies( short phase,
00225 short initial_phase = 0 ) const{
00226 count_p_occurencies( phase, initial_phase, 0, 0 );
00227 }
00228
00229
00231
00235 void count_occurencies( unsigned long beg,
00236 unsigned long end ) const {
00237 count_p_occurencies(1,0,beg,end);
00238 }
00239
00241 void count_occurencies( ) const{
00242 count_p_occurencies( 1, 0, 0, 0 );
00243 }
00244
00245
00247 unsigned long tell_p_occurencies( long code, short numphase ) const;
00248
00250 unsigned long tell_occurencies( long code ) const {
00251 return tell_p_occurencies( code, 0 ) ;
00252 }
00253 };
00254 #endif