api_service.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. // ----------------------------------------------------------------------------
  2. // Generated by InterfaceFactory [Wed May 07 00:56:11 2003]
  3. //
  4. // File : api_service.h
  5. // Class : api_service
  6. // class layer : Dispatchable Interface
  7. // ----------------------------------------------------------------------------
  8. #ifndef __API_SERVICE_H
  9. #define __API_SERVICE_H
  10. #include "../../bfc/dispatch.h"
  11. #include "../../bfc/platform/types.h"
  12. namespace SvcNotify {
  13. enum {
  14. ONREGISTERED=100, // init yourself here -- not all other services are registered yet
  15. ONSTARTUP=200, // everyone is initialized, safe to talk to other services
  16. ONAPPRUNNING=210, // app is showing and processing events
  17. ONSHUTDOWN=300, // studio is shutting down, release resources from other services
  18. ONDEREGISTERED=400, // bye bye
  19. ONDBREADCOMPLETE=500,// after db is read in (happens asynchronously after ONSTARTUP)
  20. ONBEFORESHUTDOWN=600, // system is about to shutdown, call WASABI_API_APP->main_cancelShutdown() to cancel
  21. };
  22. }
  23. class waServiceFactory;
  24. // ----------------------------------------------------------------------------
  25. class NOVTABLE api_service: public Dispatchable {
  26. protected:
  27. api_service() {}
  28. ~api_service() {}
  29. public:
  30. int service_register(waServiceFactory *svc);
  31. int service_deregister(waServiceFactory *svc);
  32. size_t service_getNumServices(FOURCC svc_type);
  33. waServiceFactory *service_enumService(FOURCC svc_type, size_t n);
  34. waServiceFactory *service_getServiceByGuid(GUID guid);
  35. int service_lock(waServiceFactory *owner, void *svcptr);
  36. int service_clientLock(void *svcptr);
  37. int service_release(void *svcptr);
  38. const char *service_getTypeName(FOURCC svc_type);
  39. #ifdef WASABI_COMPILE_COMPONENTS
  40. GUID service_getOwningComponent(void *svcptr);
  41. GUID service_getLockingComponent(void *svcptr);
  42. #endif // WASABI_COMPILE_COMPONENTS
  43. int service_unlock(void *svcptr);
  44. int service_isvalid(FOURCC svctype, waServiceFactory *service);
  45. // removes "me" from the services list and finds a second service with the same GUID and puts it in the same position
  46. // this is used by the lazy loader service factory - you shouldn't need it for any other purposes.
  47. // returns 0 if compaction actually happened
  48. int service_compactDuplicates(waServiceFactory *me);
  49. protected:
  50. enum {
  51. API_SERVICE_SERVICE_REGISTER = 10,
  52. API_SERVICE_SERVICE_DEREGISTER = 20,
  53. API_SERVICE_SERVICE_GETNUMSERVICES = 30,
  54. API_SERVICE_SERVICE_ENUMSERVICE = 40,
  55. API_SERVICE_SERVICE_GETSERVICEBYGUID = 50,
  56. API_SERVICE_SERVICE_LOCK = 60,
  57. API_SERVICE_SERVICE_CLIENTLOCK = 70,
  58. API_SERVICE_SERVICE_RELEASE = 80,
  59. API_SERVICE_SERVICE_GETTYPENAME = 90,
  60. #ifdef WASABI_COMPILE_COMPONENTS
  61. API_SERVICE_SERVICE_GETOWNINGCOMPONENT = 100,
  62. API_SERVICE_SERVICE_GETLOCKINGCOMPONENT = 110,
  63. #endif // WASABI_COMPILE_COMPONENTS
  64. API_SERVICE_SERVICE_UNLOCK = 120,
  65. API_SERVICE_ISVALID = 130,
  66. API_SERVICE_COMPACT_DUPLICATES = 140,
  67. };
  68. };
  69. // ----------------------------------------------------------------------------
  70. inline int api_service::service_register(waServiceFactory *svc) {
  71. int __retval = _call(API_SERVICE_SERVICE_REGISTER, (int)0, svc);
  72. return __retval;
  73. }
  74. inline int api_service::service_deregister(waServiceFactory *svc) {
  75. int __retval = _call(API_SERVICE_SERVICE_DEREGISTER, (int)0, svc);
  76. return __retval;
  77. }
  78. inline size_t api_service::service_getNumServices(FOURCC svc_type) {
  79. int __retval = _call(API_SERVICE_SERVICE_GETNUMSERVICES, (int)0, svc_type);
  80. return __retval;
  81. }
  82. inline waServiceFactory *api_service::service_enumService(FOURCC svc_type, size_t n) {
  83. waServiceFactory *__retval = _call(API_SERVICE_SERVICE_ENUMSERVICE, (waServiceFactory *)0, svc_type, n);
  84. return __retval;
  85. }
  86. inline waServiceFactory *api_service::service_getServiceByGuid(GUID guid) {
  87. waServiceFactory *__retval = _call(API_SERVICE_SERVICE_GETSERVICEBYGUID, (waServiceFactory *)0, guid);
  88. return __retval;
  89. }
  90. inline int api_service::service_lock(waServiceFactory *owner, void *svcptr) {
  91. int __retval = _call(API_SERVICE_SERVICE_LOCK, (int)0, owner, svcptr);
  92. return __retval;
  93. }
  94. inline int api_service::service_clientLock(void *svcptr) {
  95. int __retval = _call(API_SERVICE_SERVICE_CLIENTLOCK, (int)0, svcptr);
  96. return __retval;
  97. }
  98. inline int api_service::service_release(void *svcptr) {
  99. int __retval = _call(API_SERVICE_SERVICE_RELEASE, (int)0, svcptr);
  100. return __retval;
  101. }
  102. inline const char *api_service::service_getTypeName(FOURCC svc_type) {
  103. const char *__retval = _call(API_SERVICE_SERVICE_GETTYPENAME, (const char *)0, svc_type);
  104. return __retval;
  105. }
  106. #ifdef WASABI_COMPILE_COMPONENTS
  107. inline GUID api_service::service_getOwningComponent(void *svcptr) {
  108. GUID __retval = _call(API_SERVICE_SERVICE_GETOWNINGCOMPONENT, INVALID_GUID, svcptr);
  109. return __retval;
  110. }
  111. inline GUID api_service::service_getLockingComponent(void *svcptr) {
  112. GUID __retval = _call(API_SERVICE_SERVICE_GETLOCKINGCOMPONENT, INVALID_GUID, svcptr);
  113. return __retval;
  114. }
  115. #endif // WASABI_COMPILE_COMPONENTS
  116. inline int api_service::service_unlock(void *svcptr) {
  117. int __retval = _call(API_SERVICE_SERVICE_UNLOCK, (int)0, svcptr);
  118. return __retval;
  119. }
  120. inline int api_service::service_isvalid(FOURCC svctype, waServiceFactory *service) {
  121. int __retval = _call(API_SERVICE_ISVALID, (int)0, svctype, service);
  122. return __retval;
  123. }
  124. inline int api_service::service_compactDuplicates(waServiceFactory *me)
  125. {
  126. return _call(API_SERVICE_COMPACT_DUPLICATES, (int)1, me);
  127. }
  128. // ----------------------------------------------------------------------------
  129. extern api_service *serviceApi;
  130. #endif // __API_SERVICE_H