Mercurial > foo_out_sdl
comparison foosdk/sdk/foobar2000/SDK/metadb_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 "callback_merit.h" | |
| 3 | |
| 4 //! Callback service receiving notifications about metadb contents changes. | |
| 5 class NOVTABLE metadb_io_callback : public service_base { | |
| 6 public: | |
| 7 //! Called when metadb contents change. (Or, one of display hook component requests display update). \n | |
| 8 //! Main thread only. | |
| 9 //! @param p_items_sorted List of items that have been updated. The list is always sorted by pointer value, to allow fast bsearch to test whether specific item has changed. | |
| 10 //! @param p_fromhook Set to true when actual file contents haven't changed but one of metadb_display_field_provider implementations requested an update so output of metadb_handle::format_title() etc has changed. | |
| 11 virtual void on_changed_sorted(metadb_handle_list_cref p_items_sorted, bool p_fromhook) = 0; | |
| 12 | |
| 13 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(metadb_io_callback); | |
| 14 }; | |
| 15 | |
| 16 //! Dynamically-registered version of metadb_io_callback. See metadb_io_callback for documentation, register instances using metadb_io_v3::register_callback(). It's recommended that you use the metadb_io_callback_dynamic_impl_base helper class to manage registration/unregistration. | |
| 17 class NOVTABLE metadb_io_callback_dynamic { | |
| 18 public: | |
| 19 //! See metadb_io_callback::on_changed_sorted() | |
| 20 virtual void on_changed_sorted(metadb_handle_list_cref p_items_sorted, bool p_fromhook) = 0; | |
| 21 | |
| 22 void register_callback(); void unregister_callback(); | |
| 23 | |
| 24 }; | |
| 25 | |
| 26 //! metadb_io_callback_dynamic implementation helper. | |
| 27 class metadb_io_callback_dynamic_impl_base : public metadb_io_callback_dynamic { | |
| 28 public: | |
| 29 void on_changed_sorted(metadb_handle_list_cref p_items_sorted, bool p_fromhook) override { (void)p_items_sorted; (void)p_fromhook; } | |
| 30 | |
| 31 metadb_io_callback_dynamic_impl_base(); | |
| 32 ~metadb_io_callback_dynamic_impl_base(); | |
| 33 | |
| 34 PFC_CLASS_NOT_COPYABLE_EX(metadb_io_callback_dynamic_impl_base) | |
| 35 }; | |
| 36 | |
| 37 //! \since 1.1 | |
| 38 //! Callback service receiving notifications about user-triggered tag edits. \n | |
| 39 //! You want to use metadb_io_callback instead most of the time, unless you specifically want to track tag edits for purposes other than updating user interface. | |
| 40 class NOVTABLE metadb_io_edit_callback : public service_base { | |
| 41 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(metadb_io_edit_callback) | |
| 42 public: | |
| 43 //! Called after the user has edited tags on a set of files. | |
| 44 typedef const pfc::list_base_const_t<const file_info*>& t_infosref; | |
| 45 virtual void on_edited(metadb_handle_list_cref items, t_infosref before, t_infosref after) = 0; | |
| 46 }; | |
| 47 | |
| 48 //! \since 2.0 | |
| 49 class NOVTABLE metadb_io_edit_callback_v2 : public metadb_io_edit_callback { | |
| 50 FB2K_MAKE_SERVICE_INTERFACE(metadb_io_edit_callback_v2, metadb_io_edit_callback) | |
| 51 public: | |
| 52 //! With original on_edited(), the implementation could not tell what the info in metadb was before, 'before' parameter being actual infos freshly read from the file prior to writing. \n | |
| 53 //! on_edited_v2() clarifies this, additional argument passes old metadb state to deal with cases where it was different than file contents. | |
| 54 virtual void on_edited_v2(metadb_handle_list_cref items, t_infosref before, t_infosref after, t_infosref beforeInMetadb) = 0; | |
| 55 }; | |
| 56 | |
| 57 //! \since 2.0 | |
| 58 //! Parameter for on_changed_sorted_v2() | |
| 59 class NOVTABLE metadb_io_callback_v2_data { | |
| 60 public: | |
| 61 virtual metadb_v2_rec_t get(size_t idxInList) = 0; | |
| 62 metadb_v2_rec_t operator[](size_t i) { return get(i); } | |
| 63 }; | |
| 64 | |
| 65 //! \since 2.0 | |
| 66 //! Extended version of metadb_io_callback. | |
| 67 class NOVTABLE metadb_io_callback_v2 : public metadb_io_callback { | |
| 68 FB2K_MAKE_SERVICE_INTERFACE(metadb_io_callback_v2, metadb_io_callback); | |
| 69 public: | |
| 70 virtual void on_changed_sorted_v2(metadb_handle_list_cref itemsSorted, metadb_io_callback_v2_data & data, bool bFromHook) = 0; | |
| 71 //! Controls callback merit, see: fb2k::callback_merit_t | |
| 72 virtual fb2k::callback_merit_t get_callback_merit() { return fb2k::callback_merit_default; } | |
| 73 }; | |
| 74 | |
| 75 //! \since 2.0 | |
| 76 //! NEW interface introduced in late 2.0. \n | |
| 77 //! Invoked *BEFORE* actual update, with incoming info. \n | |
| 78 //! Note that incoming info may be partial (either main info or browse info not set), in such cases the info will remain unchanged. | |
| 79 class NOVTABLE metadb_pre_update_callback : public service_base { | |
| 80 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT( metadb_pre_update_callback ); | |
| 81 public: | |
| 82 virtual void will_update( metadb_handle_list_cref itemsSorted, metadb_io_callback_v2_data & data) = 0; | |
| 83 }; | |
| 84 | |
| 85 //! \since 2.0 | |
| 86 //! Extended version of metadb_io_callback_dynamic. | |
| 87 class NOVTABLE metadb_io_callback_v2_dynamic { | |
| 88 public: | |
| 89 virtual void on_changed_sorted_v2(metadb_handle_list_cref itemsSorted, metadb_io_callback_v2_data & data, bool bFromHook) = 0; | |
| 90 //! Controls callback merit, see: fb2k::callback_merit_t | |
| 91 virtual fb2k::callback_merit_t get_callback_merit() { return fb2k::callback_merit_default; } | |
| 92 | |
| 93 bool try_register_callback(); void try_unregister_callback(); | |
| 94 void register_callback(); void unregister_callback(); | |
| 95 }; | |
| 96 | |
| 97 class metadb_io_callback_v2_dynamic_impl_base : public metadb_io_callback_v2_dynamic { | |
| 98 public: | |
| 99 void on_changed_sorted_v2(metadb_handle_list_cref itemsSorted, metadb_io_callback_v2_data& data, bool bFromHook) override { (void)itemsSorted; (void)data; (void)bFromHook; } | |
| 100 | |
| 101 metadb_io_callback_v2_dynamic_impl_base(); | |
| 102 ~metadb_io_callback_v2_dynamic_impl_base(); | |
| 103 | |
| 104 PFC_CLASS_NOT_COPYABLE_EX(metadb_io_callback_v2_dynamic_impl_base) | |
| 105 }; |
