service.h File Reference

#include "service_impl.h"

Go to the source code of this file.

Namespaces

namespace  pfc

Classes

class  service_obscure_refcounting< T >
 Special hack to ensure errors when someone tries to ->service_add_ref()/->service_release() on a service_ptr_t. More...
class  service_ptr_t< T >
 Autopointer class to be used with all services. Manages reference counter calls behind-the-scenes. More...
class  pfc::pfc::traits_t< service_ptr_t< T > >
class  service_list_t< T, t_alloc >
class  service_base
class  service_factory_base
class  service_factory_base_t< B >
class  service_class_helper_t< T >
class  static_api_ptr_t< t_interface >
class  service_instance_array_t< T >
 Helper; simulates array with instance of each available implementation of given service class. More...
class  service_enum_t< t_interface >
class  service_factory_t< T >
class  service_factory_single_t< T >
class  service_factory_single_ref_t< T >
class  service_factory_single_transparent_t< T >
class  service_by_guid_data< what >
class  _service_by_guid_data_container< what >

Defines

#define FOOGUIDDECL
#define DECLARE_GUID(NAME, A, S, D, F, G, H, J, K, L, Z, X)   FOOGUIDDECL const GUID NAME = {A,S,D,{F,G,H,J,K,L,Z,X}};
#define DECLARE_CLASS_GUID(NAME, A, S, D, F, G, H, J, K, L, Z, X)   FOOGUIDDECL const GUID NAME::class_guid = {A,S,D,{F,G,H,J,K,L,Z,X}};
#define FB2K_MAKE_SERVICE_INTERFACE(THISCLASS, PARENTCLASS)
#define FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(THISCLASS)
#define FB2K_DECLARE_SERVICE_BEGIN(THISCLASS, BASECLASS)
#define FB2K_DECLARE_SERVICE_END()   };
#define FB2K_DECLARE_SERVICE_ENTRYPOINT_BEGIN(THISCLASS)
#define FB2K_ASSERT_VALID_SERVICE_PTR(ptr)
#define FB2K_API_AVAILABLE(API)   static_api_test_t<API>()

Typedefs

typedef const void * service_class_ref
typedef service_ptr_t
< service_base
service_ptr

Functions

 PFC_DECLARE_EXCEPTION (exception_service_not_found, pfc::exception,"Service not found")
 PFC_DECLARE_EXCEPTION (exception_service_extension_not_found, pfc::exception,"Service extension not found")
 PFC_DECLARE_EXCEPTION (exception_service_duplicated, pfc::exception,"Service duplicated")
template<typename T>
static
service_obscure_refcounting< T > * 
service_obscure_refcounting_cast (T *p_source) throw ()
 Converts a service interface pointer to a pointer that obscures service counter functionality.
template<typename T>
static void service_release_safe (T *p_ptr) throw ()
template<typename T>
static void service_add_ref_safe (T *p_ptr) throw ()
template<typename T>
static void __validate_service_class_helper ()
template<>
static void __validate_service_class_helper< service_base > ()
template<typename T>
static void _validate_service_ptr (service_ptr_t< T > const &ptr)
template<class T>
static bool service_enum_create_t (service_ptr_t< T > &p_out, t_size p_index)
template<typename T>
static service_class_ref _service_find_class ()
template<typename what>
static bool _service_instantiate_helper (service_ptr_t< what > &out, service_class_ref servClass, t_size index)
void _standard_api_create_internal (service_ptr &out, const GUID &classID)
template<typename T>
static void standard_api_create_t (service_ptr_t< T > &p_out)
template<typename T>
static service_ptr_t< T > standard_api_create_t ()
template<typename T>
static bool static_api_test_t ()
template<typename what>
static bool service_by_guid_fallback (service_ptr_t< what > &out, const GUID &id)
template<typename what>
static void service_by_guid_init ()
template<typename what>
static bool service_by_guid (service_ptr_t< what > &out, const GUID &id)
template<typename what>
static service_ptr_t< what > service_by_guid (const GUID &id)


Define Documentation

#define DECLARE_CLASS_GUID ( NAME,
A,
S,
D,
F,
G,
H,
J,
K,
L,
Z,
 )     FOOGUIDDECL const GUID NAME::class_guid = {A,S,D,{F,G,H,J,K,L,Z,X}};

#define DECLARE_GUID ( NAME,
A,
S,
D,
F,
G,
H,
J,
K,
L,
Z,
 )     FOOGUIDDECL const GUID NAME = {A,S,D,{F,G,H,J,K,L,Z,X}};

#define FB2K_API_AVAILABLE ( API   )     static_api_test_t<API>()

#define FB2K_ASSERT_VALID_SERVICE_PTR ( ptr   ) 

#define FB2K_DECLARE_SERVICE_BEGIN ( THISCLASS,
BASECLASS   ) 

Value:

