diff options
author | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
---|---|---|
committer | Jef <jef@targetspot.com> | 2024-09-24 08:54:57 -0400 |
commit | 20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch) | |
tree | 12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Wasabi/api/service/svcenumbyguid.h | |
parent | 537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff) | |
download | winamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz |
Initial community commit
Diffstat (limited to 'Src/Wasabi/api/service/svcenumbyguid.h')
-rw-r--r-- | Src/Wasabi/api/service/svcenumbyguid.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Src/Wasabi/api/service/svcenumbyguid.h b/Src/Wasabi/api/service/svcenumbyguid.h new file mode 100644 index 00000000..412523c3 --- /dev/null +++ b/Src/Wasabi/api/service/svcenumbyguid.h @@ -0,0 +1,37 @@ +#ifndef _SVCENUMBYGUID_H +#define _SVCENUMBYGUID_H + +/*<?<autoheader/>*/ +/*?>*/ + +#include "svc_enum.h" + +/* + * this is a helper class to fetch a service * by GUID + * usage: svc_something *svc = SvcEnumByGuid<svc_something>(svcguid); + * @short: Helper class to fetch unique service by GUID +*/ +template <class SERVICETYPE> +class SvcEnumByGuid { +public: +/** +@param _guid The GUID of the service factory to fetch the service from. +*/ + SvcEnumByGuid() : guid(SERVICETYPE::getServiceGuid()) {} + SvcEnumByGuid(GUID _guid) : guid(_guid) {} + +/** +@return The pointer to the service. +*/ + SERVICETYPE *getInterface() { + waServiceFactory *svc = WASABI_API_SVC->service_getServiceByGuid(guid); + return castService<SERVICETYPE>(svc); + } + + operator SERVICETYPE *() { return getInterface(); } + +private: + GUID guid; +}; + +#endif // _SVCENUMBYGUID_H |