[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 20/50: runtime: more generic version of pre
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 20/50: runtime: more generic version of prefs class. |
Date: |
Wed, 15 Apr 2015 21:07:54 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit 7bdd6effd7b6b36ea8d86cb57329a20874fb3290
Author: Tom Rondeau <address@hidden>
Date: Mon Mar 2 13:44:17 2015 -0500
runtime: more generic version of prefs class.
Adds another constructor to open a particular file to configure specific
preferences.
---
gnuradio-runtime/include/gnuradio/prefs.h | 28 ++++++++++++++++++++++++++--
gnuradio-runtime/lib/prefs.cc | 28 ++++++++++++++++++++--------
gnuradio-runtime/swig/prefs.i | 4 +++-
3 files changed, 49 insertions(+), 11 deletions(-)
diff --git a/gnuradio-runtime/include/gnuradio/prefs.h
b/gnuradio-runtime/include/gnuradio/prefs.h
index a9a2858..8049be7 100644
--- a/gnuradio-runtime/include/gnuradio/prefs.h
+++ b/gnuradio-runtime/include/gnuradio/prefs.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006,2013 Free Software Foundation, Inc.
+ * Copyright 2006,2013,2015 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -47,10 +47,34 @@ namespace gr {
public:
static prefs *singleton();
+ /*!
+ * \brief Creates an object to read preference files.
+ *
+ * \detail
+ *
+ * If no file name is given (empty arg list or ""), this opens up
+ * the standard GNU Radio configuration files in
+ * prefix/etc/gnuradio/conf.d as well as ~/.gnuradio/config.conf.
+ *
+ * Only access this through the singleton defined here:
+ * prefs *p = prefs::singleton();
+ */
prefs();
+
virtual ~prefs();
/*!
+ * If specifying a file name, this opens that specific
+ * configuration file of the standard form containing sections and
+ * key-value pairs:
+ *
+ * [SectionName]
+ * key0 = value0
+ * key1 = value1
+ */
+ void add_config_file(const std::string &configfile);
+
+ /*!
* \brief Returns the configuration options as a string.
*/
std::string to_string();
@@ -137,7 +161,7 @@ namespace gr {
protected:
virtual std::vector<std::string> _sys_prefs_filenames();
- virtual void _read_files();
+ virtual std::string _read_files(const std::vector<std::string> &filenames);
virtual void _convert_to_map(const std::string &conf);
virtual char * option_to_env(std::string section, std::string option);
diff --git a/gnuradio-runtime/lib/prefs.cc b/gnuradio-runtime/lib/prefs.cc
index b7fcaad..b303ffd 100644
--- a/gnuradio-runtime/lib/prefs.cc
+++ b/gnuradio-runtime/lib/prefs.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006,2013 Free Software Foundation, Inc.
+ * Copyright 2006,2013,2015 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -46,7 +46,10 @@ namespace gr {
prefs::prefs()
{
- _read_files();
+ std::string config = _read_files(_sys_prefs_filenames());
+
+ // Convert the string into a map
+ _convert_to_map(config);
}
prefs::~prefs()
@@ -83,13 +86,12 @@ namespace gr {
return fnames;
}
- void
- prefs::_read_files()
+ std::string
+ prefs::_read_files(const std::vector<std::string> &filenames)
{
std::string config;
- std::vector<std::string> filenames = _sys_prefs_filenames();
- std::vector<std::string>::iterator sitr;
+ std::vector<std::string>::const_iterator sitr;
char tmp[1024];
for(sitr = filenames.begin(); sitr != filenames.end(); sitr++) {
fs::ifstream fin(*sitr);
@@ -142,8 +144,7 @@ namespace gr {
fin.close();
}
- // Convert the string into a map
- _convert_to_map(config);
+ return config;
}
void
@@ -188,6 +189,17 @@ namespace gr {
}
}
+ void
+ prefs::add_config_file(const std::string &configfile)
+ {
+ std::vector<std::string> filenames;
+ filenames.push_back(configfile);
+
+ std::string config = _read_files(filenames);
+ _convert_to_map(config);
+ }
+
+
std::string
prefs::to_string()
{
diff --git a/gnuradio-runtime/swig/prefs.i b/gnuradio-runtime/swig/prefs.i
index ac5fab7..4774146 100644
--- a/gnuradio-runtime/swig/prefs.i
+++ b/gnuradio-runtime/swig/prefs.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2006,2013 Free Software Foundation, Inc.
+ * Copyright 2006,2015 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -25,6 +25,8 @@ class gr::prefs
public:
static gr::prefs *singleton();
+ void add_config_file(const std::string &configfile);
+
virtual ~prefs();
std::string to_string();
- [Commit-gnuradio] [gnuradio] branch master updated (676d5cb -> b092142), git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 03/50: controlport: working controlport server using thrift., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 06/50: controlport: quick fix, git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 02/50: ctrlport: thrift: "py" instead of "python" -- guessing a version thing, git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 04/50: controlport: restructuring to add subdirs for different cp backends., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 18/50: controlport: improving transport layer throughput., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 07/50: controlport: Addes a FindThrift cmake module to find the Thrift headers, libraries, and Python files., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 17/50: controlport: convert to To_PMT registration objects, git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 20/50: runtime: more generic version of prefs class.,
git <=
- [Commit-gnuradio] [gnuradio] 22/50: cmake: force QA tests to turn ControlPort off by default., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 15/50: controlport: convert rpcpmtconverter::to_pmt() if statement to a function object map, git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 01/50: Initial thrift definition for gnuradio, git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 14/50: controlport: Thrift's binary type, git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 09/50: controlport: cleanup and switching over to new Python common interface., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 23/50: controlport: cleaning up and using logger to display endpoint., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 34/50: controlport: replacement of nanosleep() with boost::sleep() in startup thread. Fix of merge error in booter_thrift., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 28/50: controlport: more cleaning up., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 31/50: controlport: moving the logger call that publishes Thrift's endpoint to i_impl()., git, 2015/04/16
- [Commit-gnuradio] [gnuradio] 24/50: controlport: adding performance and controlport monitor GRC blocks., git, 2015/04/16