|
Freya
0.0.1
A Gtk3 MPD Client
|
00001 /*********************************************************** 00002 * This file is part of Freya 00003 * - A free MPD Gtk3 MPD Client - 00004 * 00005 * Authors: Christopher Pahl, Christoph Piechula, 00006 * Eduard Schneider 00007 * 00008 * Copyright (C) [2011-2012] 00009 * Hosted at: https://github.com/studentkittens/Freya 00010 * 00011 * __..--''``---....___ _..._ __ 00012 * /// //_.-' .-/"; ` ``<._ ``.''_ `. / // / 00013 * ///_.-' _..--.'_ `( ) ) // // 00014 * / (_..-' // (< _ ;_..__ ; `' / /// 00015 * / // // // `-._,_)' // / ``--...____..-' /// / // 00016 * Ascii-Art by Felix Lee <flee@cse.psu.edu> 00017 * 00018 * Freya is free software: you can redistribute it and/or modify 00019 * it under the terms of the GNU General Public License as published by 00020 * the Free Software Foundation, either version 3 of the License, or 00021 * (at your option) any later version. 00022 * 00023 * Freya is distributed in the hope that it will be useful, 00024 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00025 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00026 * GNU General Public License for more details. 00027 * 00028 * You should have received a copy of the GNU General Public License 00029 * along with Freya. If not, see <http://www.gnu.org/licenses/>. 00030 **************************************************************/ 00031 #ifndef FREYA_CONFIG_HANDLER_89V106EN 00032 #define FREYA_CONFIG_HANDLER_89V106EN 00033 00034 #include <libxml/parser.h> 00035 #include <glibmm/ustring.h> 00036 00037 #include "Model.hh" 00038 #include "../Utils/Singleton.hh" 00039 00040 namespace Config 00041 { 00045 class Handler 00046 { 00047 DEF_SINGLETON( Handler ) 00048 00049 public: 00050 ~Handler (); 00051 00059 Glib::ustring get_value(Glib::ustring); 00060 00068 int get_value_as_int(Glib::ustring); 00069 00076 void set_value(Glib::ustring, Glib::ustring); 00077 00078 00085 void set_value_as_int(Glib::ustring,int); 00086 00087 00095 Glib::ustring get_default_value(Glib::ustring); 00096 00097 00105 int get_default_value_as_int(Glib::ustring); 00106 00107 00111 void save_config_now(); 00112 00113 private: 00114 /*internal traversing funcs*/ 00115 xmlNodePtr traverse(const char*, xmlNodePtr); 00116 xmlNodePtr _traverse(const char*, char*, char*, size_t, xmlNodePtr); 00117 00118 /*model config member for data access*/ 00119 Model cfgmodel; 00120 Glib::ustring _get_value(Glib::ustring, bool); 00121 int _get_value_as_int(Glib::ustring, bool); 00122 }; 00123 } 00124 00125 #define CONFIG_SET(x,y) Config::Handler::instance().set_value(x,y) 00126 #define CONFIG_GET(x) Config::Handler::instance().get_value(x) 00127 00128 #define CONFIG_SET_AS_INT(x,y) Config::Handler::instance().set_value_as_int(x,y) 00129 #define CONFIG_GET_AS_INT(x) Config::Handler::instance().get_value_as_int(x) 00130 00131 #define CONFIG_SAVE_NOW() Config::Handler::instance().save_config_now() 00132 00133 #define CONFIG_GET_DEFAULT(x) Config::Handler::instance().get_default_value(x) 00134 #define CONFIG_GET_DEFAULT_AS_INT(x) Config::Handler::instance().get_default_value_as_int(x) 00135 00136 #endif /* end of include guard: Handler_89V106EN */
1.8.0