ccsoft  0.0.0
Convolutional codes library with soft decision decoding
/shared/development/google_code/rssoft/libccsoft/lib/CC_TreeNodeEdge.h
Go to the documentation of this file.
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  Combination of a Node and its incoming Edge in the convolutional code tree
00021  (node+edge combo). In a tree structure you don't need to store nodes and
00022  edges as nodes have a single incoming edge. So a node can incorporate
00023  its incoming edge.
00024 
00025  */
00026 #ifndef __CC_TREE_NODE_EDGE_H__
00027 #define __CC_TREE_NODE_EDGE_H__
00028 
00029 #include "CC_TreeNodeEdge_base.h"
00030 #include <vector>
00031 
00032 namespace ccsoft
00033 {
00034 
00041 template<typename T_IOSymbol, typename T_Register, typename T_Tag> 
00042 class CC_TreeNodeEdge : public CC_TreeNodeEdge_base<T_IOSymbol, T_Tag>
00043 {
00044 
00045 public:
00055         CC_TreeNodeEdge(unsigned int _id,
00056                         CC_TreeNodeEdge<T_IOSymbol, T_Register, T_Tag> *_p_incoming_node_edge,
00057                         const T_IOSymbol& _in_symbol,
00058             float _incoming_edge_metric,
00059             float _path_metric,
00060             int _depth) :
00061                 CC_TreeNodeEdge_base<T_IOSymbol, T_Tag>(_id, _in_symbol, _incoming_edge_metric, _path_metric, _depth),
00062                 p_incoming_node_edge(_p_incoming_node_edge)
00063     {}
00064 
00068         ~CC_TreeNodeEdge()
00069         {
00070                 // deletes all outgoing edge+nodes
00071                 delete_outgoing_node_edges();
00072         }
00073 
00078     void add_outgoing_node_edge(CC_TreeNodeEdge<T_IOSymbol, T_Register, T_Tag> *p_outgoing_node_edge)
00079     {
00080         p_outgoing_node_edges.push_back(p_outgoing_node_edge);
00081     }
00082 
00086     void delete_outgoing_node_edges()
00087     {
00088         typename std::vector<CC_TreeNodeEdge<T_IOSymbol, T_Register, T_Tag>*>::iterator ne_it = p_outgoing_node_edges.begin();
00089 
00090         for (; ne_it != p_outgoing_node_edges.end(); ++ne_it)
00091         {
00092             if (*ne_it)
00093             {
00094                 delete *ne_it;
00095                 *ne_it = 0;
00096             }
00097         }
00098 
00099         p_outgoing_node_edges.clear();
00100     }
00101 
00105     const std::vector<CC_TreeNodeEdge<T_IOSymbol, T_Register, T_Tag>*>& get_outgoing_node_edges() const
00106     {
00107         return p_outgoing_node_edges;
00108     }
00109 
00113     std::vector<CC_TreeNodeEdge<T_IOSymbol, T_Register, T_Tag>*>& get_outgoing_node_edges()
00114     {
00115         return p_outgoing_node_edges;
00116     }
00117 
00121     CC_TreeNodeEdge<T_IOSymbol, T_Register, T_Tag> *get_incoming_node_edge()
00122     {
00123         return p_incoming_node_edge;
00124     }
00125 
00129     const std::vector<T_Register>& get_registers() const
00130     {
00131         return registers;
00132     }
00133 
00137     void set_registers(const std::vector<T_Register>& _registers)
00138     {
00139         registers = _registers;
00140     }
00141 
00142 protected:
00143     std::vector<CC_TreeNodeEdge<T_IOSymbol, T_Register, T_Tag>*> p_outgoing_node_edges; 
00144     CC_TreeNodeEdge<T_IOSymbol, T_Register, T_Tag> *p_incoming_node_edge; 
00145     std::vector<T_Register> registers; 
00146 };
00147 
00148 } // namespace ccsoft
00149 
00150 #endif
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines