diff options
Diffstat (limited to 'gnuradio-core/src/lib/general/gr_prefs.h')
-rw-r--r-- | gnuradio-core/src/lib/general/gr_prefs.h | 52 |
1 files changed, 50 insertions, 2 deletions
diff --git a/gnuradio-core/src/lib/general/gr_prefs.h b/gnuradio-core/src/lib/general/gr_prefs.h index 68957faab9..4e11d04c5b 100644 --- a/gnuradio-core/src/lib/general/gr_prefs.h +++ b/gnuradio-core/src/lib/general/gr_prefs.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2013 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -19,13 +19,20 @@ * the Free Software Foundation, Inc., 51 Franklin Street, * Boston, MA 02110-1301, USA. */ + #ifndef INCLUDED_GR_PREFS_H #define INCLUDED_GR_PREFS_H #include <gr_core_api.h> #include <string> +#include <map> #include <gruel/thread.h> +typedef std::map< std::string, std::map<std::string, std::string> > gr_config_map_t; +typedef std::map< std::string, std::map<std::string, std::string> >::iterator gr_config_map_itr; +typedef std::map<std::string, std::string> gr_config_map_elem_t; +typedef std::map<std::string, std::string>::iterator gr_config_map_elem_itr; + /*! * \brief Base class for representing user preferences a la windows INI files. * \ingroup misc @@ -44,6 +51,18 @@ public: virtual ~gr_prefs(); /*! + * \brief Returns the configuration options as a string. + */ + std::string to_string(); + + /*! + * \brief Saves the configuration settings to ${HOME}/.gnuradio/config.conf. + * + * WARNING: this will overwrite your current config.conf file. + */ + void save(); + + /*! * \brief Does \p section exist? */ virtual bool has_section(const std::string §ion); @@ -61,6 +80,13 @@ public: const std::string &default_val); /*! + * \brief Set or add a string \p option to \p section with value \p val. + */ + virtual void set_string(const std::string §ion, + const std::string &option, + const std::string &val); + + /*! * \brief If option exists and value can be converted to bool, return it; else default_val. */ virtual bool get_bool(const std::string §ion, @@ -68,6 +94,13 @@ public: bool default_val); /*! + * \brief Set or add a bool \p option to \p section with value \p val. + */ + virtual void set_bool(const std::string §ion, + const std::string &option, + bool val); + + /*! * \brief If option exists and value can be converted to long, return it; else default_val. */ virtual long get_long(const std::string §ion, @@ -75,20 +108,35 @@ public: long default_val); /*! + * \brief Set or add a long \p option to \p section with value \p val. + */ + virtual void set_long(const std::string §ion, + const std::string &option, + long val); + + /*! * \brief If option exists and value can be converted to double, return it; else default_val. */ virtual double get_double(const std::string §ion, const std::string &option, double default_val); + /*! + * \brief Set or add a double \p option to \p section with value \p val. + */ + virtual void set_double(const std::string §ion, + const std::string &option, + double val); + protected: virtual std::vector<std::string> _sys_prefs_filenames(); virtual void _read_files(); + virtual void _convert_to_map(const std::string &conf); virtual char * option_to_env(std::string section, std::string option); private: gruel::mutex d_mutex; - std::string d_configs; + gr_config_map_t d_config_map; }; |