ServiceBuilder.h 849 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #pragma once
  2. #ifndef NULLSOFT_UTILITY_SERVICE_BUILDER_H
  3. #define NULLSOFT_UTILITY_SERVICE_BUILDER_H
  4. #include <api/service/waservicefactoryi.h>
  5. #include <api/service/services.h>
  6. #ifndef WASABI_API_SVC
  7. #define WASABI_API_SVC serviceManager
  8. #endif
  9. template <class api_T>
  10. static void ServiceBuild(api_service *service, api_T *&api_t, GUID factoryGUID_t)
  11. {
  12. if (service)
  13. {
  14. waServiceFactory *factory = service->service_getServiceByGuid(factoryGUID_t);
  15. if (factory)
  16. {
  17. api_t = reinterpret_cast<api_T *>( factory->getInterface() );
  18. }
  19. }
  20. }
  21. template <class api_T>
  22. static void ServiceRelease(api_service *service, api_T *&api_t, GUID factoryGUID_t)
  23. {
  24. if (service && api_t)
  25. {
  26. waServiceFactory *factory = service->service_getServiceByGuid(factoryGUID_t);
  27. if (factory)
  28. {
  29. factory->releaseInterface(api_t);
  30. }
  31. }
  32. api_t = NULL;
  33. }
  34. #endif