Mercurial > foo_out_sdl
comparison foosdk/sdk/foobar2000/helpers/track_property_callback_impl.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 #include <functional> | |
| 4 #include <SDK/track_property.h> | |
| 5 | |
| 6 class groupname_comparator { | |
| 7 public: | |
| 8 static int compare(pfc::stringp p_name1,pfc::stringp p_name2) { | |
| 9 int temp = uStringCompare(p_name1,p_name2); | |
| 10 if (temp != 0) return temp; | |
| 11 return strcmp(p_name1,p_name2); | |
| 12 } | |
| 13 }; | |
| 14 | |
| 15 struct propertyname_container { | |
| 16 pfc::string m_name; | |
| 17 double m_priority; | |
| 18 }; | |
| 19 | |
| 20 class propertyname_comparator { | |
| 21 public: | |
| 22 static int compare(const propertyname_container & p_item1,const propertyname_container & p_item2) { | |
| 23 int state = pfc::compare_t(p_item1.m_priority,p_item2.m_priority); | |
| 24 if (state != 0) return state; | |
| 25 return uStringCompare(p_item1.m_name.ptr(),p_item2.m_name.ptr()); | |
| 26 } | |
| 27 }; | |
| 28 | |
| 29 typedef pfc::map_t<propertyname_container,pfc::string,propertyname_comparator> property_group; | |
| 30 | |
| 31 typedef pfc::map_t<pfc::string,property_group,groupname_comparator> t_property_group_list; | |
| 32 | |
| 33 class track_property_callback_impl : public track_property_callback_v2 { | |
| 34 public: | |
| 35 void set_property(const char * p_group,double p_sortpriority,const char * p_name,const char * p_value) override; | |
| 36 bool is_group_wanted(const char * p_group) override; | |
| 37 | |
| 38 void merge( track_property_callback_impl const & other ); | |
| 39 | |
| 40 t_property_group_list m_entries; | |
| 41 | |
| 42 bool m_cutMultiLine = false; | |
| 43 typedef std::function<bool ( const char * ) > groupFilter_t; | |
| 44 groupFilter_t m_groupFilter; | |
| 45 }; | |
| 46 | |
| 47 // Helper function to walk all track property providers in an optimized multithread manner | |
| 48 // Various *source arguments have been std::function'd so you can reference your own data structures gracefully | |
| 49 // If the function is aborted, it returns immediately - while actual worker threads may not yet have completed, and may still reference *source arguments. | |
| 50 // You must ensure - by means of std::shared_ptr<> or such - that all of the *source arguments remain accessible even after enumerateTrackProperties() returns, until the std::functions are released. | |
| 51 // Legacy track property providers that do not support off main thread operation will be invoked via main_thread_callback in main thread, and the function will stall until they have returned (unless aborted). | |
| 52 void enumerateTrackProperties(track_property_callback_impl & callback, std::function< metadb_handle_list_cref() > itemsSource, std::function<track_property_provider_v3_info_source*()> infoSource, std::function<abort_callback& () > abortSource); | |
| 53 void enumerateTrackProperties_v5(track_property_callback_impl& callback, std::function< metadb_handle_list_cref() > itemsSource, std::function<track_property_provider_v5_info_source* ()> infoSource, std::function<abort_callback& () > abortSource); |
