Sayonara Player
SettingRegistry.h
1 /* SettingRegistry.h */
2 
3 /* Copyright (C) 2011-2015 Lucio Carreras
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 
22 
23 #include "Helper/Settings/Settings.h"
24 #include "Helper/Settings/SettingKey.h"
25 #include "Helper/globals.h"
26 
27 #include <type_traits>
28 
30 {
31  SINGLETON(SettingRegistry)
32 
33 private:
34  Settings* _settings=nullptr;
35 
36  template<typename KEY, typename T>
37  void register_setting(const KEY& key, const char* db_key, const T& default_value){
38 
39  typedef decltype(key.p) ValueTypePtr;
40  typedef typename std::remove_pointer<ValueTypePtr>::type ValueType;
41  auto setting = new Setting<ValueType>(key, db_key, default_value);
42 
43  _settings->register_setting( setting );
44  }
45 
46  template<typename KEY, typename T>
47  void register_setting(const KEY& key, const T& default_value){
48 
49  typedef decltype(key.p) ValueTypePtr;
50  typedef typename std::remove_pointer<ValueTypePtr>::type ValueType;
51  auto setting = new Setting<ValueType>(key, default_value);
52 
53  _settings->register_setting( setting );
54  }
55 
56 public:
57  bool init();
58 };
59 
The Setting class T is the pure value type e.g. QString.
Definition: Setting.h:68
The Settings class.
Definition: Settings.h:31
Definition: SettingRegistry.h:29