Archived
1
0
This repository has been archived on 2024-10-17. You can view files and clone it, but cannot push or open issues or pull requests.
winamp/Src/Wasabi/api/service/svcenumbyguid.h

38 lines
838 B
C
Raw Normal View History

2024-09-24 12:54:57 +00:00
#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