api_service.h 6.6 KB

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