From 7bdd6effd7b6b36ea8d86cb57329a20874fb3290 Mon Sep 17 00:00:00 2001
From: Tom Rondeau <tom@trondeau.com>
Date: Mon, 2 Mar 2015 13:44:17 -0500
Subject: runtime: more generic version of prefs class.

Adds another constructor to open a particular file to configure specific preferences.
---
 gnuradio-runtime/lib/prefs.cc | 28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

(limited to 'gnuradio-runtime/lib/prefs.cc')

diff --git a/gnuradio-runtime/lib/prefs.cc b/gnuradio-runtime/lib/prefs.cc
index b7fcaada9d..b303ffdaf9 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()
   {
-- 
cgit v1.2.3