![]() |
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 Node in the convolutional code tree 00021 00022 */ 00023 00024 #ifndef __CC_TREE_NODE_H__ 00025 #define __CC_TREE_NODE_H__ 00026 00027 #include <vector> 00028 00029 namespace ccsoft 00030 { 00031 00032 template<typename T_IOSymbol, typename T_Register, typename T_EdgeTag> 00033 class CC_TreeEdge; 00034 00040 template<typename T_IOSymbol, typename T_Register, typename T_EdgeTag> 00041 class CC_TreeNode 00042 { 00043 public: 00051 CC_TreeNode(unsigned int _id, 00052 CC_TreeEdge<T_IOSymbol, T_Register, T_EdgeTag> *_p_incoming_edge, 00053 float _path_metric, 00054 int _depth) : 00055 id(_id), 00056 p_incoming_edge(_p_incoming_edge), 00057 path_metric(_path_metric), 00058 depth(_depth), 00059 on_final_path(false) 00060 {} 00061 00065 ~CC_TreeNode() 00066 { 00067 delete_outgoing_edges(); 00068 } 00069 00073 void add_outgoing_edge(CC_TreeEdge<T_IOSymbol, T_Register, T_EdgeTag> *p_outgoing_edge) 00074 { 00075 p_outgoing_edges.push_back(p_outgoing_edge); 00076 } 00077 00081 void delete_outgoing_edges() 00082 { 00083 typename std::vector<CC_TreeEdge<T_IOSymbol, T_Register, T_EdgeTag>*>::iterator e_it = p_outgoing_edges.begin(); 00084 00085 for (; e_it != p_outgoing_edges.end(); ++e_it) 00086 { 00087 if (*e_it) 00088 { 00089 delete *e_it; 00090 *e_it = 0; 00091 } 00092 } 00093 00094 p_outgoing_edges.clear(); 00095 } 00096 00100 const std::vector<CC_TreeEdge<T_IOSymbol, T_Register, T_EdgeTag>*>& get_outgoing_edges() const 00101 { 00102 return p_outgoing_edges; 00103 } 00104 00108 std::vector<CC_TreeEdge<T_IOSymbol, T_Register, T_EdgeTag>*>& get_outgoing_edges() 00109 { 00110 return p_outgoing_edges; 00111 } 00112 00116 CC_TreeEdge<T_IOSymbol, T_Register, T_EdgeTag> *get_incoming_edge() 00117 { 00118 return p_incoming_edge; 00119 } 00120 00124 float get_path_metric() const 00125 { 00126 return path_metric; 00127 } 00128 00132 int get_depth() const 00133 { 00134 return depth; 00135 } 00136 00140 unsigned int get_id() const 00141 { 00142 return id; 00143 } 00144 00148 bool operator<(const CC_TreeNode<T_IOSymbol, T_Register, T_EdgeTag>& other) const 00149 { 00150 return path_metric < other.path_metric; 00151 } 00152 00156 bool operator>(const CC_TreeNode<T_IOSymbol, T_Register, T_EdgeTag>& other) const 00157 { 00158 return path_metric > other.path_metric; 00159 } 00160 00164 const std::vector<T_Register>& get_registers() const 00165 { 00166 return registers; 00167 } 00168 00172 void set_registers(const std::vector<T_Register>& _registers) 00173 { 00174 registers = _registers; 00175 } 00176 00180 void set_on_final_path(bool _on_final_path = true) 00181 { 00182 on_final_path = _on_final_path; 00183 } 00184 00188 bool is_on_final_path() 00189 { 00190 return on_final_path; 00191 } 00192 00196 bool operator<(const CC_TreeNode<T_IOSymbol, T_Register, T_EdgeTag>& other) 00197 { 00198 if (path_metric == other.path_metric) 00199 { 00200 return id < other.id; 00201 } 00202 else 00203 { 00204 return path_metric < other.path_metric; 00205 } 00206 } 00207 00211 bool operator>(const CC_TreeNode<T_IOSymbol, T_Register, T_EdgeTag>& other) 00212 { 00213 if (path_metric == other.path_metric) 00214 { 00215 return id > other.id; 00216 } 00217 else 00218 { 00219 return path_metric > other.path_metric; 00220 } 00221 } 00222 00223 protected: 00224 unsigned int id; 00225 std::vector<CC_TreeEdge<T_IOSymbol, T_Register, T_EdgeTag>*> p_outgoing_edges; 00226 CC_TreeEdge<T_IOSymbol, T_Register, T_EdgeTag> *p_incoming_edge; 00227 float path_metric; 00228 int depth; 00229 std::vector<T_Register> registers; 00230 bool on_final_path; 00231 }; 00232 00233 } // namespace ccsoft 00234 00235 #endif // __CC_TREE_NODE_H__