1
0

svcenumbyguid.h 838 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #ifndef _SVCENUMBYGUID_H
  2. #define _SVCENUMBYGUID_H
  3. /*<?<autoheader/>*/
  4. /*?>*/
  5. #include "svc_enum.h"
  6. /*
  7. * this is a helper class to fetch a service * by GUID
  8. * usage: svc_something *svc = SvcEnumByGuid<svc_something>(svcguid);
  9. * @short: Helper class to fetch unique service by GUID
  10. */
  11. template <class SERVICETYPE>
  12. class SvcEnumByGuid {
  13. public:
  14. /**
  15. @param _guid The GUID of the service factory to fetch the service from.
  16. */
  17. SvcEnumByGuid() : guid(SERVICETYPE::getServiceGuid()) {}
  18. SvcEnumByGuid(GUID _guid) : guid(_guid) {}
  19. /**
  20. @return The pointer to the service.
  21. */
  22. SERVICETYPE *getInterface() {
  23. waServiceFactory *svc = WASABI_API_SVC->service_getServiceByGuid(guid);
  24. return castService<SERVICETYPE>(svc);
  25. }
  26. operator SERVICETYPE *() { return getInterface(); }
  27. private:
  28. GUID guid;
  29. };
  30. #endif // _SVCENUMBYGUID_H