deviceManagerFactory.cpp 2.0 KB

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