foobar2000 SDK  2015-08-03
Public Types | Public Member Functions | Static Public Member Functions
file_operation_callbackabstract

#include <file_operation_callback.h>

+ Inheritance diagram for file_operation_callback:

Public Types

typedef const pfc::list_base_const_t< const char * > & t_pathlist
 
- Public Types inherited from service_base
typedef service_base t_interface
 

Public Member Functions

 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT (file_operation_callback)
 
virtual void on_files_copied_sorted (t_pathlist p_from, t_pathlist p_to)=0
 
virtual void on_files_deleted_sorted (t_pathlist p_items)=0
 
virtual void on_files_moved_sorted (t_pathlist p_from, t_pathlist p_to)=0
 
- Public Member Functions inherited from service_base
template<typename outPtr_t >
bool cast (outPtr_t &outPtr)
 
virtual int service_add_ref ()=0 throw ()
 
virtual bool service_query (service_ptr_t< service_base > &p_out, const GUID &p_guid)
 
template<class T >
bool service_query_t (service_ptr_t< T > &p_out)
 
virtual int service_release ()=0 throw ()
 

Static Public Member Functions

static bool g_mark_dead_entries (metadb_handle_list_cref items, bit_array_var &mask, t_pathlist deadPaths)
 
static void g_on_files_copied (const pfc::list_base_const_t< const char * > &p_from, const pfc::list_base_const_t< const char * > &p_to)
 
static void g_on_files_deleted (const pfc::list_base_const_t< const char * > &p_items)
 
static void g_on_files_moved (const pfc::list_base_const_t< const char * > &p_from, const pfc::list_base_const_t< const char * > &p_to)
 
static bool g_search_sorted_list (const pfc::list_base_const_t< const char * > &p_list, const char *p_string, t_size &p_index)
 
static bool g_update_list_on_moved (metadb_handle_list_ref p_list, t_pathlist p_from, t_pathlist p_to)
 
static bool g_update_list_on_moved_ex (metadb_handle_list_ref p_list, t_pathlist p_from, t_pathlist p_to, metadb_handle_list_ref itemsAdded, metadb_handle_list_ref itemsRemoved)
 

Additional Inherited Members

- Protected Member Functions inherited from service_base
 service_base ()
 
 ~service_base ()
 

Detailed Description

Interface to notify component system about files being deleted or moved. Operates in app's main thread only.

Definition at line 6 of file file_operation_callback.h.

Member Typedef Documentation

Definition at line 8 of file file_operation_callback.h.

Member Function Documentation

file_operation_callback::FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT ( file_operation_callback  )
bool file_operation_callback::g_mark_dead_entries ( metadb_handle_list_cref  items,
bit_array_var mask,
t_pathlist  deadPaths 
)
static

Definition at line 117 of file file_operation_callback.cpp.

117  {
118  bool found = false;
119  const t_size total = items.get_count();
120  for(t_size walk = 0; walk < total; ++walk) {
121  t_size index;
122  if (g_search_sorted_list(deadPaths,items[walk]->get_path(),index)) {
123  mask.set(walk,true); found = true;
124  } else {
125  mask.set(walk,false);
126  }
127  }
128  return found;
129 }
virtual void set(t_size n, bool val)=0
size_t t_size
Definition: int_types.h:48
virtual t_size get_count() const =0
static bool g_search_sorted_list(const pfc::list_base_const_t< const char * > &p_list, const char *p_string, t_size &p_index)
void file_operation_callback::g_on_files_copied ( const pfc::list_base_const_t< const char * > &  p_from,
const pfc::list_base_const_t< const char * > &  p_to 
)
static

Definition at line 60 of file file_operation_callback.cpp.

61 {
63  {
64  assert(p_from.get_count() == p_to.get_count());
65  t_size count = p_from.get_count();
66  if (count > 0)
67  {
68  if (count == 1) g_on_files_copied_sorted(p_from,p_to);
69  else
70  {
71  pfc::array_t<t_size> order; order.set_size(count);
72  order_helper::g_fill(order);
75  }
76  }
77  }
78 }
const t_item * get_ptr() const
Definition: array.h:213
static void g_fill(t_int *p_order, const t_size p_count)
Definition: order_helper.h:38
static void g_on_files_copied_sorted(const pfc::list_base_const_t< const char * > &p_from, const pfc::list_base_const_t< const char * > &p_to)
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
static int path_compare(const char *p1, const char *p2)
Definition: metadb.h:245
bool assert_main_thread()
Tests whether calling thread is main app thread, and shows diagnostic message in debugger output if i...
void sort_get_permutation_t(t_compare p_compare, t_permutation const &p_permutation) const
Definition: list.h:55
void file_operation_callback::g_on_files_deleted ( const pfc::list_base_const_t< const char * > &  p_items)
static

Definition at line 25 of file file_operation_callback.cpp.

26 {
28  t_size count = p_items.get_count();
29  if (count > 0)
30  {
31  if (count == 1) g_on_files_deleted_sorted(p_items);
32  else
33  {
34  pfc::array_t<t_size> order; order.set_size(count);
35  order_helper::g_fill(order);
38  }
39  }
40 }
void ensure_main_thread()
Triggers a bug check if the calling thread is not the main app thread.
const t_item * get_ptr() const
Definition: array.h:213
static void g_fill(t_int *p_order, const t_size p_count)
Definition: order_helper.h:38
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
static void g_on_files_deleted_sorted(const pfc::list_base_const_t< const char * > &p_items)
static int path_compare(const char *p1, const char *p2)
Definition: metadb.h:245
void sort_get_permutation_t(t_compare p_compare, t_permutation const &p_permutation) const
Definition: list.h:55
void file_operation_callback::g_on_files_moved ( const pfc::list_base_const_t< const char * > &  p_from,
const pfc::list_base_const_t< const char * > &  p_to 
)
static

