Mercurial > foo_out_sdl
comparison foosdk/sdk/foobar2000/SDK/library_callbacks.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 #include "library_manager.h" | |
| 3 #include "metadb_callbacks.h" | |
| 4 #include "callback_merit.h" | |
| 5 | |
| 6 //! Callback service receiving notifications about Media Library content changes. Methods called only from main thread.\n | |
| 7 //! Use library_callback_factory_t template to register. | |
| 8 class NOVTABLE library_callback : public service_base { | |
| 9 public: | |
| 10 //! Called when new items are added to the Media Library. | |
| 11 virtual void on_items_added(metadb_handle_list_cref items) = 0; | |
| 12 //! Called when some items have been removed from the Media Library. | |
| 13 virtual void on_items_removed(metadb_handle_list_cref items) = 0; | |
| 14 //! Called when some items in the Media Library have been modified. \n | |
| 15 //! The list is sorted by pointer value for convenient matching by binary search. | |
| 16 virtual void on_items_modified(metadb_handle_list_cref items) = 0; | |
| 17 | |
| 18 //! Is current on_items_modified() cycle called due to actual tags changed or dispaly hook operations? \n | |
| 19 //! Supported since foobar2000 v2.0 beta 13 | |
| 20 static bool is_modified_from_hook(); | |
| 21 | |
| 22 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(library_callback); | |
| 23 }; | |
| 24 | |
| 25 //! \since 2.0 | |
| 26 class NOVTABLE library_callback_v2 : public library_callback { | |
| 27 public: | |
| 28 virtual void on_items_modified_v2(metadb_handle_list_cref items, metadb_io_callback_v2_data& data) = 0; | |
| 29 virtual void on_library_initialized() = 0; | |
| 30 | |
| 31 FB2K_MAKE_SERVICE_INTERFACE(library_callback_v2, library_callback); | |
| 32 }; | |
| 33 | |
| 34 template<typename T> | |
| 35 class library_callback_factory_t : public service_factory_single_t<T> {}; | |
| 36 | |
| 37 class NOVTABLE library_callback_dynamic { | |
| 38 public: | |
| 39 //! Called when new items are added to the Media Library. | |
| 40 virtual void on_items_added(metadb_handle_list_cref items) = 0; | |
| 41 //! Called when some items have been removed from the Media Library. | |
| 42 virtual void on_items_removed(metadb_handle_list_cref items) = 0; | |
| 43 //! Called when some items in the Media Library have been modified. | |
| 44 //! The list is sorted by pointer value for convenient matching by binary search. | |
| 45 virtual void on_items_modified(metadb_handle_list_cref items) = 0; | |
| 46 | |
| 47 void register_callback(); void unregister_callback(); | |
| 48 }; | |
| 49 | |
| 50 //! Base class for library_callback_dynamic implementations, manages register/unregister calls for you | |
| 51 class library_callback_dynamic_impl_base : public library_callback_dynamic { | |
| 52 public: | |
| 53 library_callback_dynamic_impl_base() { register_callback(); } | |
| 54 ~library_callback_dynamic_impl_base() { unregister_callback(); } | |
| 55 | |
| 56 //stub implementations - avoid pure virtual function call issues | |
| 57 void on_items_added(metadb_handle_list_cref) override {} | |
| 58 void on_items_removed(metadb_handle_list_cref) override {} | |
| 59 void on_items_modified(metadb_handle_list_cref) override {} | |
| 60 | |
| 61 PFC_CLASS_NOT_COPYABLE_EX(library_callback_dynamic_impl_base); | |
| 62 }; | |
| 63 | |
| 64 //! \since 2.0 | |
| 65 class NOVTABLE library_callback_v2_dynamic { | |
| 66 public: | |
| 67 //! Called when new items are added to the Media Library. | |
| 68 virtual void on_items_added(metadb_handle_list_cref items) = 0; | |
| 69 //! Called when some items have been removed from the Media Library. | |
| 70 virtual void on_items_removed(metadb_handle_list_cref items) = 0; | |
| 71 //! Called when some items in the Media Library have been modified. | |
| 72 //! The list is sorted by pointer value for convenient matching by binary search. | |
| 73 virtual void on_items_modified_v2(metadb_handle_list_cref items, metadb_io_callback_v2_data & data) = 0; | |
| 74 | |
| 75 virtual void on_library_initialized() = 0; | |
| 76 | |
| 77 void register_callback(); void unregister_callback(); | |
| 78 }; | |
| 79 | |
| 80 //! \since 2.0 | |
| 81 //! //! Base class for library_callback_v2_dynamic implementations, manages register/unregister calls for you | |
| 82 class library_callback_v2_dynamic_impl_base : public library_callback_v2_dynamic { | |
| 83 public: | |
| 84 library_callback_v2_dynamic_impl_base() { register_callback(); } | |
| 85 ~library_callback_v2_dynamic_impl_base() { unregister_callback(); } | |
| 86 | |
| 87 //stub implementations - avoid pure virtual function call issues | |
| 88 void on_items_added(metadb_handle_list_cref) override {} | |
| 89 void on_items_removed(metadb_handle_list_cref) override {} | |
| 90 void on_items_modified_v2(metadb_handle_list_cref, metadb_io_callback_v2_data&) override {} | |
| 91 void on_library_initialized() override {} | |
| 92 | |
| 93 PFC_CLASS_NOT_COPYABLE_EX(library_callback_v2_dynamic_impl_base); | |
| 94 }; |
