ccsoft  0.0.0
Convolutional codes library with soft decision decoding
/shared/development/google_code/rssoft/libccsoft/lib/CC_TreeNodeEdge_base.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_BASE_H__
00027 #define __CC_TREE_NODE_EDGE_BASE_H__
00028 
00029 namespace ccsoft
00030 {
00031 
00032 class CC_TreeNodeEdgeTag_Empty
00033 {
00034 };
00035 
00041 template<typename T_IOSymbol, typename T_Tag>
00042 class CC_TreeNodeEdge_base
00043 {
00044 
00045 public:
00054         CC_TreeNodeEdge_base(unsigned int _id,
00055                         const T_IOSymbol& _in_symbol,
00056             float _incoming_edge_metric,
00057             float _path_metric,
00058             int _depth) :
00059                 id(_id),
00060                 in_symbol(_in_symbol),
00061                 incoming_edge_metric(_incoming_edge_metric),
00062                 path_metric(_path_metric),
00063                 depth(_depth),
00064                 on_final_path(false)
00065     {}
00066 
00070         ~CC_TreeNodeEdge_base()
00071         {
00072         }
00073 
00077     float get_path_metric() const
00078     {
00079         return path_metric;
00080     }
00081 
00085     int get_depth() const
00086     {
00087         return depth;
00088     }
00089 
00093     unsigned int get_id() const
00094     {
00095         return id;
00096     }
00097 
00101     bool operator<(const CC_TreeNodeEdge_base<T_IOSymbol, T_Tag>& other) const
00102     {
00103         return path_metric < other.path_metric;
00104     }
00105 
00109     bool operator>(const CC_TreeNodeEdge_base<T_IOSymbol, T_Tag>& other) const
00110     {
00111         return path_metric > other.path_metric;
00112     }
00113 
00117     void set_on_final_path(bool _on_final_path = true)
00118     {
00119         on_final_path = _on_final_path;
00120     }
00121 
00125     bool is_on_final_path()
00126     {
00127         return on_final_path;
00128     }
00129 
00133     const T_IOSymbol& get_in_symbol() const
00134     {
00135         return in_symbol;
00136     }
00137 
00141     float get_incoming_metric() const
00142     {
00143         return incoming_edge_metric;
00144     }
00145 
00149     const T_Tag& get_tag() const
00150     {
00151         return tag;
00152     }
00153 
00157     T_Tag& get_tag()
00158     {
00159         return tag;
00160     }
00161 
00165     bool operator<(const CC_TreeNodeEdge_base<T_IOSymbol, T_Tag>& other)
00166     {
00167         if (path_metric == other.path_metric)
00168         {
00169             return id < other.id;
00170         }
00171         else
00172         {
00173             return path_metric < other.path_metric;
00174         }
00175     }
00176 
00180     bool operator>(const CC_TreeNodeEdge_base<T_IOSymbol, T_Tag>& other)
00181     {
00182         if (path_metric == other.path_metric)
00183         {
00184             return id > other.id;
00185         }
00186         else
00187         {
00188             return path_metric > other.path_metric;
00189         }
00190     }
00191 
00192 
00193 protected:
00194     unsigned int id; 
00195     T_IOSymbol in_symbol; 
00196     float path_metric; 
00197     float incoming_edge_metric; 
00198     int depth; 
00199     bool on_final_path; 
00200     T_Tag tag; 
00201 };
00202 
00203 } // namespace ccsoft
00204 
00205 #endif
 All Classes Namespaces Files Functions Variables Typedefs Friends Defines