foobar2000 SDK
2015-01-14
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
foobar2000
SDK
service.cpp
Go to the documentation of this file.
1
#include "
foobar2000.h
"
2
#include "
component.h
"
3
4
foobar2000_api
*
g_foobar2000_api
= NULL;
5
6
service_class_ref
service_factory_base::enum_find_class
(
const
GUID
& p_guid)
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
12
bool
service_factory_base::enum_create
(
service_ptr_t<service_base>
& p_out,
service_class_ref
p_class,
t_size
p_index)
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
18
t_size
service_factory_base::enum_get_count
(
service_class_ref
p_class)
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
24
service_factory_base
*
service_factory_base::__internal__list
= NULL;
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
}
41
namespace
service_impl_helper
{
42
void
release_object_delayed
(
service_ptr
obj) {
43
static_api_ptr_t<main_thread_callback_manager>
()->add_callback(
new
service_impl_t<main_thread_callback_release_object>
(obj));
44
}
45
};
46
47
48
void
_standard_api_create_internal
(
service_ptr
& out,
const
GUID
& classID) {
49
service_class_ref
c =
service_factory_base::enum_find_class
(classID);
50
switch
(
service_factory_base::enum_get_count
(c)) {
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
}
service_impl_t
Template implementing reference-counting features of service_base. Intended for dynamic instantiation...
Definition:
service_impl.h:4
GUID
Definition:
pfc.h:53
foobar2000_api::service_enum_find_class
virtual service_class_ref service_enum_find_class(const GUID &p_guid)=0
g_foobar2000_api
foobar2000_api * g_foobar2000_api
Definition:
service.cpp:4
service_factory_base::__internal__list
static service_factory_base * __internal__list
FOR INTERNAL USE ONLY.
Definition:
service.h:400
foobar2000_api
Definition:
component.h:37
service_class_ref
const void * service_class_ref
Definition:
service.h:4
service_factory_base
Definition:
service.h:383
service_factory_base::enum_get_count
static t_size enum_get_count(service_class_ref p_class)
Definition:
service.cpp:18
t_size
size_t t_size
Definition:
int_types.h:48
_standard_api_create_internal
void _standard_api_create_internal(service_ptr &out, const GUID &classID)
Definition:
service.cpp:48
foobar2000.h
service_factory_base::enum_find_class
static service_class_ref enum_find_class(const GUID &p_guid)
Definition:
service.cpp:6
foobar2000_api::service_enum_get_count
virtual t_size service_enum_get_count(service_class_ref p_class)=0
service_factory_base::enum_create
static bool enum_create(service_ptr_t< service_base > &p_out, service_class_ref p_class, t_size p_index)
Definition:
service.cpp:12
service_ptr_t
Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes.
Definition:
service.h:55
main_thread_callback::callback_run
virtual void callback_run()=0
Gets called from main app thread. See main_thread_callback_manager description for more info...
component.h
static_api_ptr_t
Helper template used to easily access core services. Usage: static_api_ptr_t
api; api->doso...
Definition:
service.h:533
service_impl_helper
Definition:
service.cpp:41
core_api::are_services_available
bool are_services_available()
Tests whether services are available at this time. They are not available only during DLL startup or ...
Definition:
component_client.cpp:35
main_thread_callback
Callback object class for main_thread_callback_manager service.
Definition:
main_thread_callback.h:2
foobar2000_api::service_enum_create
virtual bool service_enum_create(service_ptr_t< service_base > &p_out, service_class_ref p_class, t_size p_index)=0
service_impl_helper::release_object_delayed
void release_object_delayed(service_ptr obj)
Definition:
service.cpp:42
Generated by
1.8.9.1