foobar2000 SDK  2015-08-03
Private Types | Private Member Functions
ui_edit_contextabstract

#include <ui_edit_context.h>

+ Inheritance diagram for ui_edit_context:

Private Types

enum  {
  flag_removable = 1, flag_reorderable = 2, flag_undoable = 4, flag_redoable = 8,
  flag_linearlist = 16, flag_searchable = 32, flag_insertable = 64
}
 

Private Member Functions

bool can_remove ()
 
bool can_remove_mask ()
 
bool can_reorder ()
 
bool can_search ()
 
virtual void clear ()
 
virtual void crop_selection ()
 
virtual void get_all_items (metadb_handle_list_ref out)
 
virtual t_uint32 get_flags ()=0
 
virtual metadb_handle_ptr get_item (t_size index)=0
 
virtual t_size get_item_count (t_size max=~0)=0
 
virtual void get_items (metadb_handle_list_ref out, pfc::bit_array const &mask)=0
 
virtual void get_selected_items (metadb_handle_list_ref out)
 
virtual t_size get_selection_count (t_size max=~0)
 
virtual void get_selection_mask (pfc::bit_array_var &out)
 
virtual GUID get_selection_type ()=0
 
virtual void insert_items (t_size at, metadb_handle_list_cref items, pfc::bit_array const &selection)=0
 
virtual bool is_item_selected (t_size item)=0
 
virtual t_size query_insert_mark ()=0
 
virtual void redo_restore ()=0
 
virtual void remove_items (pfc::bit_array const &mask)=0
 
virtual void remove_selection ()
 
virtual void reorder_items (const t_size *order, t_size count)=0
 
virtual void search ()=0
 
virtual void select_all ()
 
virtual void select_none ()
 
virtual FB2K_MAKE_SERVICE_INTERFACE(ui_edit_context, service_base) public void shutdown ()=0
 
void sort_by_format (const char *spec, bool onlySelection)
 
bool test_flags (t_uint32 flags)
 
virtual void undo_backup ()=0
 
virtual void undo_restore ()=0
 
virtual void update_selection (const pfc::bit_array &mask, const pfc::bit_array &newVals)=0
 

Additional Inherited Members

- Public Types inherited from service_base
typedef service_base t_interface
 
- 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 ()
 
- Protected Member Functions inherited from service_base
 service_base ()
 
 ~service_base ()
 

Detailed Description

Definition at line 2 of file ui_edit_context.h.

Member Enumeration Documentation

anonymous enum
private
Enumerator
flag_removable 
flag_reorderable 
flag_undoable 
flag_redoable 
flag_linearlist 
flag_searchable 
flag_insertable 

Definition at line 11 of file ui_edit_context.h.

Member Function Documentation

bool ui_edit_context::can_remove ( )
inlineprivate

Definition at line 23 of file ui_edit_context.h.

23 {return (get_flags() & flag_removable) != 0;}
virtual t_uint32 get_flags()=0
bool ui_edit_context::can_remove_mask ( )
inlineprivate
bool ui_edit_context::can_reorder ( )
inlineprivate

Definition at line 26 of file ui_edit_context.h.

bool ui_edit_context::can_search ( )
inlineprivate

Definition at line 27 of file ui_edit_context.h.

virtual void ui_edit_context::clear ( )
inlineprivatevirtual

Definition at line 34 of file ui_edit_context.h.

virtual void remove_items(pfc::bit_array const &mask)=0
virtual void ui_edit_context::crop_selection ( )
inlineprivatevirtual

Definition at line 33 of file ui_edit_context.h.

Generic variable bit_array implementation. Needs to be initialized with requested array size before ...
virtual void remove_items(pfc::bit_array const &mask)=0
Negation of another array. Valid index range is the same as valid index range of the parameter array...
virtual void get_selection_mask(pfc::bit_array_var &out)
virtual t_size get_item_count(t_size max=~0)=0
virtual void ui_edit_context::get_all_items ( metadb_handle_list_ref  out)
inlineprivatevirtual

Definition at line 35 of file ui_edit_context.h.

35 {get_items(out, bit_array_true());}
virtual void get_items(metadb_handle_list_ref out, pfc::bit_array const &mask)=0
virtual t_uint32 ui_edit_context::get_flags ( )
privatepure virtual
virtual metadb_handle_ptr ui_edit_context::get_item ( t_size  index)
privatepure virtual
virtual t_size ui_edit_context::get_item_count ( t_size  max = ~0)
privatepure virtual
virtual void ui_edit_context::get_items ( metadb_handle_list_ref  out,
pfc::bit_array const &  mask 
)
privatepure virtual
virtual void ui_edit_context::get_selected_items ( metadb_handle_list_ref  out)
inlineprivatevirtual

Definition at line 31 of file ui_edit_context.h.

Generic variable bit_array implementation. Needs to be initialized with requested array size before ...
virtual void get_items(metadb_handle_list_ref out, pfc::bit_array const &mask)=0
virtual void get_selection_mask(pfc::bit_array_var &out)
virtual t_size get_item_count(t_size max=~0)=0
virtual t_size ui_edit_context::get_selection_count ( t_size  max = ~0)
inlineprivatevirtual

Definition at line 49 of file ui_edit_context.h.

49  {
50  t_size count = 0;
51  const t_size total = get_item_count();
52  for(t_size walk = 0; walk < total && count < max; ++walk) if (is_item_selected(walk)) ++count;
53  return count;
54  }
size_t t_size
Definition: int_types.h:48
virtual bool is_item_selected(t_size item)=0
virtual t_size get_item_count(t_size max=~0)=0
virtual void ui_edit_context::get_selection_mask ( pfc::bit_array_var out)
inlineprivatevirtual

Definition at line 39 of file ui_edit_context.h.

39  {
40  const t_size count = get_item_count(); for(t_size walk = 0; walk < count; ++walk) out.set(walk, is_item_selected(walk));
41  }
virtual void set(t_size n, bool val)=0
size_t t_size
Definition: int_types.h:48
virtual bool is_item_selected(t_size item)=0
virtual t_size get_item_count(t_size max=~0)=0
virtual GUID ui_edit_context::get_selection_type ( )
privatepure virtual
virtual void ui_edit_context::insert_items ( t_size  at,
metadb_handle_list_cref  items,
pfc::bit_array const &  selection 
)
privatepure virtual
virtual bool ui_edit_context::is_item_selected ( t_size  item)
privatepure virtual
virtual t_size ui_edit_context::query_insert_mark ( )
privatepure virtual
virtual void ui_edit_context::redo_restore ( )
privatepure virtual
virtual void ui_edit_context::remove_items ( pfc::bit_array const &  mask)
privatepure virtual
virtual void ui_edit_context::remove_selection ( )
inlineprivatevirtual

Definition at line 32 of file ui_edit_context.h.

Generic variable bit_array implementation. Needs to be initialized with requested array size before ...
virtual void remove_items(pfc::bit_array const &mask)=0
virtual void get_selection_mask(pfc::bit_array_var &out)
virtual t_size get_item_count(t_size max=~0)=0
virtual void ui_edit_context::reorder_items ( const t_size order,
t_size  count 
)
privatepure virtual
virtual void ui_edit_context::search ( )
privatepure virtual
virtual void ui_edit_context::select_all ( )
inlineprivatevirtual

Definition at line 29 of file ui_edit_context.h.

virtual void update_selection(const pfc::bit_array &mask, const pfc::bit_array &newVals)=0
virtual void ui_edit_context::select_none ( )
inlineprivatevirtual

Definition at line 30 of file ui_edit_context.h.

virtual void update_selection(const pfc::bit_array &mask, const pfc::bit_array &newVals)=0
virtual FB2K_MAKE_SERVICE_INTERFACE (ui_edit_context, service_base) public void ui_edit_context::shutdown ( )
privatepure virtual

Called by core only.
WARNING: you may get other methods called after shutdown() in case someone using ui_edit_context_manager has kept a reference to your service - for an example during an async operation. You should behave sanely in such case - either execute the operation if still possible or fail cleanly.

void ui_edit_context::sort_by_format ( const char *  spec,
bool  onlySelection 
)
inlineprivate

Definition at line 66 of file ui_edit_context.h.

66  {
67  const t_size count = get_item_count();
68  pfc::array_t<t_size> order; order.set_size(count);
69  pfc::array_t<t_size> sel_map;
70  if (onlySelection) {
71  sel_map.set_size(count);
72  t_size sel_count = 0;
73  for(t_size n=0;n<count;n++) if (is_item_selected(n)) sel_map[sel_count++]=n;
74  sel_map.set_size(sel_count);
75  }
76 
77  {
78  metadb_handle_list temp;
79  pfc::array_t<t_size> order_temp;
80  if (onlySelection) {
81  get_selected_items(temp);
82  order_temp.set_size(count);
83  } else {
84  get_all_items(temp);
85  }
86 
87 
88  if (spec != NULL) {
89  temp.sort_by_format_get_order(onlySelection ? order_temp.get_ptr() : order.get_ptr(),spec,0);
90  } else {
91  static_api_ptr_t<genrand_service> api; api->seed((unsigned)__rdtsc());
92  api->generate_random_order(onlySelection ? order_temp.get_ptr() : order.get_ptr(),temp.get_count());
93  }
94 
95  if (onlySelection) {
96  t_size n,ptr;
97  for(n=0,ptr=0;n<count;n++) {
98  if (!is_item_selected(n)) {
99  order[n] = n;
100  } else {
101  t_size v = order_temp[ptr++];
102  order[n] = sel_map[v];
103  }
104  }
105  }
106  }
107 
108  reorder_items(order.get_ptr(), count);
109  }
const t_item * get_ptr() const
Definition: array.h:213
virtual void reorder_items(const t_size *order, t_size count)=0
void sort_by_format_get_order(t_size *order, const char *spec, titleformat_hook *p_hook) const
t_size get_count() const
Definition: list.h:365
size_t t_size
Definition: int_types.h:48
void set_size(t_size p_size)
Definition: array.h:104
virtual void get_all_items(metadb_handle_list_ref out)
virtual bool is_item_selected(t_size item)=0
virtual void get_selected_items(metadb_handle_list_ref out)
Helper template used to easily access core services. Usage: static_api_ptr_t<myclass> api; api->doso...
Definition: service.h:533
virtual t_size get_item_count(t_size max=~0)=0
bool ui_edit_context::test_flags ( t_uint32  flags)
inlineprivate

Definition at line 24 of file ui_edit_context.h.

24 {return (get_flags() & flags) == flags;}
virtual t_uint32 get_flags()=0
virtual void ui_edit_context::undo_backup ( )
privatepure virtual
virtual void ui_edit_context::undo_restore ( )
privatepure virtual
virtual void ui_edit_context::update_selection ( const pfc::bit_array mask,
const pfc::bit_array newVals 
)
privatepure virtual

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