Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

CacheDecoderBase.hpp

Go to the documentation of this file.
00001 #ifndef CacheDecoderBase_HPP
00002 #define CacheDecoderBase_HPP
00003 
00008 #include "io/codec/decoder/DecoderBase.hpp"
00009 #include "io/output/BufferedOutput.hpp"
00010 #include "util/Formatter.hpp"
00011 #include "io/FDRepr.hpp"  
00012 #include <vector>
00013 #include <iostream>
00014 
00020 template <class FR = FDRepr>
00021 class CacheDecoderBase : public DecoderBase< BufferedOutput<FR> >
00022 {
00023    public:
00024      
00025       typedef typename DecoderBase< BufferedOutput<FR> >::params_t params_t;
00026       CacheDecoderBase(const params_t* par)
00027          : DecoderBase< BufferedOutput<FR> >(par){}
00028 
00029       ~CacheDecoderBase()
00030       {
00031          for(std::vector< std::pair<char*, unsigned int> >::iterator it = 
00032                 code_inverse.begin(); it != code_inverse.end(); ++it)
00033             delete [] (*it).first;
00034       }
00035 
00036          
00037       void setCodeInverse( const std::vector<item_t>& code_inverse )
00038       {  
00039          char* temp_string;
00040          std::streamsize pos;
00041          unsigned int length;
00042          std::pair<char*, unsigned int> temp_pair;
00043          for( std::vector<item_t>::const_iterator it = code_inverse.begin();
00044               it != code_inverse.end(); ++it)
00045          {
00046             pos = this->buffer_size;
00047             Formatter::IntToStringBack(*it, this->buffer, pos);
00048             length = this->buffer_size - pos;
00049             temp_string = new char[length];
00050             memcpy( temp_string, &(this->buffer)[pos], length );
00051             temp_pair.first = temp_string;
00052             temp_pair.second = length;
00053             this->code_inverse.push_back(temp_pair);
00054          }
00055       }  
00056       
00057    protected:
00063       std::vector< std::pair<char*, unsigned int> > code_inverse;
00064 };
00065 
00066 #endif

Generated on Sun Sep 17 17:50:37 2006 for FIM environment by  doxygen 1.4.4