comparison foosdk/sdk/foobar2000/helpers/advconfig_runtime.h @ 1:20d02a178406 default tip

*: check in everything else yay
author Paper <paper@tflc.us>
date Mon, 05 Jan 2026 02:15:46 -0500
parents
children
comparison
equal deleted inserted replaced
0:e9bb126753e7 1:20d02a178406
1 #pragma once
2
3 // Alternate advconfig var implementations that discard their state across app restarts - use for debug options that should not stick
4
5 template<bool p_is_radio = false, uint32_t prefFlags = 0>
6 class advconfig_entry_checkbox_runtime_impl : public advconfig_entry_checkbox_v2 {
7 public:
8 advconfig_entry_checkbox_runtime_impl(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,bool p_initialstate)
9 : m_name(p_name), m_initialstate(p_initialstate), m_state(p_initialstate), m_parent(p_parent), m_priority(p_priority), m_guid(p_guid) {}
10
11 void get_name(pfc::string_base & p_out) {p_out = m_name;}
12 GUID get_guid() {return m_guid;}
13 GUID get_parent() {return m_parent;}
14 void reset() {m_state = m_initialstate;}
15 bool get_state() {return m_state;}
16 void set_state(bool p_state) {m_state = p_state;}
17 bool is_radio() {return p_is_radio;}
18 double get_sort_priority() {return m_priority;}
19 bool get_state_() const {return m_state;}
20 bool get_default_state() {return m_initialstate;}
21 bool get_default_state_() const {return m_initialstate;}
22 t_uint32 get_preferences_flags() {return prefFlags;}
23 private:
24 pfc::string8 m_name;
25 const bool m_initialstate;
26 bool m_state;
27 const GUID m_parent;
28 const GUID m_guid;
29 const double m_priority;
30 };
31
32 template<bool p_is_radio, uint32_t prefFlags = 0>
33 class advconfig_checkbox_factory_runtime_t : public service_factory_single_t<advconfig_entry_checkbox_runtime_impl<p_is_radio, prefFlags> > {
34 public:
35 advconfig_checkbox_factory_runtime_t(const char * p_name,const GUID & p_guid,const GUID & p_parent,double p_priority,bool p_initialstate)
36 : service_factory_single_t<advconfig_entry_checkbox_runtime_impl<p_is_radio, prefFlags> >(p_name,p_guid,p_parent,p_priority,p_initialstate) {}
37
38 bool get() const {return this->get_static_instance().get_state_();}
39 void set(bool val) {this->get_static_instance().set_state(val);}
40 operator bool() const {return get();}
41 bool operator=(bool val) {set(val); return val;}
42 };
43
44 typedef advconfig_checkbox_factory_runtime_t<false> advconfig_checkbox_factory_runtime;
45 typedef advconfig_checkbox_factory_runtime_t<true> advconfig_radio_factory_runtime;