1
0

api.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "api__in_avi.h"
  2. #include "main.h"
  3. #include <api/service/waservicefactory.h>
  4. api_config *AGAVE_API_CONFIG = 0;
  5. api_application *WASABI_API_APP = 0;
  6. api_stats *AGAVE_API_STATS = 0;
  7. api_language *WASABI_API_LNG = 0;
  8. HINSTANCE WASABI_API_LNG_HINST = 0, WASABI_API_ORIG_HINST = 0;
  9. template <class api_T>
  10. void ServiceBuild(api_T *&api_t, GUID factoryGUID_t)
  11. {
  12. if (plugin.service)
  13. {
  14. waServiceFactory *factory = plugin.service->service_getServiceByGuid(factoryGUID_t);
  15. if (factory)
  16. api_t = reinterpret_cast<api_T *>( factory->getInterface() );
  17. }
  18. }
  19. template <class api_T>
  20. void ServiceRelease(api_T *api_t, GUID factoryGUID_t)
  21. {
  22. if (plugin.service && api_t)
  23. {
  24. waServiceFactory *factory = plugin.service->service_getServiceByGuid(factoryGUID_t);
  25. if (factory)
  26. factory->releaseInterface(api_t);
  27. }
  28. api_t = NULL;
  29. }
  30. void WasabiInit()
  31. {
  32. ServiceBuild(AGAVE_API_CONFIG, AgaveConfigGUID);
  33. ServiceBuild(WASABI_API_APP, applicationApiServiceGuid);
  34. ServiceBuild(AGAVE_API_STATS, AnonymousStatsGUID);
  35. ServiceBuild(WASABI_API_LNG, languageApiGUID);
  36. // need to have this initialised before we try to do anything with localisation features
  37. WASABI_API_START_LANG(plugin.hDllInstance,InAviLangGUID);
  38. }
  39. void WasabiQuit()
  40. {
  41. ServiceRelease(AGAVE_API_CONFIG, AgaveConfigGUID);
  42. ServiceRelease(WASABI_API_APP, applicationApiServiceGuid);
  43. ServiceRelease(AGAVE_API_STATS, AnonymousStatsGUID);
  44. ServiceRelease(WASABI_API_LNG, languageApiGUID);
  45. }