foobar2000 SDK  2015-08-03
service.cpp
Go to the documentation of this file.
1 #include "foobar2000.h"
2 #include "component.h"
3 
5 
7 {
8  PFC_ASSERT(core_api::are_services_available() && g_foobar2000_api);
9  return g_foobar2000_api->service_enum_find_class(p_guid);
10 }
11 
13 {
14  PFC_ASSERT(core_api::are_services_available() && g_foobar2000_api);
15  return g_foobar2000_api->service_enum_create(p_out,p_class,p_index);
16 }
17 
19 {
20  PFC_ASSERT(core_api::are_services_available() && g_foobar2000_api);
21  return g_foobar2000_api->service_enum_get_count(p_class);
22 }
23 
25 
26 
27 
28 
29 
30 namespace {
31  class main_thread_callback_release_object : public main_thread_callback {
32  public:
33  main_thread_callback_release_object(service_ptr obj) : m_object(obj) {}
34  void callback_run() {
35  try { m_object.release(); } catch(...) {}
36  }
37  private:
38  service_ptr m_object;
39  };
40 }
44  }
45 };
46 
47 
48 void _standard_api_create_internal(service_ptr & out, const GUID & classID) {
51  case 0:
52  throw exception_service_not_found();
53  case 1:
54  PFC_ASSERT_SUCCESS( service_factory_base::enum_create(out, c, 0) );
55  break;
56  default:
57  throw exception_service_duplicated();
58  }
59 }
Template implementing reference-counting features of service_base. Intended for dynamic instantiation...
Definition: service_impl.h:4
Definition: pfc.h:71
virtual service_class_ref service_enum_find_class(const GUID &p_guid)=0
foobar2000_api * g_foobar2000_api
Definition: service.cpp:4
static service_factory_base * __internal__list
FOR INTERNAL USE ONLY.
Definition: service.h:400
const void * service_class_ref
Definition: service.h:4
static t_size enum_get_count(service_class_ref p_class)
Definition: service.cpp:18
size_t t_size
Definition: int_types.h:48
void _standard_api_create_internal(service_ptr &out, const GUID &classID)
Definition: service.cpp:48
static service_class_ref enum_find_class(const GUID &p_guid)
Definition: service.cpp:6
virtual t_size service_enum_get_count(service_class_ref p_class)=0
static bool enum_create(service_ptr_t< service_base > &p_out, service_class_ref p_class, t_size p_index)
Definition: service.cpp:12
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition: service.h:55
Helper template used to easily access core services. Usage: static_api_ptr_t<myclass> api; api->doso...
Definition: service.h:533
bool are_services_available()
Tests whether services are available at this time. They are not available only during DLL startup or ...
Callback object class for main_thread_callback_manager service.
virtual bool service_enum_create(service_ptr_t< service_base > &p_out, service_class_ref p_class, t_size p_index)=0
void release_object_delayed(service_ptr obj)
Definition: service.cpp:42