class NOVTABLE THISCLASS : public BASECLASS     {       \
                FB2K_MAKE_SERVICE_INTERFACE(THISCLASS,BASECLASS);       \
        public:

 
#define FB2K_DECLARE_SERVICE_END (  )     };

#define FB2K_DECLARE_SERVICE_ENTRYPOINT_BEGIN ( THISCLASS   ) 

Value:

class NOVTABLE THISCLASS : public service_base {        \
                FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(THISCLASS)       \
        public:

#define FB2K_MAKE_SERVICE_INTERFACE ( THISCLASS,
PARENTCLASS   ) 

Value:

public: \
                typedef THISCLASS t_interface;  \
                typedef PARENTCLASS t_interface_parent; \
                        \
                static const GUID class_guid;   \
                        \
                virtual bool service_query(service_ptr_t<service_base> & p_out,const GUID & p_guid) {   \
                        if (p_guid == class_guid) {p_out = this; return true;}  \
                        else return PARENTCLASS::service_query(p_out,p_guid);   \
                }       \
                typedef service_ptr_t<t_interface> ptr; \
        protected:      \
                THISCLASS() {}  \
                ~THISCLASS() {} \
        private:        \
                const THISCLASS & operator=(const THISCLASS &) {throw pfc::exception_not_implemented();}        \
                THISCLASS(const THISCLASS &) {throw pfc::exception_not_implemented();}  \
        private:        \
                void __private__service_declaration_selftest() {        \
                        pfc::assert_same_type<PARENTCLASS,PARENTCLASS::t_interface>(); /*parentclass must be an interface*/     \
                        __validate_service_class_helper<THISCLASS>(); /*service_base must be reachable by walking t_interface_parent*/  \
                        pfc::safe_cast<service_base*>(this); /*this class must derive from service_base, directly or indirectly, and be implictly castable to it*/ \
                }
Helper macro for use when defining a service class. Generates standard features of a service, without ability to register using service_factory / enumerate using service_enum_t.
This is used for declaring services that are meant to be instantiated by means other than service_enum_t (or non-entrypoint services), or extensions of services (including extension of entrypoint services).
Sample non-entrypoint declaration: class myclass : public service_base {...; FB2K_MAKE_SERVICE_INTERFACE(myclass, service_base); };
Sample extension declaration: class myclass : public myotherclass {...; FB2K_MAKE_SERVICE_INTERFACE(myclass, myotherclass); };
This macro is intended for use ONLY WITH INTERFACE CLASSES, not with implementation classes.

#define FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT ( THISCLASS   ) 

Value:

public: \
                typedef THISCLASS t_interface_entrypoint;       \
        FB2K_MAKE_SERVICE_INTERFACE(THISCLASS,service_base)
Helper macro for use when defining an entrypoint service class. Generates standard features of a service, including ability to register using service_factory and enumerate using service_enum.
Sample declaration: class myclass : public service_base {...; FB2K_MAKE_SERVICE_INTERFACE_ENTRYPOINT(myclass); };
Note that entrypoint service classes must directly derive from service_base, and not from another service class. This macro is intended for use ONLY WITH INTERFACE CLASSES, not with implementation classes.

#define FOOGUIDDECL


Typedef Documentation

typedef const void* service_class_ref


Function Documentation

template<typename T>
static void __validate_service_class_helper (  )  [inline, static]

template<>
static void __validate_service_class_helper< service_base > (  )  [inline, static]

template<typename T>
static service_class_ref _service_find_class (  )  [inline, static]

template<typename what>
static bool _service_instantiate_helper ( service_ptr_t< what > &  out,
service_class_ref  servClass,
t_size  index 
) [inline, static]

void _standard_api_create_internal ( service_ptr out,
const GUID &  classID 
)

template<typename T>
static void _validate_service_ptr ( service_ptr_t< T > const &  ptr  )  [inline, static]

PFC_DECLARE_EXCEPTION ( exception_service_duplicated  ,
pfc::exception  ,
"Service duplicated"   
)

PFC_DECLARE_EXCEPTION ( exception_service_extension_not_found  ,
pfc::exception  ,
"Service extension not found"   
)

PFC_DECLARE_EXCEPTION ( exception_service_not_found  ,
pfc::exception  ,
"Service not found"   
)

template<typename T>
static void service_add_ref_safe ( T *  p_ptr  )  throw () [inline, static]

template<typename what>
static service_ptr_t<what> service_by_guid ( const GUID &  id  )  [inline, static]

template<typename what>
static bool service_by_guid ( service_ptr_t< what > &  out,
const GUID &  id 
) [inline, static]

template<typename what>
static bool service_by_guid_fallback ( service_ptr_t< what > &  out,
const GUID &  id 
) [inline, static]

template<typename what>
static void service_by_guid_init (  )  [inline, static]

template<class T>
static bool service_enum_create_t ( service_ptr_t< T > &  p_out,
t_size  p_index 
) [inline, static]

template<typename T>
static service_obscure_refcounting<T>* service_obscure_refcounting_cast ( T *  p_source  )  throw () [inline, static]

Converts a service interface pointer to a pointer that obscures service counter functionality.

template<typename T>
static void service_release_safe ( T *  p_ptr  )  throw () [inline, static]

template<typename T>
static service_ptr_t<T> standard_api_create_t (  )  [inline, static]

template<typename T>
static void standard_api_create_t ( service_ptr_t< T > &  p_out  )  [inline, static]

template<typename T>
static bool static_api_test_t (  )  [inline, static]


Generated on Fri Apr 25 18:49:38 2008 for foobar2000 SDK by  doxygen 1.5.5