component.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #include "main.h"
  2. #include "./component.h"
  3. #include "./deviceManagerFactory.h"
  4. static DeviceManagerFactory deviceManagerFactory;
  5. DevicesComponent::DevicesComponent()
  6. {
  7. InitializeCriticalSection(&lock);
  8. }
  9. DevicesComponent::~DevicesComponent()
  10. {
  11. EnterCriticalSection(&lock);
  12. ReleaseServices();
  13. LeaveCriticalSection(&lock);
  14. DeleteCriticalSection(&lock);
  15. }
  16. size_t DevicesComponent::AddRef()
  17. {
  18. return 1;
  19. }
  20. size_t DevicesComponent::Release()
  21. {
  22. return 1;
  23. }
  24. int DevicesComponent::QueryInterface(GUID interface_guid, void **object)
  25. {
  26. if (NULL == object)
  27. return E_POINTER;
  28. *object = NULL;
  29. return E_NOINTERFACE;
  30. }
  31. void DevicesComponent::RegisterServices(api_service *service)
  32. {
  33. EnterCriticalSection(&lock);
  34. deviceManagerFactory.Register(service);
  35. LeaveCriticalSection(&lock);
  36. aTRACE_LINE("Devices Service Registered");
  37. }
  38. int DevicesComponent::RegisterServicesSafeModeOk()
  39. {
  40. return 1;
  41. }
  42. void DevicesComponent::DeregisterServices(api_service *service)
  43. {
  44. EnterCriticalSection(&lock);
  45. deviceManagerFactory.Unregister(service);
  46. ReleaseServices();
  47. LeaveCriticalSection(&lock);
  48. aTRACE_LINE("Devices Service Unregistered");
  49. }
  50. void DevicesComponent::ReleaseServices()
  51. {
  52. }
  53. #define CBCLASS DevicesComponent
  54. START_DISPATCH;
  55. CB(ADDREF, AddRef)
  56. CB(RELEASE, Release)
  57. CB(QUERYINTERFACE, QueryInterface)
  58. VCB(API_WA5COMPONENT_REGISTERSERVICES, RegisterServices)
  59. CB(15, RegisterServicesSafeModeOk)
  60. VCB(API_WA5COMPONENT_DEREEGISTERSERVICES, DeregisterServices)
  61. END_DISPATCH;
  62. #undef CBCLASS