ED247 Library  VA2.3.0
Implementation of ED247-A standard
ed247_signal.h
1 /* -*- mode: c++; c-basic-offset: 2 -*- */
2 /******************************************************************************
3  * The MIT Licence
4  *
5  * Copyright (c) 2021 Airbus Operations S.A.S
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation
10  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11  * and/or sell copies of the Software, and to permit persons to whom the
12  * Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23  * OTHER DEALINGS IN THE SOFTWARE.
24  *****************************************************************************/
25 #ifndef _ED247_SIGNAL_H_
26 #define _ED247_SIGNAL_H_
27 #include "ed247.h"
28 #include "ed247_xml.h"
29 #include "ed247_friend_test.h"
30 #include <memory>
31 #include <vector>
32 #include <unordered_map>
33 
34 
35 // base structures for C API
39 
40 namespace ed247
41 {
43  {
44  public:
45  Signal(const xml::Signal* configuration, ed247_internal_stream_t* ed247_api_stream);
46  ~Signal();
47 
48  // No implicit copy
49  Signal(const Signal & other) = delete;
50  Signal& operator = (const Signal & other) = delete;
51 
52  // configuration accessors
53  const std::string& get_name() const { return _configuration->_name; }
54  const std::string& get_comment() const { return _configuration->_comment; }
55  const std::string& get_icd() const { return _configuration->_icd; }
56  ed247_signal_type_t get_type() const { return _configuration->_type; }
57  uint32_t get_byte_offset() const { return _configuration->_byte_offset; }
58  const std::string& get_analogue_electrical_unit() const { return _configuration->_analogue_electrical_unit; }
59 
60  ed247_nad_type_t get_nad_type() const { return _configuration->_nad_type; }
61  uint32_t get_nad_type_size() const { return _configuration->get_nad_type_size(); }
62  const std::string& get_nad_unit() const { return _configuration->_nad_unit; }
63  const std::vector<uint32_t> get_nad_dimensions() { return _configuration->_nad_dimensions; }
64 
65  uint32_t get_vnad_position() const { return _configuration->_vnad_position; }
66  uint32_t get_vnad_max_number() const { return _configuration->_vnad_max_number; }
67  uint32_t get_sample_max_size_bytes() const { return _configuration->get_sample_max_size_bytes(); }
68 
69 
70  // implementation of ed247_signal_get_stream()
71  ed247_internal_stream_t* get_api_stream() { return _ed247_api_stream; }
72 
73  // Handle user-data
74  void set_user_data(void *user_data) { _user_data = user_data; }
75  void get_user_data(void **user_data) { *user_data = _user_data; }
76 
77 
78  private:
79  const xml::Signal* _configuration;
80  ed247_internal_stream_t* _ed247_api_stream; // Needed for API method ed247_signal_get_stream()
81  void* _user_data;
82  };
83 
84 
85  typedef std::shared_ptr<Signal> signal_ptr_t;
86  typedef std::vector<signal_ptr_t> signal_list_t;
87 
88 
89  class SignalSet
90  {
91  public:
92  signal_ptr_t create(const xml::Signal* configuration, ed247_internal_stream_t* ed247_api_stream);
93  signal_ptr_t get(const std::string& name);
94  signal_list_t find(const std::string& regex);
95 
96  SignalSet();
97  ~SignalSet();
98 
99  SignalSet& operator=(const SignalSet &) = delete;
100  SignalSet& operator=(SignalSet &&) = delete;
101 
102  protected:
103  ED247_FRIEND_TEST();
104  std::unordered_map<std::string, signal_ptr_t> _signals;
105  };
106 }
107 
108 #endif
Definition: ed247_signal.h:42
Definition: ed247_signal.h:89
ed247_signal_type_t
Signal types.
Definition: ed247.h:164
Definition: ed247_xml.h:98
Definition: ed247_stream.h:33
Definition: ed247_signal.h:37
ed247_nad_type_t
NAD type.
Definition: ed247.h:176
Definition: ed247_signal.h:36
Definition: ed247_channel.cpp:37