2011-10-01 18:45:20 +00:00
|
|
|
/*!
|
|
|
|
* \file file_configuration.h
|
2011-12-28 21:36:45 +00:00
|
|
|
* \brief A ConfigurationInterface that reads the configuration from a file.
|
2011-10-01 18:45:20 +00:00
|
|
|
* \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com
|
|
|
|
*
|
|
|
|
* This implementation has a text file as the source for the values of the parameters.
|
|
|
|
* The file is in the INI format, containing sections and pairs of names and values.
|
2020-02-05 20:24:46 +00:00
|
|
|
* For more information about the INI format, see https://en.wikipedia.org/wiki/INI_file
|
2011-10-01 18:45:20 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2011-10-01 18:45:20 +00:00
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* GNSS-SDR is a Global Navigation Satellite System software-defined receiver.
|
2011-10-01 18:45:20 +00:00
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
2020-12-30 12:35:06 +00:00
|
|
|
* Copyright (C) 2010-2020 (see AUTHORS file for a list of contributors)
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2011-10-01 18:45:20 +00:00
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2011-10-01 18:45:20 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2020-02-08 09:10:46 +00:00
|
|
|
#ifndef GNSS_SDR_FILE_CONFIGURATION_H
|
|
|
|
#define GNSS_SDR_FILE_CONFIGURATION_H
|
2011-10-01 18:45:20 +00:00
|
|
|
|
2020-06-23 07:47:58 +00:00
|
|
|
#include "INIReader.h"
|
2011-10-01 18:45:20 +00:00
|
|
|
#include "configuration_interface.h"
|
2020-06-23 07:47:58 +00:00
|
|
|
#include "in_memory_configuration.h"
|
|
|
|
#include "string_converter.h"
|
2018-12-02 04:29:11 +00:00
|
|
|
#include <cstdint>
|
2014-04-03 21:59:14 +00:00
|
|
|
#include <memory>
|
2011-10-01 18:45:20 +00:00
|
|
|
#include <string>
|
|
|
|
|
2020-11-01 12:37:19 +00:00
|
|
|
/** \addtogroup Core
|
|
|
|
* \{ */
|
|
|
|
/** \addtogroup Core_Receiver
|
|
|
|
* \{ */
|
|
|
|
|
|
|
|
|
2011-10-01 18:45:20 +00:00
|
|
|
/*!
|
|
|
|
* \brief This class is an implementation of the interface ConfigurationInterface
|
|
|
|
*
|
|
|
|
* Derived from ConfigurationInterface, this class implements an interface
|
|
|
|
* to a configuration file. This implementation has a text file as the source
|
|
|
|
* for the values of the parameters.
|
|
|
|
* The file is in the INI format, containing sections and pairs of names and values.
|
2020-02-05 20:24:46 +00:00
|
|
|
* For more information about the INI format, see https://en.wikipedia.org/wiki/INI_file
|
2011-10-01 18:45:20 +00:00
|
|
|
*/
|
2012-10-28 10:56:04 +00:00
|
|
|
class FileConfiguration : public ConfigurationInterface
|
|
|
|
{
|
2011-10-01 18:45:20 +00:00
|
|
|
public:
|
2019-08-23 19:25:44 +00:00
|
|
|
explicit FileConfiguration(std::string filename);
|
2011-10-01 18:45:20 +00:00
|
|
|
FileConfiguration();
|
2020-02-26 21:40:00 +00:00
|
|
|
~FileConfiguration() = default;
|
2020-06-23 09:05:31 +00:00
|
|
|
std::string property(std::string property_name, std::string default_value) const override;
|
|
|
|
bool property(std::string property_name, bool default_value) const override;
|
|
|
|
int64_t property(std::string property_name, int64_t default_value) const override;
|
|
|
|
uint64_t property(std::string property_name, uint64_t default_value) const override;
|
|
|
|
int32_t property(std::string property_name, int32_t default_value) const override;
|
|
|
|
uint32_t property(std::string property_name, uint32_t default_value) const override;
|
|
|
|
int16_t property(std::string property_name, int16_t default_value) const override;
|
|
|
|
uint16_t property(std::string property_name, uint16_t default_value) const override;
|
|
|
|
float property(std::string property_name, float default_value) const override;
|
|
|
|
double property(std::string property_name, double default_value) const override;
|
|
|
|
void set_property(std::string property_name, std::string value) override;
|
|
|
|
bool is_present(const std::string& property_name) const;
|
2021-01-24 23:49:36 +00:00
|
|
|
bool has_section() const;
|
2018-03-03 01:03:39 +00:00
|
|
|
|
2011-10-01 18:45:20 +00:00
|
|
|
private:
|
|
|
|
void init();
|
|
|
|
std::string filename_;
|
2020-06-23 07:47:58 +00:00
|
|
|
std::unique_ptr<INIReader> ini_reader_;
|
|
|
|
std::unique_ptr<InMemoryConfiguration> overrided_;
|
|
|
|
std::unique_ptr<StringConverter> converter_;
|
2019-07-07 17:56:23 +00:00
|
|
|
int error_{};
|
2011-10-01 18:45:20 +00:00
|
|
|
};
|
|
|
|
|
2020-11-01 12:37:19 +00:00
|
|
|
|
|
|
|
/** \} */
|
|
|
|
/** \} */
|
2020-02-08 09:10:46 +00:00
|
|
|
#endif // GNSS_SDR_FILE_CONFIGURATION_H
|