GNSS-SDR  0.0.21
An Open Source GNSS Software Defined Receiver
sensor_identifier.h
Go to the documentation of this file.
1 /*!
2  * \file sensor_identifier.h
3  * \brief
4  * \author Victor Castillo, 2025. victorcastilloaguero(at)gmail.com
5  *
6  * -----------------------------------------------------------------------------
7  *
8  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
9  * This file is part of GNSS-SDR.
10  *
11  * Copyright (C) 2024-2025 (see AUTHORS file for a list of contributors)
12  * SPDX-License-Identifier: GPL-3.0-or-later
13  *
14  * -----------------------------------------------------------------------------
15  */
16 
17 
18 #ifndef GNSS_SDR_SENSOR_IDENTIFIER_H
19 #define GNSS_SDR_SENSOR_IDENTIFIER_H
20 
21 #include "sensor_data_type.h"
22 #include <functional>
23 #include <string>
24 
25 /** \addtogroup Algorithms_Library
26  * \{ */
27 /** \addtogroup Algorithm_libs algorithms_libs
28  * \{ */
29 
31 {
32  SensorIdentifier() = delete;
33  enum value_type : unsigned short
34  {
35  SAMPLE_STAMP = 0, // Used internally
36  CHUNK_COUNT, // Used internally
37  IMU_VEL_X,
38  IMU_VEL_Y,
39  IMU_VEL_Z,
40  IMU_ACC_X,
41  IMU_ACC_Y,
42  IMU_ACC_Z,
43  IMU_ANG_VEL_X,
44  IMU_ANG_VEL_Y,
45  IMU_ANG_VEL_Z,
46  IMU_ANG_ACC_X,
47  IMU_ANG_ACC_Y,
48  IMU_ANG_ACC_Z,
49  };
50 
51  static value_type from_string(const std::string& s);
52 
53  static std::string to_string(value_type v);
54 
55  static bool is_valid_type(value_type sensor_id, SensorDataType::value_type type);
56 
57  static SensorDataType::value_type get_internal_type(value_type sensor_id);
58 
59  static pmt::pmt_t convert_to_internal_type(value_type sensor_id, SensorDataType::value_type original_type, const pmt::pmt_t& value);
60 };
61 
62 
63 // Fix for C++11
64 namespace std
65 {
66 template <>
67 struct hash<SensorIdentifier::value_type>
68 {
69  std::size_t operator()(const SensorIdentifier::value_type& key) const noexcept
70  {
71  return std::hash<unsigned short>()(static_cast<unsigned short>(key));
72  }
73 };
74 } // namespace std
75 
76 
77 /** \} */
78 /** \} */
79 #endif // GNSS_SDR_SENSOR_IDENTIFIER_H
STL namespace.