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.
|
|
|
|
* For more information about the INI format, see http://en.wikipedia.org/wiki/INI_file
|
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*
|
2018-05-13 20:49:11 +00:00
|
|
|
* Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors)
|
2011-10-01 18:45:20 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is a software defined Global Navigation
|
|
|
|
* Satellite Systems receiver
|
|
|
|
*
|
|
|
|
* This file is part of GNSS-SDR.
|
|
|
|
*
|
|
|
|
* GNSS-SDR is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
2015-01-08 18:49:59 +00:00
|
|
|
* (at your option) any later version.
|
2011-10-01 18:45:20 +00:00
|
|
|
*
|
|
|
|
* GNSS-SDR is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-05-13 20:49:11 +00:00
|
|
|
* along with GNSS-SDR. If not, see <https://www.gnu.org/licenses/>.
|
2011-10-01 18:45:20 +00:00
|
|
|
*
|
|
|
|
* -------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef GNSS_SDR_FILE_CONFIGURATION_H_
|
|
|
|
#define GNSS_SDR_FILE_CONFIGURATION_H_
|
|
|
|
|
|
|
|
#include "configuration_interface.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>
|
|
|
|
|
|
|
|
class INIReader;
|
|
|
|
class StringConverter;
|
|
|
|
class InMemoryConfiguration;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \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.
|
|
|
|
* For more information about the INI format, see http://en.wikipedia.org/wiki/INI_file
|
|
|
|
*/
|
2012-10-28 10:56:04 +00:00
|
|
|
class FileConfiguration : public ConfigurationInterface
|
|
|
|
{
|
2011-10-01 18:45:20 +00:00
|
|
|
public:
|
|
|
|
FileConfiguration(std::string filename);
|
|
|
|
FileConfiguration();
|
|
|
|
//! Virtual destructor
|
2018-03-03 01:03:39 +00:00
|
|
|
~FileConfiguration();
|
2011-10-01 18:45:20 +00:00
|
|
|
std::string property(std::string property_name, std::string default_value);
|
|
|
|
bool property(std::string property_name, bool default_value);
|
2018-12-02 04:29:11 +00:00
|
|
|
int64_t property(std::string property_name, int64_t default_value);
|
|
|
|
uint64_t property(std::string property_name, uint64_t default_value);
|
|
|
|
int32_t property(std::string property_name, int32_t default_value);
|
|
|
|
uint32_t property(std::string property_name, uint32_t default_value);
|
|
|
|
int16_t property(std::string property_name, int16_t default_value);
|
|
|
|
uint16_t property(std::string property_name, uint16_t default_value);
|
2011-10-01 18:45:20 +00:00
|
|
|
float property(std::string property_name, float default_value);
|
|
|
|
double property(std::string property_name, double default_value);
|
|
|
|
void set_property(std::string property_name, std::string value);
|
2018-03-03 01:03:39 +00:00
|
|
|
|
2011-10-01 18:45:20 +00:00
|
|
|
private:
|
|
|
|
void init();
|
|
|
|
std::string filename_;
|
2014-04-03 21:59:14 +00:00
|
|
|
std::shared_ptr<INIReader> ini_reader_;
|
|
|
|
std::shared_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
|
|
|
};
|
|
|
|
|
|
|
|
#endif /*GNSS_SDR_FILE_CONFIGURATION_H_*/
|