![]() |
ccsoft
0.0.0
Convolutional codes library with soft decision decoding
|
00001 /* 00002 Copyright 2013 Edouard Griffiths <f4exb at free dot fr> 00003 00004 This file is part of CCSoft. A Convolutional Codes Soft Decoding library 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Boston, MA 02110-1301 USA 00019 00020 Convolutional encoder class. 00021 00022 This version uses a fixed array for internal registers 00023 00024 */ 00025 #ifndef __CC_ENCODING_REGISTERS_FA_H__ 00026 #define __CC_ENCODING_REGISTERS_FA_H__ 00027 00028 #include "CCSoft_Exception.h" 00029 00030 #include <iostream> 00031 #include <array> 00032 #include <algorithm> 00033 00034 namespace ccsoft 00035 { 00036 00042 template<typename T_Register, unsigned int N_k> 00043 class CC_EncodingRegisters_FA 00044 { 00045 public: 00046 00047 //============================================================================================= 00051 CC_EncodingRegisters_FA() 00052 { 00053 clear(); 00054 } 00055 00056 //============================================================================================= 00060 ~CC_EncodingRegisters_FA() 00061 {} 00062 00063 //============================================================================================= 00067 void clear() 00068 { 00069 std::fill(registers.begin(), registers.end(), 0); 00070 //registers.fill(0); 00071 } 00072 00073 //============================================================================================= 00077 T_Register& get_register(const unsigned int index) 00078 { 00079 return registers[index]; 00080 } 00081 00082 //============================================================================================= 00086 const std::array<T_Register, N_k>& get_registers() const 00087 { 00088 return registers; 00089 } 00090 00091 //============================================================================================= 00095 void set_registers(const std::array<T_Register, N_k>& _registers) 00096 { 00097 registers = _registers; 00098 } 00099 00100 00101 protected: 00102 std::array<T_Register, N_k> registers; 00103 }; 00104 00109 template<typename T_Register> 00110 class CC_EncodingRegisters_FA<T_Register, 1> 00111 { 00112 public: 00113 00114 //============================================================================================= 00118 CC_EncodingRegisters_FA() 00119 { 00120 clear(); 00121 } 00122 00123 //============================================================================================= 00127 ~CC_EncodingRegisters_FA() 00128 {} 00129 00130 //============================================================================================= 00134 void clear() 00135 { 00136 m_register = 0; 00137 } 00138 00139 //============================================================================================= 00143 T_Register& get_register(const unsigned int index) 00144 { 00145 if (index > 0) 00146 { 00147 throw CCSoft_Exception("Invalid subscript for single register"); 00148 } 00149 00150 return m_register; 00151 } 00152 00153 //============================================================================================= 00157 const T_Register& get_registers() const 00158 { 00159 return m_register; 00160 } 00161 00162 //============================================================================================= 00166 void set_registers(const T_Register& _register) 00167 { 00168 m_register = _register; 00169 } 00170 00171 00172 protected: 00173 T_Register m_register; 00174 }; 00175 00176 00177 } // namespace ccsoft 00178 00179 00180 #endif // __CC_ENCODING_REGISTERS_FA_H__