GNSS-SDR  0.0.13
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  * Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
13  *
14  * GNSS-SDR is a software defined Global Navigation
15  * Satellite Systems receiver
16  *
17  * This file is part of GNSS-SDR.
18  *
19  * SPDX-License-Identifier: GPL-3.0-or-later
20  *
21  * -----------------------------------------------------------------------------
22  */
23 
24 
25 #ifndef GNSS_SDR_FILE_CONFIGURATION_H
26 #define GNSS_SDR_FILE_CONFIGURATION_H
27 
28 #include "INIReader.h"
31 #include "string_converter.h"
32 #include <cstdint>
33 #include <memory>
34 #include <string>
35 
36 /*!
37  * \brief This class is an implementation of the interface ConfigurationInterface
38  *
39  * Derived from ConfigurationInterface, this class implements an interface
40  * to a configuration file. This implementation has a text file as the source
41  * for the values of the parameters.
42  * The file is in the INI format, containing sections and pairs of names and values.
43  * For more information about the INI format, see https://en.wikipedia.org/wiki/INI_file
44  */
46 {
47 public:
48  explicit FileConfiguration(std::string filename);
50  ~FileConfiguration() = default;
51  std::string property(std::string property_name, std::string default_value) const override;
52  bool property(std::string property_name, bool default_value) const override;
53  int64_t property(std::string property_name, int64_t default_value) const override;
54  uint64_t property(std::string property_name, uint64_t default_value) const override;
55  int32_t property(std::string property_name, int32_t default_value) const override;
56  uint32_t property(std::string property_name, uint32_t default_value) const override;
57  int16_t property(std::string property_name, int16_t default_value) const override;
58  uint16_t property(std::string property_name, uint16_t default_value) const override;
59  float property(std::string property_name, float default_value) const override;
60  double property(std::string property_name, double default_value) const override;
61  void set_property(std::string property_name, std::string value) override;
62  bool is_present(const std::string& property_name) const;
63 
64 private:
65  void init();
66  std::string filename_;
67  std::unique_ptr<INIReader> ini_reader_;
68  std::unique_ptr<InMemoryConfiguration> overrided_;
69  std::unique_ptr<StringConverter> converter_;
70  int error_{};
71 };
72 
73 #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...