GNU Radio 3.4.0 C++ API
gr_prefs.h
Go to the documentation of this file.
00001 /* -*- c++ -*- */
00002 /*
00003  * Copyright 2006 Free Software Foundation, Inc.
00004  * 
00005  * This file is part of GNU Radio
00006  * 
00007  * GNU Radio is free software; you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation; either version 3, or (at your option)
00010  * any later version.
00011  * 
00012  * GNU Radio is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with GNU Radio; see the file COPYING.  If not, write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street,
00020  * Boston, MA 02110-1301, USA.
00021  */
00022 #ifndef INCLUDED_GR_PREFS_H
00023 #define INCLUDED_GR_PREFS_H
00024 
00025 #include <string>
00026 
00027 /*!
00028  * \brief Base class for representing user preferences a la windows INI files.
00029  * \ingroup misc
00030  *
00031  * The real implementation is in Python, and is accessable from C++
00032  * via the magic of SWIG directors.
00033  */
00034 
00035 class gr_prefs
00036 {
00037 public:
00038   static gr_prefs *singleton();
00039   static void set_singleton(gr_prefs *p);
00040 
00041   virtual ~gr_prefs();
00042 
00043   /*!
00044    * \brief Does \p section exist?
00045    */
00046   virtual bool has_section(const std::string section);
00047 
00048   /*!
00049    * \brief Does \p option exist?
00050    */
00051   virtual bool has_option(const std::string section, const std::string option);
00052 
00053   /*!
00054    * \brief If option exists return associated value; else default_val.
00055    */
00056   virtual const std::string get_string(const std::string section,
00057                                        const std::string option,
00058                                        const std::string default_val);
00059 
00060   /*!
00061    * \brief If option exists and value can be converted to bool, return it; else default_val.
00062    */
00063   virtual bool get_bool(const std::string section,
00064                         const std::string option,
00065                         bool default_val);
00066 
00067   /*!
00068    * \brief If option exists and value can be converted to long, return it; else default_val.
00069    */
00070   virtual long get_long(const std::string section,
00071                         const std::string option,
00072                         long default_val);
00073 
00074   /*!
00075    * \brief If option exists and value can be converted to double, return it; else default_val.
00076    */
00077   virtual double get_double(const std::string section,
00078                             const std::string option,
00079                             double default_val);
00080 };
00081 
00082 
00083 #endif /* INCLUDED_GR_PREFS_H */