serviceFactory.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #include "./serviceFactory.h"
  2. #include "./serviceManager.h"
  3. OmServiceFactory::OmServiceFactory()
  4. : object(NULL)
  5. {
  6. }
  7. OmServiceFactory::~OmServiceFactory()
  8. {
  9. if (NULL != object)
  10. object->Release();
  11. }
  12. FOURCC OmServiceFactory::GetServiceType()
  13. {
  14. return WaSvc::UNIQUE;
  15. }
  16. const char *OmServiceFactory::GetServiceName()
  17. {
  18. return "OmServiceManager Interface";
  19. }
  20. GUID OmServiceFactory::GetGUID()
  21. {
  22. return IFC_OmServiceManager;
  23. }
  24. void *OmServiceFactory::GetInterface(int global_lock)
  25. {
  26. if (NULL == object)
  27. {
  28. object = OmServiceManager::CreateInstance();
  29. if (NULL == object) return NULL;
  30. }
  31. object->AddRef();
  32. return object;
  33. }
  34. int OmServiceFactory::SupportNonLockingInterface()
  35. {
  36. return 1;
  37. }
  38. int OmServiceFactory::ReleaseInterface(void *ifc)
  39. {
  40. OmServiceManager *object = (OmServiceManager*)ifc;
  41. if (NULL != object) object->Release();
  42. return 1;
  43. }
  44. const char *OmServiceFactory::GetTestString()
  45. {
  46. return NULL;
  47. }
  48. int OmServiceFactory::ServiceNotify(int msg, int param1, int param2)
  49. {
  50. return 1;
  51. }
  52. HRESULT OmServiceFactory::Register(api_service *service)
  53. {
  54. if (NULL == service) return E_INVALIDARG;
  55. service->service_register(this);
  56. return S_OK;
  57. }
  58. HRESULT OmServiceFactory::Unregister(api_service *service)
  59. {
  60. if (NULL == service) return E_INVALIDARG;
  61. service->service_deregister(this);
  62. return S_OK;
  63. }
  64. #define CBCLASS OmServiceFactory
  65. START_DISPATCH;
  66. CB(WASERVICEFACTORY_GETSERVICETYPE, GetServiceType)
  67. CB(WASERVICEFACTORY_GETSERVICENAME, GetServiceName)
  68. CB(WASERVICEFACTORY_GETGUID, GetGUID)
  69. CB(WASERVICEFACTORY_GETINTERFACE, GetInterface)
  70. CB(WASERVICEFACTORY_SUPPORTNONLOCKINGGETINTERFACE, SupportNonLockingInterface)
  71. CB(WASERVICEFACTORY_RELEASEINTERFACE, ReleaseInterface)
  72. CB(WASERVICEFACTORY_GETTESTSTRING, GetTestString)
  73. CB(WASERVICEFACTORY_SERVICENOTIFY, ServiceNotify)
  74. END_DISPATCH;
  75. #undef CBCLASS