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

softoutdecodingfactory.h

Go to the documentation of this file.
00001 /*-*-c++-*-****************************************************************
00002                           sofoutdecodingfactory.h  -  description
00003                              -------------------
00004     begin                : Mit Mai 22 2002
00005     copyright            : (C) 2002 by Peter Haase
00006     email                : mail@p-haase.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This library is free software; you can redistribute it and/or         *
00012  *   modify it under the terms of the GNU Lesser General Public            *
00013  *   License as published by the Free Software Foundation; either          *
00014  *   version 2.1 of the License, or (at your option) any later version.    *
00015  *                                                                         *
00016  *   This library is distributed in the hope that it will be useful,       *
00017  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00018  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
00019  *   Lesser General Public License for more details.                       *
00020  *                                                                         *
00021  *   You should have received a copy of the GNU Lesser General Public      *
00022  *   License along with this library; if not, write to the Free Software   *
00023  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston,                 *
00024  *   MA  02111-1307  USA                                                   *
00025  *                                                                         *
00026  ***************************************************************************/
00027 
00028 
00029 #ifndef SOFOUTDECODINGFACTORY_HEADER
00030 #define SOFOUTDECODINGFACTORY_HEADER
00031 
00032 #include <iostream>
00033 #include <string>
00034 #include <complex>
00035 #include <memory>
00036 
00037 
00038 #include "misc.h"
00039 #include "signals.h"
00040 #include "basicdevice.h"
00041 #include "softoutdecoding.h"
00042 #include "trellissoftout.h"
00043 
00044 namespace simthlib
00045 {
00046 
00047 /* These classes are so called factory classes (see "Die C++ Programiersprache", page S.~342) for
00048     different SoftoutDecoding classes.
00049  
00050 */
00051 class SoftoutDecodingMaker
00052 {
00053   public:
00054 
00055     virtual SoftoutDecoding* newSoftoutDecoding() const = 0;
00056 
00057     virtual ~SoftoutDecodingMaker(){};
00058 };
00059 
00060 class StreamSoftoutDecodingMaker : public SoftoutDecodingMaker
00061 {
00062   public:
00063 
00064     virtual StreamSoftoutDecoding* newSoftoutDecoding() const = 0;
00065 
00066     virtual ~StreamSoftoutDecodingMaker(){};
00067 };
00068 
00069 class StreamSoftoutDecodingTailbitsMaker : public StreamSoftoutDecodingMaker
00070 {
00071   public:
00072 
00073     virtual StreamSoftoutDecodingTailbits* newSoftoutDecoding() const = 0;
00074 
00075     virtual ~StreamSoftoutDecodingTailbitsMaker(){};
00076 };
00077 
00078 class TrellisSoftoutDecodingMaker : public StreamSoftoutDecodingTailbitsMaker
00079 {
00080   public:
00081 
00082     virtual TrellisSoftoutDecoding* newSoftoutDecoding() const = 0;
00083 
00084     virtual ~TrellisSoftoutDecodingMaker(){};
00085 };
00086 
00087 
00088 
00089 class ConvSoftoutDecodingMaker : public TrellisSoftoutDecodingMaker
00090 {
00091     int inSymbolsPerStep;
00092     int bitsPerSymbol;
00093     simthlib::ConvCodeTrellis::StartingMode startingMode;
00094 
00095     bool mapping;
00096     simthlib::map_type mapMode;
00097 
00098     simth::checkedVector<int> polynome;
00099     int recursivePolynomial;
00100 
00101     bool systematic;
00102 
00103     int mem;
00104     int outbits;
00105 
00106     trellissoftout::softoutalgorithmmode soMode;
00107 
00108   public:
00109     ConvSoftoutDecodingMaker(int mem_, int inbits_, int outbits_,
00110                             trellissoftout::softoutalgorithmmode soMode_)
00111         : inSymbolsPerStep(inbits_),bitsPerSymbol(1), startingMode(simthlib::ConvCodeTrellis::ZERO),
00112         mapping(false), mapMode(simthlib::NATURAL),
00113         polynome(0),recursivePolynomial(-1), systematic(false),
00114     mem(mem_), outbits(outbits_), soMode(soMode_) {}
00115 
00116     ConvSoftoutDecodingMaker(int inSymbolsPerStep_, const simth::checkedVector<int>& polynome_,
00117                               trellissoftout::softoutalgorithmmode soMode_)
00118         : inSymbolsPerStep(inSymbolsPerStep_),bitsPerSymbol(1), startingMode(simthlib::ConvCodeTrellis::ZERO),
00119         mapping(false), mapMode(simthlib::NATURAL),
00120         polynome(polynome_),recursivePolynomial(0), systematic(false),
00121     mem(-1), outbits(-1), soMode(soMode_) {}
00122 
00123     ConvSoftoutDecodingMaker(int inSymbolsPerStep_, const simth::checkedVector<int>& polynome_,
00124                             int recursivePolynomial_, bool systematic_,
00125                             trellissoftout::softoutalgorithmmode soMode_)
00126         : inSymbolsPerStep(inSymbolsPerStep_),bitsPerSymbol(1), startingMode(simthlib::ConvCodeTrellis::ZERO),
00127         mapping(false), mapMode(simthlib::NATURAL),
00128         polynome(polynome_),recursivePolynomial(recursivePolynomial_), systematic(systematic_),
00129     mem(-1), outbits(-1), soMode(soMode_) {}
00130 
00131     ConvSoftoutDecodingMaker(int inSymbolsPerStep_, int bitsPerSymbol_,simthlib::ConvCodeTrellis::StartingMode startingMode_, simthlib::map_type mapMode_,
00132                             const simth::checkedVector<int>& polynome_, int recursivePolynomial_,
00133                             trellissoftout::softoutalgorithmmode soMode_)
00134         : inSymbolsPerStep(inSymbolsPerStep_), bitsPerSymbol(bitsPerSymbol_), startingMode(startingMode_),
00135         mapping(true), mapMode(mapMode_),
00136         polynome(polynome_),recursivePolynomial(recursivePolynomial_), systematic(false),
00137     mem(-1), outbits(-1), soMode(soMode_){}
00138 
00139     virtual ConvSoftoutDecoding* newSoftoutDecoding() const;
00140 };
00141 
00142 
00143 inline ConvSoftoutDecoding* ConvSoftoutDecodingMaker::newSoftoutDecoding() const
00144 {
00145   if(DEBUG) {
00146     if( (polynome.size() == 0)&&(mem <= 0)) {
00147       throw std::logic_error("inline ConvSoftoutDecoding* ConvSoftoutDecodingMaker::newSoftoutDecoding()"
00148                              " : Error 1");
00149     }
00150   }
00151   if(!mapping) {
00152     if(polynome.size() != 0) {
00153       return new ConvSoftoutDecoding(inSymbolsPerStep, polynome, recursivePolynomial,systematic,
00154                                     soMode);
00155     }
00156     else {
00157       return new ConvSoftoutDecoding(mem, inSymbolsPerStep, outbits, soMode);
00158     }
00159   }
00160   else {
00161     if(DEBUG) {
00162       if(polynome.size() == 0) {
00163         throw std::logic_error("inline ConvSoftoutDecoding* ConvSoftoutDecodingMaker::newSoftoutDecoding() "
00164                                "const : error 1");
00165       }
00166     }
00167     return new ConvSoftoutDecoding(inSymbolsPerStep, bitsPerSymbol, startingMode, mapMode, polynome,
00168                                   recursivePolynomial, soMode);
00169   }
00170 }
00171 
00172 
00173 class ConvSoftoutDecodingExplicitMaker : public TrellisSoftoutDecodingMaker
00174 {
00175 
00176   public:
00177 
00178     ConvSoftoutDecodingExplicitMaker(int inbits, int outbits, ConvCodeTrellis::StartingMode startingMode_,
00179                      map_type mappMode_,trellissoftout::softoutalgorithmmode mode)
00180        : inputBitsPerStep(inbits),outputBitsPerStep(outbits),startingMode(startingMode_),mappMode(mappMode_),soMode(mode)
00181       { }; 
00182 
00183 
00184     virtual TrellisSoftoutDecoding* newSoftoutDecoding() const;
00185 
00186   private:
00187   
00188     int inputBitsPerStep;
00189     int outputBitsPerStep;
00190     simthlib::ConvCodeTrellis::StartingMode startingMode;
00191     map_type mappMode;
00192     trellissoftout::softoutalgorithmmode soMode;
00193 };
00194 
00195 
00196 inline TrellisSoftoutDecoding* ConvSoftoutDecodingExplicitMaker::newSoftoutDecoding() const
00197 {
00198     std::auto_ptr<TrellisSoftoutAlgorithm> algorithmPtr = makeExplicitSoftoutAlgorithm(soMode,inputBitsPerStep, outputBitsPerStep,startingMode,mappMode);
00199     return new TrellisSoftoutDecoding(algorithmPtr);
00200 }
00201 
00202 
00203 class SoftoutDAPSKDecodingMaker : public StreamSoftoutDecodingTailbitsMaker
00204 {
00205 
00206     int inSymbolsPerStep;
00207     int bitsPerSymbol;
00208     simthlib::ConvCodeTrellis::StartingMode startingMode;
00209 
00210     bool mapping;
00211     simthlib::map_type mapMode;
00212 
00213     simth::checkedVector<int> polynome;
00214     int recursivePolynomial;
00215 
00216     trellissoftout::softoutalgorithmmode soMode;
00217 
00218   public:
00219 
00220     SoftoutDAPSKDecodingMaker(int inSymbolsPerStep_, int bitsPerSymbol_,simthlib::ConvCodeTrellis::StartingMode startingMode_, 
00221                              simthlib::map_type mapMode_,
00222                              const simth::checkedVector<int>& polynome_, int recursivePolynomial_, 
00223                              trellissoftout::softoutalgorithmmode soMode_)
00224         : inSymbolsPerStep(inSymbolsPerStep_),bitsPerSymbol(bitsPerSymbol_), startingMode(startingMode_),
00225         mapping(true), mapMode(mapMode_),
00226       polynome(polynome_),recursivePolynomial(recursivePolynomial_),soMode(soMode_)
00227     {}
00228 
00229     virtual StreamSoftoutDecodingTailbits* newSoftoutDecoding() const;
00230 };
00231 
00232 inline StreamSoftoutDecodingTailbits* SoftoutDAPSKDecodingMaker::newSoftoutDecoding() const
00233 {
00234   if(DEBUG) {
00235     if(polynome.size() == 0) {
00236       throw std::logic_error("inline StreamSoftoutDecoding* ConvSoftoutDecodingMaker::newSoftoutDecoding() "
00237                              "const : error 1");
00238     }
00239   }
00240   return new SoftoutDAPSKDecoding(inSymbolsPerStep, bitsPerSymbol, startingMode, mapMode, polynome, recursivePolynomial,soMode);
00241 }
00242 
00243 
00244 
00245 class PunctConvSoftoutDecodingMaker : public StreamSoftoutDecodingTailbitsMaker
00246 {
00247     int codeRateNumerator;
00248     int codeRateDenumerator;
00249 
00250     simth::checkedVector<int> polynome;
00251     int recursivePolynomial;
00252 
00253     bool systematic;
00254 
00255     int mem;
00256     int inbits;
00257     int outbits;
00258 
00259     std::string pattern;
00260 
00261     trellissoftout::softoutalgorithmmode soMode;
00262 
00263   public:
00264     PunctConvSoftoutDecodingMaker(int codeRateNumerator_, int codeRateDenumerator_,
00265                                  int mem_, int inbits_, int outbits_,
00266                                  trellissoftout::softoutalgorithmmode soMode_)
00267         : codeRateNumerator(codeRateNumerator_), codeRateDenumerator(codeRateDenumerator_),
00268         polynome(0),recursivePolynomial(-1), systematic(false),
00269     mem(mem_), inbits(inbits_), outbits(outbits_), soMode(soMode_) {}
00270 
00271     PunctConvSoftoutDecodingMaker(int inbits_, int codeRateNumerator_, int codeRateDenumerator_,
00272                                  const simth::checkedVector<int>& polynomePar,
00273                                  int recursivePolynomialPar,bool  systematic_,
00274                                  trellissoftout::softoutalgorithmmode soMode_)
00275         : codeRateNumerator(codeRateNumerator_), codeRateDenumerator(codeRateDenumerator_),
00276         polynome(polynomePar),recursivePolynomial(recursivePolynomialPar), systematic(systematic_),
00277     mem(-1), inbits(inbits_), outbits(-1), soMode(soMode_) {}
00278 
00279     PunctConvSoftoutDecodingMaker(int inbits_, const std::string& punctPattern,
00280                                  const simth::checkedVector<int>& polynomePar,
00281                                  int recursivePolynomialPar,bool  systematic_,
00282                                  trellissoftout::softoutalgorithmmode soMode_)
00283         : codeRateNumerator(-1), codeRateDenumerator(-1),
00284         polynome(polynomePar),recursivePolynomial(recursivePolynomialPar), systematic(systematic_),
00285     mem(-1), inbits(inbits_), outbits(-1), pattern(punctPattern), soMode(soMode_) {}
00286 
00287     virtual StreamSoftoutDecodingTailbits* newSoftoutDecoding() const;
00288 };
00289 
00290 inline StreamSoftoutDecodingTailbits* PunctConvSoftoutDecodingMaker::newSoftoutDecoding() const
00291 {
00292   if(DEBUG) {
00293     if( (polynome.size() == 0)&&(mem <= 0)) {
00294       throw std::logic_error("inline StreamSoftoutDecoding* PunctConvSoftoutDecodingMaker::newSoftoutDecoding()"
00295                              " : Error 1");
00296     }
00297   }
00298   if(polynome.size() != 0) {
00299     if(pattern.length()==0) {
00300       return new PunctConvSoftoutDecoding(codeRateNumerator, codeRateDenumerator, inbits, polynome,
00301                                           recursivePolynomial, systematic, soMode);
00302     }
00303     return new PunctConvSoftoutDecoding(pattern, inbits, polynome, recursivePolynomial,systematic,
00304                                         soMode);
00305   }
00306   else {
00307     return new PunctConvSoftoutDecoding(codeRateNumerator, codeRateDenumerator, mem,inbits,outbits,
00308                                         soMode);
00309   }
00310 }
00311 
00312 
00313 }
00314 
00315 #endif

Generated on Tue Aug 9 14:35:11 2005 for simtheticlib by  doxygen 1.4.1