utilityFactory.cpp 1.8 KB

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