|
1
|
1 #pragma once
|
|
|
2
|
|
|
3 //! \since 0.9.5
|
|
|
4 //! Instance of a search filter object. \n
|
|
|
5 //! This object contains a preprocessed search query; used to perform filtering similar to Media Library Search or Album List's "filter" box. \n
|
|
|
6 //! Use search_filter_manager API to instantiate search_filter objects.
|
|
|
7 class search_filter : public service_base {
|
|
|
8 public:
|
|
|
9 protected:
|
|
|
10 //! For backwards compatibility with older (0.9.5 alpha) revisions of this API. Do not call.
|
|
|
11 virtual bool test_locked(const metadb_handle_ptr & p_item,const file_info * p_info) = 0;
|
|
|
12 public:
|
|
|
13
|
|
|
14 //! Use this to run this filter on a group of items.
|
|
|
15 //! @param data Items to test.
|
|
|
16 //! @param out Pointer to a buffer (size at least equal to number of items in the source list) receiving the results.
|
|
|
17 virtual void test_multi(metadb_handle_list_cref data, bool * out) = 0;
|
|
|
18
|
|
|
19 FB2K_MAKE_SERVICE_INTERFACE(search_filter,service_base);
|
|
|
20 };
|
|
|
21
|
|
|
22 //! \since 0.9.5.3
|
|
|
23 class search_filter_v2 : public search_filter {
|
|
|
24 public:
|
|
|
25 virtual bool get_sort_pattern(titleformat_object::ptr & out, int & direction) = 0;
|
|
|
26
|
|
|
27 //! Abortable version of test_multi(). If the abort_callback object becomes signaled while the operation is being performed, contents of the output buffer are undefined and the operation will fail with exception_aborted.
|
|
|
28 virtual void test_multi_ex(metadb_handle_list_cref data, bool * out, abort_callback & abort) = 0;
|
|
|
29
|
|
|
30 //! Helper; removes non-matching items from the list.
|
|
|
31 void test_multi_here(metadb_handle_list & ref, abort_callback & abort);
|
|
|
32
|
|
|
33 FB2K_MAKE_SERVICE_INTERFACE(search_filter_v2, search_filter)
|
|
|
34 };
|
|
|
35
|
|
|
36 //! \since 0.9.5.4
|
|
|
37 class search_filter_v3 : public search_filter_v2 {
|
|
|
38 public:
|
|
|
39 //! Returns whether the sort pattern returned by get_sort_pattern() was set by the user explicitly using "SORT BY" syntax or whether it was determined implicitly from some other part of the query. It's recommended to use this to determine whether to create a force-sorted autoplaylist or not.
|
|
|
40 virtual bool is_sort_explicit() = 0;
|
|
|
41
|
|
|
42 FB2K_MAKE_SERVICE_INTERFACE(search_filter_v3, search_filter_v2)
|
|
|
43 };
|
|
|
44
|
|
|
45 //! \since 2.0
|
|
|
46 class search_filter_v4 : public search_filter_v3 {
|
|
|
47 public:
|
|
|
48 enum {
|
|
|
49 flag_sort = 1 << 0,
|
|
|
50 };
|
|
|
51 virtual void test_v4(metadb_handle_list_cref items, metadb_io_callback_v2_data* dataIfAvail, bool* out, abort_callback& abort) = 0;
|
|
|
52
|
|
|
53 virtual fb2k::arrayRef /* of metadb_handle */ search_v4(metadb_handle_list_cref lst, uint32_t flags, metadb_io_callback_v2_data * dataIfAvail, abort_callback& a) = 0;
|
|
|
54
|
|
|
55 FB2K_MAKE_SERVICE_INTERFACE(search_filter_v4, search_filter_v3);
|
|
|
56 };
|
|
|
57
|
|
|
58 //! \since 0.9.5
|
|
|
59 //! Entrypoint class to instantiate search_filter objects.
|
|
|
60 class search_filter_manager : public service_base {
|
|
|
61 public:
|
|
|
62 //! Creates a search_filter object. Throws an exception on failure (such as an error in the query). It's recommended that you relay the exception message to the user if this function fails.
|
|
|
63 virtual search_filter::ptr create(const char * p_query) = 0;
|
|
|
64
|
|
|
65 //! OBSOLETE, DO NOT CALL
|
|
|
66 virtual void get_manual(pfc::string_base & p_out) = 0;
|
|
|
67
|
|
|
68 FB2K_MAKE_SERVICE_COREAPI(search_filter_manager);
|
|
|
69 };
|
|
|
70
|
|
|
71 //! \since 0.9.5.3.
|
|
|
72 class search_filter_manager_v2 : public search_filter_manager {
|
|
|
73 public:
|
|
|
74 enum {
|
|
|
75 KFlagAllowSort = 1 << 0,
|
|
|
76 KFlagSuppressNotify = 1 << 1,
|
|
|
77 };
|
|
|
78 //! Creates a search_filter object. Throws an exception on failure (such as an error in the query). It's recommended that you relay the exception message to the user if this function fails.
|
|
|
79 //! @param changeNotify A completion_notify callback object that will get called each time the query's behavior changes as a result of some external event (such as system time change). The caller must refresh query results each time this callback is triggered. The status parameter of its on_completion() parameter is unused and always set to zero.
|
|
|
80 virtual search_filter_v2::ptr create_ex(const char * query, completion_notify::ptr changeNotify, t_uint32 flags) = 0;
|
|
|
81
|
|
|
82 //! Opens the search query syntax reference document, typically an external HTML in user's default web browser.
|
|
|
83 virtual void show_manual() = 0;
|
|
|
84
|
|
|
85 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(search_filter_manager_v2, search_filter_manager);
|
|
|
86 };
|
|
|
87
|
|
|
88 //! \since 2.0
|
|
|
89 class search_filter_manager_v3 : public search_filter_manager_v2 {
|
|
|
90 FB2K_MAKE_SERVICE_COREAPI_EXTENSION(search_filter_manager_v3, search_filter_manager_v2);
|
|
|
91 public:
|
|
|
92 enum combine_t {
|
|
|
93 combine_and,
|
|
|
94 combine_or
|
|
|
95 };
|
|
|
96 //! Combine multiple search filters into one, using the specified logical operation. \n
|
|
|
97 //! This method INVALIDATES passed objects. Do not try to use them afterwards.
|
|
|
98 virtual search_filter_v4::ptr combine(pfc::list_base_const_t<search_filter::ptr> const & arg, combine_t how, completion_notify::ptr changeNotify, t_uint32 flags) = 0;
|
|
|
99 };
|
|
|
100
|
|
|
101 //! \since 2.0
|
|
|
102 class search_index : public service_base {
|
|
|
103 FB2K_MAKE_SERVICE_INTERFACE(search_index, service_base)
|
|
|
104 public:
|
|
|
105 enum {
|
|
|
106 flag_sort = 1 << 0,
|
|
|
107 };
|
|
|
108
|
|
|
109 //! Searches Tracks in this index for tracks matching criteria.
|
|
|
110 //! @returns list of metadb_handles. Safe to use arr->as_list_of<metadb_handle>() to get a pfc::list_base_const_t<metadb_handle_ptr>
|
|
|
111 //! @param subset Optional: pass subset of tracks in this index to search - whole index is searched if nullptr is passed.
|
|
|
112 //! @param flags Optional: set flag_sort to sort output
|
|
|
113 //! Thread safety: call from any thread.
|
|
|
114 virtual fb2k::arrayRef search(search_filter::ptr pattern, metadb_handle_list_cptr subset, uint32_t flags, abort_callback& abort) = 0;
|
|
|
115 //! Performs hit test on a group of tracks that are a subset of tracks in this index. \n
|
|
|
116 //! Thread safety: call from any thread.
|
|
|
117 virtual void test(search_filter::ptr pattern, metadb_handle_list_cref items, bool* out, abort_callback& abort) = 0;
|
|
|
118
|
|
|
119 //! Add tracks to a custom index. \n
|
|
|
120 //! Illegal to call on library or playlist indexes. \n
|
|
|
121 //! Thread safety: call from any thread.
|
|
|
122 virtual void add_tracks(metadb_handle_list_cref, metadb_io_callback_v2_data* dataIfAvail) = 0;
|
|
|
123 //! Remove tracks from a custom index. \n
|
|
|
124 //! Illegal to call on library or playlist indexes. \n
|
|
|
125 //! Thread safety: call from any thread.
|
|
|
126 virtual void remove_tracks(metadb_handle_list_cref) = 0;
|
|
|
127 };
|
|
|
128
|
|
|
129 //! \since 2.0
|
|
|
130 class search_index_manager : public service_base {
|
|
|
131 FB2K_MAKE_SERVICE_COREAPI(search_index_manager);
|
|
|
132 public:
|
|
|
133 //! Create a custom index on any data set. \n
|
|
|
134 //! OK to call from any thread.
|
|
|
135 virtual search_index::ptr create_index(metadb_handle_list_cref items, metadb_io_callback_v2_data* dataIfAvail) = 0;
|
|
|
136
|
|
|
137 //! Create a search index referencing a playlist. \n
|
|
|
138 //! Specify null GUID to follow active playlist (typical playlist search). \n
|
|
|
139 //! Call from main thread to obtain index, then can use obtained object from any thread.
|
|
|
140 virtual search_index::ptr create_playlist_index(const GUID& playlistID = pfc::guid_null) = 0;
|
|
|
141
|
|
|
142 //! Returns a shared object indexing user's media library. \n
|
|
|
143 //! Call from main thread to obtain index, then can use obtained object from any thread.
|
|
|
144 virtual search_index::ptr get_library_index() = 0;
|
|
|
145 }; |