comparison foosdk/sdk/foobar2000/SDK/service_compat.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 // Obsolete features
4
5 //! Special hack to ensure errors when someone tries to ->service_add_ref()/->service_release() on a service_ptr_t
6 template<typename T> class service_obscure_refcounting : public T {
7 private:
8 int service_add_ref() throw();
9 int service_release() throw();
10 };
11
12 //! Converts a service interface pointer to a pointer that obscures service counter functionality.
13 template<typename T> static inline service_obscure_refcounting<T>* service_obscure_refcounting_cast(T * p_source) throw() {return static_cast<service_obscure_refcounting<T>*>(p_source);}
14
15 template<typename T, template<typename> class t_alloc = pfc::alloc_fast>
16 class service_list_t : public pfc::list_t<service_ptr_t<T>, t_alloc >
17 {
18 };
19
20 //! Helper; simulates array with instance of each available implementation of given service class.
21 template<typename T> class service_instance_array_t {
22 public:
23 typedef service_ptr_t<T> t_ptr;
24 service_instance_array_t() {
25 service_class_helper_t<T> helper;
26 const t_size count = helper.get_count();
27 m_data.set_size(count);
28 for(t_size n=0;n<count;n++) m_data[n] = helper.create(n);
29 }
30
31 t_size get_size() const {return m_data.get_size();}
32 const t_ptr & operator[](t_size p_index) const {return m_data[p_index];}
33
34 //nonconst version to allow sorting/bsearching; do not abuse
35 t_ptr & operator[](t_size p_index) {return m_data[p_index];}
36 private:
37 pfc::array_t<t_ptr> m_data;
38 };