GNSS-SDR  0.0.19
An Open Source GNSS Software Defined Receiver
file_configuration.h
Go to the documentation of this file.
1 /*!
2  * \file file_configuration.h
3  * \brief A ConfigurationInterface that reads the configuration from a file.
4  * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
5  *
6  * This implementation has a text file as the source for the values of the parameters.
7  * The file is in the INI format, containing sections and pairs of names and values.
8  * For more information about the INI format, see https://en.wikipedia.org/wiki/INI_file
9  *
10  * -----------------------------------------------------------------------------
11  *
12  * GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
13  * This file is part of GNSS-SDR.
14  *
15  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
16  * SPDX-License-Identifier: GPL-3.0-or-later
17  *
18  * -----------------------------------------------------------------------------
19  */
20 
21 
22 #ifndef GNSS_SDR_FILE_CONFIGURATION_H
23 #define GNSS_SDR_FILE_CONFIGURATION_H
24 
25 #include "INIReader.h"
28 #include "string_converter.h"
29 #include <cstdint>
30 #include <memory>
31 #include <string>
32 
33 /** \addtogroup Core
34  * \{ */
35 /** \addtogroup Core_Receiver
36  * \{ */
37 
38 
39 /*!
40  * \brief This class is an implementation of the interface ConfigurationInterface
41  *
42  * Derived from ConfigurationInterface, this class implements an interface
43  * to a configuration file. This implementation has a text file as the source
44  * for the values of the parameters.
45  * The file is in the INI format, containing sections and pairs of names and values.
46  * For more information about the INI format, see https://en.wikipedia.org/wiki/INI_file
47  */
49 {
50 public:
51  explicit FileConfiguration(std::string filename);
53  ~FileConfiguration() = default;
54  std::string property(std::string property_name, std::string default_value) const override;
55  bool property(std::string property_name, bool default_value) const override;
56  int64_t property(std::string property_name, int64_t default_value) const override;
57  uint64_t property(std::string property_name, uint64_t default_value) const override;
58  int32_t property(std::string property_name, int32_t default_value) const override;
59  uint32_t property(std::string property_name, uint32_t default_value) const override;
60  int16_t property(std::string property_name, int16_t default_value) const override;
61  uint16_t property(std::string property_name, uint16_t default_value) const override;
62  float property(std::string property_name, float default_value) const override;
63  double property(std::string property_name, double default_value) const override;
64  void set_property(std::string property_name, std::string value) override;
65  bool is_present(const std::string& property_name) const;
66  bool has_section() const;
67 
68 private:
69  void init();
70  std::string filename_;
71  std::unique_ptr<INIReader> ini_reader_;
72  std::unique_ptr<InMemoryConfiguration> overrided_;
73  std::unique_ptr<StringConverter> converter_;
74  int error_{};
75 };
76 
77 
78 /** \} */
79 /** \} */
80 #endif // GNSS_SDR_FILE_CONFIGURATION_H
This class is an implementation of the interface ConfigurationInterface.
A ConfigurationInterface for testing purposes.
This abstract class represents an interface to configuration parameters.
This class reads an INI file into easy-to-access name/value pairs.
This class represents an interface to configuration parameters.
Interface of a class that interprets the contents of a string and converts it into different types...