Definition at line 42 of file file_operation_callback.cpp.

43 {
45  pfc::dynamic_assert(p_from.get_count() == p_to.get_count());
46  t_size count = p_from.get_count();
47  if (count > 0)
48  {
49  if (count == 1) g_on_files_moved_sorted(p_from,p_to);
50  else
51  {
52  pfc::array_t<t_size> order; order.set_size(count);
53  order_helper::g_fill(order);
56  }
57  }
58 }
void ensure_main_thread()
Triggers a bug check if the calling thread is not the main app thread.
static void g_on_files_moved_sorted(const pfc::list_base_const_t< const char * > &p_from, const pfc::list_base_const_t< const char * > &p_to)
const t_item * get_ptr() const
Definition: array.h:213
static void g_fill(t_int *p_order, const t_size p_count)
Definition: order_helper.h:38
void dynamic_assert(bool p_condition, const char *p_msg)
Definition: primitives.h:239
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
static int path_compare(const char *p1, const char *p2)
Definition: metadb.h:245
void sort_get_permutation_t(t_compare p_compare, t_permutation const &p_permutation) const
Definition: list.h:55
bool file_operation_callback::g_search_sorted_list ( const pfc::list_base_const_t< const char * > &  p_list,
const char *  p_string,
t_size p_index 
)
static

Definition at line 79 of file file_operation_callback.cpp.

79  {
80  return pfc::binarySearch<metadb::path_comparator>::run(p_list,0,p_list.get_count(),p_string,p_index);
81 }
static bool run(const t_container &p_container, t_size p_base, t_size p_count, const t_param &p_param, t_size &p_result)
Definition: binary_search.h:9
virtual t_size get_count() const =0
bool file_operation_callback::g_update_list_on_moved ( metadb_handle_list_ref  p_list,
t_pathlist  p_from,
t_pathlist  p_to 
)
static

Definition at line 100 of file file_operation_callback.cpp.

100  {
102  bool changed = false;
103  for(t_size walk = 0; walk < p_list.get_count(); ++walk) {
104  metadb_handle_ptr item = p_list[walk];
105  t_size index;
106  if (g_search_sorted_list(p_from,item->get_path(),index)) {
107  metadb_handle_ptr newItem;
108  api->handle_create_replace_path_canonical(newItem,item,p_to[index]);
109  p_list.replace_item(walk,newItem);
110  changed = true;
111  }
112  }
113  return changed;
114 }
virtual void replace_item(t_size p_index, const T &p_item)=0
size_t t_size
Definition: int_types.h:48
virtual t_size get_count() const =0
static bool g_search_sorted_list(const pfc::list_base_const_t< const char * > &p_list, const char *p_string, t_size &p_index)
Helper template used to easily access core services. Usage: static_api_ptr_t<myclass> api; api->doso...
Definition: service.h:533
bool file_operation_callback::g_update_list_on_moved_ex ( metadb_handle_list_ref  p_list,
t_pathlist  p_from,
t_pathlist  p_to,
metadb_handle_list_ref  itemsAdded,
metadb_handle_list_ref  itemsRemoved 
)
static

Definition at line 83 of file file_operation_callback.cpp.

83  {
85  bool changed = false;
86  itemsAdded.remove_all(); itemsRemoved.remove_all();
87  for(t_size walk = 0; walk < p_list.get_count(); ++walk) {
88  metadb_handle_ptr item = p_list[walk];
89  t_size index;
90  if (g_search_sorted_list(p_from,item->get_path(),index)) {
91  metadb_handle_ptr newItem;
92  api->handle_create_replace_path_canonical(newItem,item,p_to[index]);
93  p_list.replace_item(walk,newItem);
94  changed = true;
95  itemsAdded.add_item(newItem); itemsRemoved.add_item(item);
96  }
97  }
98  return changed;
99 }
t_size add_item(const T &item)
Definition: list.h:210
virtual void replace_item(t_size p_index, const T &p_item)=0
size_t t_size
Definition: int_types.h:48
virtual t_size get_count() const =0
static bool g_search_sorted_list(const pfc::list_base_const_t< const char * > &p_list, const char *p_string, t_size &p_index)
void remove_all()
Definition: list.h:213
Helper template used to easily access core services. Usage: static_api_ptr_t<myclass> api; api->doso...
Definition: service.h:533
virtual void file_operation_callback::on_files_copied_sorted ( t_pathlist  p_from,
t_pathlist  p_to 
)
pure virtual

p_from is a metadb::path_compare sorted list of files that have been copied, p_to is a list of corresponding target locations.

virtual void file_operation_callback::on_files_deleted_sorted ( t_pathlist  p_items)
pure virtual

p_items is a metadb::path_compare sorted list of files that have been deleted.

virtual void file_operation_callback::on_files_moved_sorted ( t_pathlist  p_from,
t_pathlist  p_to 
)
pure virtual

p_from is a metadb::path_compare sorted list of files that have been moved, p_to is a list of corresponding target locations.


The documentation for this class was generated from the following files: