foobar2000 SDK  2015-01-14
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions
metadbabstract

#include <metadb.h>

+ Inheritance diagram for metadb:

Public Types

enum  { case_sensitive = true }
 
typedef pfc::comparator_strcmp path_comparator
 
- Public Types inherited from service_base
typedef service_base t_interface
 

Public Member Functions

 FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT (metadb)
 
virtual void handle_create (metadb_handle_ptr &p_out, const playable_location &p_location)=0
 
metadb_handle_ptr handle_create (playable_location const &l)
 
metadb_handle_ptr handle_create (const char *path, uint32_t subsong)
 
void handle_create_replace_path (metadb_handle_ptr &p_out, const metadb_handle_ptr &p_source, const char *p_new_path)
 
void handle_create_replace_path_canonical (metadb_handle_ptr &p_out, const metadb_handle_ptr &p_source, const char *p_new_path)
 
void handle_replace_path_canonical (metadb_handle_ptr &p_out, const char *p_new_path)
 
- 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_get_random_handle (metadb_handle_ptr &p_out)
 
static int path_compare (const char *p1, const char *p2)
 
static int path_compare_ex (const char *p1, t_size len1, const char *p2, t_size len2)
 
static int path_compare_metadb_handle (const metadb_handle_ptr &p1, const metadb_handle_ptr &p2)
 
static int path_compare_nc (const char *p1, size_t len1, const char *p2, size_t len2)
 

Protected Member Functions

virtual void database_lock ()=0
 
virtual void database_unlock ()=0
 
- Protected Member Functions inherited from service_base
 service_base ()
 
 ~service_base ()
 

Detailed Description

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 at line 216 of file metadb.h.

Member Typedef Documentation

Definition at line 241 of file metadb.h.

Member Enumeration Documentation

anonymous enum
Enumerator
case_sensitive 

Definition at line 240 of file metadb.h.

Member Function Documentation

virtual void metadb::database_lock ( )
protectedpure virtual

OBSOLETE, DO NOT CALL.

virtual void metadb::database_unlock ( )
protectedpure virtual

OBSOLETE, DO NOT CALL.

metadb::FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT ( metadb  )
bool metadb::g_get_random_handle ( metadb_handle_ptr p_out)
static

Helper function; attempts to retrieve a handle to any known playable location to be used for e.g. titleformatting script preview.
.

Returns
True on success; false on failure (no known playable locations).

Definition at line 39 of file metadb.cpp.

39  {
40  if (static_api_ptr_t<playback_control>()->get_now_playing(p_out)) return true;
41 
42  {
44 
45  t_size playlist_count = api->get_playlist_count();
46  t_size active_playlist = api->get_active_playlist();
47  if (active_playlist != ~0) {
48  if (api->playlist_get_focus_item_handle(p_out,active_playlist)) return true;
49  }
50 
51  for(t_size n = 0; n < playlist_count; n++) {
52  if (api->playlist_get_focus_item_handle(p_out,n)) return true;
53  }
54 
55  if (active_playlist != ~0) {
56  t_size item_count = api->playlist_get_item_count(active_playlist);
57  if (item_count > 0) {
58  if (api->playlist_get_item_handle(p_out,active_playlist,0)) return true;
59  }
60  }
61 
62  for(t_size n = 0; n < playlist_count; n++) {
63  t_size item_count = api->playlist_get_item_count(n);
64  if (item_count > 0) {
65  if (api->playlist_get_item_handle(p_out,n,0)) return true;
66  }
67  }
68  }
69 
70  return false;
71 }
size_t t_size
Definition: int_types.h:48
virtual void metadb::handle_create ( metadb_handle_ptr p_out,
const playable_location p_location 
)
pure virtual

Returns a metadb_handle object referencing the specified location. If one doesn't exist yet a new one is created. There can be only one metadb_handle object referencing specific location.
This function should never fail unless there's something critically wrong (can't allocate memory for the new object, etc).
Speed: O(log(n)) to total number of metadb_handles present. It's recommended to pass metadb_handles around whenever possible rather than pass playable_locations then retrieve metadb_handles on demand when needed.

Parameters
p_outReceives the metadb_handle pointer.
p_locationLocation to create a metadb_handle for.
metadb_handle_ptr metadb::handle_create ( playable_location const &  l)
inline

Definition at line 248 of file metadb.h.

248 {metadb_handle_ptr temp; handle_create(temp, l); return temp;}
virtual void handle_create(metadb_handle_ptr &p_out, const playable_location &p_location)=0
Returns a metadb_handle object referencing the specified location. If one doesn't exist yet a new one...
metadb_handle_ptr metadb::handle_create ( const char *  path,
uint32_t  subsong 
)
inline

Definition at line 249 of file metadb.h.

249 {return handle_create(make_playable_location(path, subsong));}
virtual void handle_create(metadb_handle_ptr &p_out, const playable_location &p_location)=0
Returns a metadb_handle object referencing the specified location. If one doesn't exist yet a new one...
void metadb::handle_create_replace_path ( metadb_handle_ptr p_out,
const metadb_handle_ptr p_source,
const char *  p_new_path 
)

Definition at line 8 of file metadb.cpp.

8  {
9  pfc::string8 path;
10  filesystem::g_get_canonical_path(p_new_path,path);
11  handle_create_replace_path_canonical(p_out,p_source,path);
12 }
void handle_create_replace_path_canonical(metadb_handle_ptr &p_out, const metadb_handle_ptr &p_source, const char *p_new_path)
Definition: metadb.cpp:4
void metadb::handle_create_replace_path_canonical ( metadb_handle_ptr p_out,
const metadb_handle_ptr p_source,
const char *  p_new_path 
)

Definition at line 4 of file metadb.cpp.

4  {
5  handle_create(p_out,make_playable_location(p_new_path,p_source->get_subsong_index()));
6 }
virtual void handle_create(metadb_handle_ptr &p_out, const playable_location &p_location)=0
Returns a metadb_handle object referencing the specified location. If one doesn't exist yet a new one...
void metadb::handle_replace_path_canonical ( metadb_handle_ptr p_out,
const char *  p_new_path 
)

Definition at line 14 of file metadb.cpp.

14  {
15  metadb_handle_ptr temp;
16  handle_create_replace_path_canonical(temp,p_out,p_new_path);
17  p_out = temp;
18 }
void handle_create_replace_path_canonical(metadb_handle_ptr &p_out, const metadb_handle_ptr &p_source, const char *p_new_path)
Definition: metadb.cpp:4
static int metadb::path_compare ( const char *  p1,
const char *  p2 
)
inlinestatic

Definition at line 245 of file metadb.h.

245 {return case_sensitive ? strcmp(p1,p2) : stricmp_utf8(p1,p2);}
int SHARED_EXPORT stricmp_utf8(const char *p1, const char *p2)
static int metadb::path_compare_ex ( const char *  p1,
t_size  len1,
const char *  p2,
t_size  len2 
)
inlinestatic

Definition at line 243 of file metadb.h.

243 {return case_sensitive ? pfc::strcmp_ex(p1,len1,p2,len2) : stricmp_utf8_ex(p1,len1,p2,len2);}
int SHARED_EXPORT stricmp_utf8_ex(const char *p1, t_size len1, const char *p2, t_size len2)
int strcmp_ex(const char *p1, t_size n1, const char *p2, t_size n2)
static int metadb::path_compare_metadb_handle ( const metadb_handle_ptr p1,
const metadb_handle_ptr p2 
)
inlinestatic

Definition at line 246 of file metadb.h.

246 {return path_compare(p1->get_path(),p2->get_path());}
static int path_compare(const char *p1, const char *p2)
Definition: metadb.h:245
static int metadb::path_compare_nc ( const char *  p1,
size_t  len1,
const char *  p2,
size_t  len2 
)
inlinestatic

Definition at line 244 of file metadb.h.

244 {return case_sensitive ? pfc::strcmp_nc(p1,len1,p2,len2) : stricmp_utf8_ex(p1,len1,p2,len2);}
int SHARED_EXPORT stricmp_utf8_ex(const char *p1, t_size len1, const char *p2, t_size len2)
int strcmp_nc(const char *p1, size_t n1, const char *p2, size_t n2)

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