00001
00029 #ifndef CHANNEL_CODE_H
00030 #define CHANNEL_CODE_H
00031
00032 #include <itpp/base/vec.h>
00033 #include <itpp/comm/modulator.h>
00034
00035
00036 namespace itpp
00037 {
00038
00043
00044
00050 class Channel_Code
00051 {
00052 public:
00054 Channel_Code() {}
00056 virtual ~Channel_Code() {}
00057
00059 virtual void encode(const bvec &uncoded_bits, bvec &coded_bits) = 0;
00061 virtual bvec encode(const bvec &uncoded_bits) = 0;
00062
00064 virtual void decode(const bvec &codedbits, bvec &decoded_bits) = 0;
00066
00067 virtual bvec decode(const bvec &coded_bits) = 0;
00068
00070 virtual void decode(const vec &received_signal, bvec &decoded_bits) = 0;
00072
00073 virtual bvec decode(const vec &received_signal) = 0;
00074
00076 virtual double get_rate() const = 0;
00077 };
00078
00079
00086 class Dummy_Code : public Channel_Code
00087 {
00088 public:
00090 Dummy_Code() {}
00092 virtual ~Dummy_Code() {}
00093
00095 virtual void encode(const bvec &uncoded_bits, bvec &coded_bits) { coded_bits = uncoded_bits; }
00097 virtual bvec encode(const bvec &uncoded_bits) { return uncoded_bits; }
00098
00100 virtual void decode(const bvec &coded_bits, bvec &decoded_bits) { decoded_bits = coded_bits; }
00102 virtual bvec decode(const bvec &coded_bits) { return coded_bits; }
00103
00105 virtual void decode(const vec &received_signal, bvec &decoded_bits) { BPSK bpsk; bpsk.demodulate_bits(received_signal, decoded_bits); }
00107 virtual bvec decode(const vec &received_signal) { bvec out; decode(received_signal, out); return out; }
00108
00110 virtual double get_rate() const { return 1.0; }
00111 };
00112
00113
00114
00115 }
00116
00117 #endif // #ifndef CHANNEL_CODE_H