GNU Radio's SATNOGS Package
morse_tree.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * gr-satnogs: SatNOGS GNU Radio Out-Of-Tree Module
4  *
5  * Copyright (C) 2016, 2019, Libre Space Foundation <http://libre.space>
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef INCLUDED_SATNOGS_MORSE_TREE_H
22 #define INCLUDED_SATNOGS_MORSE_TREE_H
23 
24 #include <satnogs/api.h>
25 #include <string>
26 #include <satnogs/morse.h>
27 
28 namespace gr {
29 namespace satnogs {
30 
31 /*!
32  * \brief Binary tree node containing the corresponding character
33  */
35 private:
36  const char d_char;
37  tree_node *d_left;
38  tree_node *d_right;
39 
40 public:
41  tree_node(char c);
42 
43  void
44  set_left_child(tree_node *child);
45 
46  void
47  set_right_child(tree_node *child);
48 
49  tree_node *
50  get_left_child();
51 
52  tree_node *
53  get_right_child();
54 
55  char
56  get_char();
57 };
58 
59 /*!
60  * \brief A Binary tree representation of the Morse coding scheme.
61  * Left transitions occur when a dot is received, whereas right transitions
62  * are performed during the reception of a dash.
63  *
64  * The tree follows the ITU International Morse code representation
65  * ITU-R M.1677-1
66  */
68 public:
69  morse_tree(size_t max_len = 128);
70  morse_tree(char unrecognized, size_t max_len = 128);
71  ~morse_tree();
72  void
73  reset();
74  bool
75  received_symbol(morse_symbol_t s);
76  std::string
77  get_word();
78  size_t
79  get_max_word_len() const;
80  size_t
81  get_word_len();
82 
83 private:
84  const char d_unrecognized_symbol;
85  tree_node *d_root;
86  tree_node *d_current;
87  const size_t d_buff_len;
88  size_t d_word_len;
89  char *d_word_buffer;
90 
91  void
92  construct_tree();
93  void
94  delete_tree(tree_node *node);
95 };
96 
97 } // namespace satnogs
98 } // namespace gr
99 
100 #endif /* INCLUDED_SATNOGS_MORSE_TREE_H */
101 
Binary tree node containing the corresponding character.
Definition: morse_tree.h:34
Definition: amsat_duv_decoder.h:29
A Binary tree representation of the Morse coding scheme. Left transitions occur when a dot is receive...
Definition: morse_tree.h:67
#define SATNOGS_API
Definition: api.h:30
data_t s[NROOTS]
Definition: decode_rs.h:75
morse_symbol_t
Definition: morse.h:28