foobar2000 SDK  2015-08-03
metadb.h
Go to the documentation of this file.
1 class NOVTABLE metadb_io : public service_base
6 {
7 public:
11  load_info_check_if_changed
12  };
13 
18  };
19 
24  };
25 
27  __declspec(deprecated) virtual bool is_busy() = 0;
29  __declspec(deprecated) virtual bool is_updating_disabled() = 0;
31  __declspec(deprecated) virtual bool is_file_updating_blocked() = 0;
33  __declspec(deprecated) virtual void highlight_running_process() = 0;
35  __declspec(deprecated) virtual t_load_info_state load_info_multi(metadb_handle_list_cref p_list,t_load_info_type p_type,HWND p_parent_window,bool p_show_errors) = 0;
37  __declspec(deprecated) virtual t_update_info_state update_info_multi(metadb_handle_list_cref p_list,const pfc::list_base_const_t<file_info*> & p_new_info,HWND p_parent_window,bool p_show_errors) = 0;
39  __declspec(deprecated) virtual t_update_info_state rewrite_info_multi(metadb_handle_list_cref p_list,HWND p_parent_window,bool p_show_errors) = 0;
41  __declspec(deprecated) virtual t_update_info_state remove_info_multi(metadb_handle_list_cref p_list,HWND p_parent_window,bool p_show_errors) = 0;
42 
43  virtual void hint_multi(metadb_handle_list_cref p_list,const pfc::list_base_const_t<const file_info*> & p_infos,const pfc::list_base_const_t<t_filestats> & p_stats,const bit_array & p_fresh_mask) = 0;
44 
45  virtual void hint_multi_async(metadb_handle_list_cref p_list,const pfc::list_base_const_t<const file_info*> & p_infos,const pfc::list_base_const_t<t_filestats> & p_stats,const bit_array & p_fresh_mask) = 0;
46 
47  virtual void hint_reader(service_ptr_t<class input_info_reader> p_reader,const char * p_path,abort_callback & p_abort) = 0;
48 
50  virtual void path_to_handles_simple(const char * p_path, metadb_handle_list_ref p_out) = 0;
51 
53  virtual void dispatch_refresh(metadb_handle_list_cref p_list) = 0;
54 
55  void dispatch_refresh(metadb_handle_ptr const & handle) {dispatch_refresh(pfc::list_single_ref_t<metadb_handle_ptr>(handle));}
56 
57  void hint_async(metadb_handle_ptr p_item,const file_info & p_info,const t_filestats & p_stats,bool p_fresh);
58 
59  __declspec(deprecated) t_load_info_state load_info(metadb_handle_ptr p_item,t_load_info_type p_type,HWND p_parent_window,bool p_show_errors);
60  __declspec(deprecated) t_update_info_state update_info(metadb_handle_ptr p_item,file_info & p_info,HWND p_parent_window,bool p_show_errors);
61 
62  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(metadb_io);
63 };
64 
66 class NOVTABLE file_info_filter : public service_base {
67 public:
71  virtual bool apply_filter(metadb_handle_ptr p_location,t_filestats p_stats,file_info & p_info) = 0;
72 
73  FB2K_MAKE_SERVICE_INTERFACE(file_info_filter,service_base);
74 };
75 
77 class NOVTABLE metadb_hint_list : public service_base {
78  FB2K_MAKE_SERVICE_INTERFACE(metadb_hint_list,service_base);
79 public:
85  virtual void add_hint(metadb_handle_ptr const & p_location,const file_info & p_info,const t_filestats & p_stats,bool p_freshflag) = 0;
87  virtual void add_hint_reader(const char * p_path,service_ptr_t<input_info_reader> const & p_reader,abort_callback & p_abort) = 0;
89  virtual void on_done() = 0;
90 };
91 
93 class NOVTABLE metadb_hint_list_v2 : public metadb_hint_list {
95 public:
96  virtual void add_hint_browse(metadb_handle_ptr const & p_location,const file_info & p_info, t_filetimestamp browseTS) = 0;
97 };
98 
100 class NOVTABLE metadb_hint_list_v3 : public metadb_hint_list_v2 {
102 public:
103  virtual void add_hint_v3(metadb_handle_ptr const & p_location, metadb_info_container::ptr info,bool p_freshflag) = 0;
104  virtual void add_hint_browse_v3(metadb_handle_ptr const & p_location,metadb_info_container::ptr info) = 0;
105 
106  virtual void add_hint_forced(metadb_handle_ptr const & p_location, const file_info & p_info,const t_filestats & p_stats,bool p_freshflag) = 0;
107  virtual void add_hint_forced_v3(metadb_handle_ptr const & p_location, metadb_info_container::ptr info,bool p_freshflag) = 0;
108  virtual void add_hint_forced_reader(const char * p_path,service_ptr_t<input_info_reader> const & p_reader,abort_callback & p_abort) = 0;
109 };
110 
111 
113 class NOVTABLE metadb_io_v2 : public metadb_io {
114 public:
115  enum {
118  op_flag_no_errors = 1 << 0,
120  op_flag_background = 1 << 1,
122  op_flag_delay_ui = 1 << 2,
123 
127  op_flag_partial_info_aware = 1 << 3,
128  };
129 
134  virtual void load_info_async(metadb_handle_list_cref p_list,t_load_info_type p_type,HWND p_parent_window,t_uint32 p_op_flags,completion_notify_ptr p_notify) = 0;
140  virtual void update_info_async(metadb_handle_list_cref p_list,service_ptr_t<file_info_filter> p_filter,HWND p_parent_window,t_uint32 p_op_flags,completion_notify_ptr p_notify) = 0;
145  virtual void rewrite_info_async(metadb_handle_list_cref p_list,HWND p_parent_window,t_uint32 p_op_flags,completion_notify_ptr p_notify) = 0;
150  virtual void remove_info_async(metadb_handle_list_cref p_list,HWND p_parent_window,t_uint32 p_op_flags,completion_notify_ptr p_notify) = 0;
151 
153  virtual metadb_hint_list::ptr create_hint_list() = 0;
154 
160  void update_info_async_simple(metadb_handle_list_cref p_list,const pfc::list_base_const_t<const file_info*> & p_new_info, HWND p_parent_window,t_uint32 p_op_flags,completion_notify_ptr p_notify);
161 
162  FB2K_MAKE_SERVICE_INTERFACE(metadb_io_v2,metadb_io);
163 };
164 
165 
168 public:
169  virtual void on_changed_sorted(metadb_handle_list_cref p_items_sorted, bool p_fromhook) = 0;
170 };
171 
173 class NOVTABLE metadb_io_v3 : public metadb_io_v2 {
174 public:
175  virtual void register_callback(metadb_io_callback_dynamic * p_callback) = 0;
176  virtual void unregister_callback(metadb_io_callback_dynamic * p_callback) = 0;
177 
179 };
180 
183 public:
184  void on_changed_sorted(metadb_handle_list_cref p_items_sorted, bool p_fromhook) {}
185 
188 
189  PFC_CLASS_NOT_COPYABLE_EX(metadb_io_callback_dynamic_impl_base)
190 };
192 class NOVTABLE metadb_io_callback : public service_base {
193 public:
197  virtual void on_changed_sorted(metadb_handle_list_cref p_items_sorted, bool p_fromhook) = 0;
198 
199  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(metadb_io_callback);
200 };
201 
205 class NOVTABLE metadb_io_edit_callback : public service_base {
206  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(metadb_io_edit_callback)
207 public:
209  typedef const pfc::list_base_const_t<const file_info*> & t_infosref;
210  virtual void on_edited(metadb_handle_list_cref items, t_infosref before, t_infosref after) = 0;
211 };
212 
216 class NOVTABLE metadb : public service_base
217 {
218 protected:
220  virtual void database_lock()=0;
222  virtual void database_unlock()=0;
223 public:
224 
230  virtual void handle_create(metadb_handle_ptr & p_out,const playable_location & p_location)=0;
231 
232  void handle_create_replace_path_canonical(metadb_handle_ptr & p_out,const metadb_handle_ptr & p_source,const char * p_new_path);
233  void handle_replace_path_canonical(metadb_handle_ptr & p_out,const char * p_new_path);
234  void handle_create_replace_path(metadb_handle_ptr & p_out,const metadb_handle_ptr & p_source,const char * p_new_path);
235 
238  static bool g_get_random_handle(metadb_handle_ptr & p_out);
239 
240  enum {case_sensitive = true};
242 
243  inline static int path_compare_ex(const char * p1,t_size len1,const char * p2,t_size len2) {return case_sensitive ? pfc::strcmp_ex(p1,len1,p2,len2) : stricmp_utf8_ex(p1,len1,p2,len2);}
244  inline static int path_compare_nc(const char * p1, size_t len1, const char * p2, size_t len2) {return case_sensitive ? pfc::strcmp_nc(p1,len1,p2,len2) : stricmp_utf8_ex(p1,len1,p2,len2);}
245  inline static int path_compare(const char * p1,const char * p2) {return case_sensitive ? strcmp(p1,p2) : stricmp_utf8(p1,p2);}
246  inline static int path_compare_metadb_handle(const metadb_handle_ptr & p1,const metadb_handle_ptr & p2) {return path_compare(p1->get_path(),p2->get_path());}
247 
249  metadb_handle_ptr handle_create(const char * path, uint32_t subsong) {return handle_create(make_playable_location(path, subsong));}
250 
251  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(metadb);
252 };
253 
256 
257 
273 public:
275  virtual t_uint32 get_field_count() = 0;
277  virtual void get_field_name(t_uint32 index, pfc::string_base & out) = 0;
283  virtual bool process_field(t_uint32 index, metadb_handle * handle, titleformat_text_out * out) = 0;
284 
285  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(metadb_display_field_provider);
286 };
287 
288 
289 
290 
291 
294 public:
296  FB2K_DYNAMIC_ASSERT(p_list.get_count() == p_new_info.get_count());
297  pfc::array_t<t_size> order;
298  order.set_size(p_list.get_count());
299  order_helper::g_fill(order.get_ptr(),order.get_size());
300  p_list.sort_get_permutation_t(pfc::compare_t<metadb_handle_ptr,metadb_handle_ptr>,order.get_ptr());
301  m_handles.set_count(order.get_size());
302  m_infos.set_size(order.get_size());
303  for(t_size n = 0; n < order.get_size(); n++) {
304  m_handles[n] = p_list[order[n]];
305  m_infos[n] = *p_new_info[order[n]];
306  }
307  }
308 
309  bool apply_filter(metadb_handle_ptr p_location,t_filestats p_stats,file_info & p_info) {
310  t_size index;
311  if (m_handles.bsearch_t(pfc::compare_t<metadb_handle_ptr,metadb_handle_ptr>,p_location,index)) {
312  p_info = m_infos[index];
313  return true;
314  } else {
315  return false;
316  }
317  }
318 private:
321 };
322 
323 
325 // typedef hasher_md5_result metadb_index_hash;
327 
328 
330 class NOVTABLE metadb_index_client : public service_base {
331  FB2K_MAKE_SERVICE_INTERFACE(metadb_index_client, service_base)
332 public:
333  virtual metadb_index_hash transform(const file_info & info, const playable_location & location) = 0;
334 
335  bool hashHandle(metadb_handle_ptr const & h, metadb_index_hash & out) {
336  metadb_info_container::ptr info;
337  if (!h->get_info_ref(info)) return false;
338  out = transform(info->info(), h->get_location());
339  return true;
340  }
341 
342  static metadb_index_hash from_md5(hasher_md5_result const & in) {return in.xorHalve();}
343 };
344 
346 class NOVTABLE metadb_index_manager : public service_base {
347  FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(metadb_index_manager)
348 public:
349  virtual void add(metadb_index_client::ptr client, const GUID & index_id, t_filetimestamp userDataRetentionPeriod) = 0;
350  virtual void remove(const GUID & index_id) = 0;
351  virtual void set_user_data(const GUID & index_id, const metadb_index_hash & hash, const void * data, t_size dataSize) = 0;
352  virtual void get_user_data(const GUID & index_id, const metadb_index_hash & hash, mem_block_container & out) = 0;
353 
354 
355  template<typename t_array> void get_user_data_t(const GUID & index_id, const metadb_index_hash & hash, t_array & out) {
357  get_user_data(index_id, hash, ref);
358  }
359 
360  t_size get_user_data_here(const GUID & index_id, const metadb_index_hash & hash, void * out, t_size outSize) {
361  mem_block_container_temp_impl ref(out, outSize);
362  get_user_data(index_id, hash, ref);
363  return ref.get_size();
364  }
365 
366  virtual void dispatch_refresh(const GUID & index_id, const pfc::list_base_const_t<metadb_index_hash> & hashes) = 0;
367 
368  void dispatch_refresh(const GUID & index_id, const metadb_index_hash & hash) {
370  dispatch_refresh(index_id, l);
371  }
372 
373  virtual void dispatch_global_refresh() = 0;
374 
377  virtual void get_ML_handles(const GUID & index_id, const metadb_index_hash & hash, metadb_handle_list_ref out) = 0;
378 
380  virtual void get_all_hashes(const GUID & index_id, pfc::list_base_t<metadb_index_hash> & out) = 0;
381 
384  virtual bool have_orphaned_data(const GUID & index_id) = 0;
385 
388  virtual void erase_orphaned_data(const GUID & index_id) = 0;
389 
392  virtual void save_index_data(const GUID & index_id) = 0;
393 };
metadb_handle_ptr handle_create(playable_location const &l)
Definition: metadb.h:248
int SHARED_EXPORT stricmp_utf8_ex(const char *p1, t_size len1, const char *p2, t_size len2)
Dynamically-registered version of metadb_io_callback. See metadb_io_callback for documentation, register instances using metadb_io_v3::register_callback(). It&#39;s recommended that you use the metadb_io_callback_dynamic_impl_base helper class to manage registration/unregistration.
Definition: metadb.h:167
metadb_handle_ptr handle_create(const char *path, uint32_t subsong)
Definition: metadb.h:249
Definition: pfc.h:71
static void g_fill(t_int *p_order, const t_size p_count)
Definition: order_helper.h:38
uint64_t t_uint64
Definition: int_types.h:3
void on_changed_sorted(metadb_handle_list_cref p_items_sorted, bool p_fromhook)
Definition: metadb.h:184
API for tag read/write operations. Legal to call from main thread only, except for hint_multi_async()...
Definition: metadb.h:5
void info(const char *p_message)
Definition: console.cpp:4
FB2K_MAKE_SERVICE_INTERFACE(metadb_hint_list, service_base)
Bit array interface class, constant version (you can only retrieve values). Range of valid indexes d...
Definition: bit_array.h:6
New (0.9.5)
Definition: metadb.h:173
FB2K_MAKE_SERVICE_INTERFACE(metadb_hint_list_v2, metadb_hint_list)
t_update_info_state
Definition: metadb.h:14
t_uint64 metadb_index_hash
Definition: metadb.h:326
void dispatch_refresh(const GUID &index_id, const metadb_index_hash &hash)
Definition: metadb.h:368
int SHARED_EXPORT stricmp_utf8(const char *p1, const char *p2)
__declspec(dllexport) foobar2000_client *_cdecl foobar2000_get_interface(foobar2000_api *p_api
A metadb_handle object represents interface to reference-counted file_info cache entry for the specif...
Definition: metadb_handle.h:19
Class providing interface for retrieval of information (metadata, duration, replaygain, other tech infos) from files. Also see: file_info. Instantiating: see input_entry. Implementing: see input_impl.
Definition: input.h:18
void dispatch_refresh(metadb_handle_ptr const &handle)
Definition: metadb.h:55
t_size get_user_data_here(const GUID &index_id, const metadb_index_hash &hash, void *out, t_size outSize)
Definition: metadb.h:360
int strcmp_ex(const char *p1, t_size n1, const char *p2, t_size n2)
Main interface class for information about some playable object.
Definition: file_info.h:73
t_uint64 xorHalve() const
Definition: hasher_md5.cpp:24
metadb_io_callback_dynamic implementation helper.
Definition: metadb.h:182
size_t t_size
Definition: int_types.h:48
void set_size(t_size p_size)
Definition: array.h:104
virtual t_size get_count() const =0
Implementing this class gives you direct control over which part of file_info gets altered during a t...
Definition: metadb.h:66
int strcmp_nc(const char *p1, size_t n1, const char *p2, size_t n2)
Advanced interface for passing infos read from files to metadb backend. Use metadb_io_v2::create_hint...
Definition: metadb.h:77
pfc::comparator_strcmp path_comparator
Definition: metadb.h:241
Base class for all service classes. Provides interfaces for reference counter and querying for differ...
Definition: service.h:333
pfc::array_t< file_info_impl > m_infos
Definition: metadb.h:320
static int path_compare(const char *p1, const char *p2)
Definition: metadb.h:245
file_info_filter_impl(const pfc::list_base_const_t< metadb_handle_ptr > &p_list, const pfc::list_base_const_t< const file_info * > &p_new_info)
Definition: metadb.h:295
t_load_info_state
Definition: metadb.h:20
Callback service receiving notifications about metadb contents changes.
Definition: metadb.h:192
t_uint64 t_filetimestamp
Type used for file timestamp related variables. 64-bit value representing the number of 100-nanosecon...
Definition: filesystem.h:12
static metadb_index_hash from_md5(hasher_md5_result const &in)
Definition: metadb.h:342
void get_user_data_t(const GUID &index_id, const metadb_index_hash &hash, t_array &out)
Definition: metadb.h:355
New in 0.9.3. Extends metadb_io functionality with nonblocking versions of tag read/write functions...
Definition: metadb.h:113
Entrypoint service for metadb_handle related operations. Implemented only by core, do not reimplement. Use static_api_ptr_t template to access it, e.g. static_api_ptr_t<metadb>()->handle_create(myhandle,mylocation);.
Definition: metadb.h:216
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
static int path_compare_nc(const char *p1, size_t len1, const char *p2, size_t len2)
Definition: metadb.h:244
void sort_get_permutation_t(t_compare p_compare, t_permutation const &p_permutation) const
Definition: list.h:55
FB2K_MAKE_SERVICE_INTERFACE(metadb_index_client, service_base) public bool hashHandle(metadb_handle_ptr const &h, metadb_index_hash &out)
Definition: metadb.h:335
Generic interface for a memory block; used by various other interfaces to return memory blocks while ...
bool apply_filter(metadb_handle_ptr p_location, t_filestats p_stats, file_info &p_info)
Alters specified file_info entry; called as a part of tag update process. Specified file_info has bee...
Definition: metadb.h:309
Helper template used to easily access core services. Usage: static_api_ptr_t<myclass> api; api->doso...
Definition: service.h:533
metadb_handle_list m_handles
Definition: metadb.h:319
static int path_compare_metadb_handle(const metadb_handle_ptr &p1, const metadb_handle_ptr &p2)
Definition: metadb.h:246
FB2K_MAKE_SERVICE_INTERFACE(metadb_io_v2, metadb_io)
Helper implementation of file_info_filter_impl.
Definition: metadb.h:293
uint32_t t_uint32
Definition: int_types.h:5
t_load_info_type
Definition: metadb.h:8
static int path_compare_ex(const char *p1, t_size len1, const char *p2, t_size len2)
Definition: metadb.h:243