ctkManagedServiceFactoryTracker_p.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #ifndef CTKMANAGEDSERVICEFACTORYTRACKER_P_H
  16. #define CTKMANAGEDSERVICEFACTORYTRACKER_P_H
  17. #include <ctkServiceTracker.h>
  18. #include <service/cm/ctkManagedServiceFactory.h>
  19. #include "ctkCMSerializedTaskQueue_p.h"
  20. class ctkConfigurationAdminFactory;
  21. class ctkConfigurationStore;
  22. class ctkConfigurationImpl;
  23. /**
  24. * ctkManagedServiceFactoryTracker tracks... ManagedServiceFactory(s) and notifies them about related configuration changes
  25. */
  26. class ctkManagedServiceFactoryTracker : public ctkServiceTracker<ctkManagedServiceFactory*>
  27. {
  28. public:
  29. ctkManagedServiceFactoryTracker(ctkConfigurationAdminFactory* configurationAdminFactory,
  30. ctkConfigurationStore* configurationStore,
  31. ctkPluginContext* context);
  32. ctkManagedServiceFactory* addingService(const ctkServiceReference& reference);
  33. void modifiedService(const ctkServiceReference& reference, ctkManagedServiceFactory* service);
  34. void removedService(const ctkServiceReference& reference, ctkManagedServiceFactory* service);
  35. void notifyDeleted(ctkConfigurationImpl* config);
  36. void notifyUpdated(ctkConfigurationImpl* config);
  37. private:
  38. ctkPluginContext* context;
  39. ctkConfigurationAdminFactory* configurationAdminFactory;
  40. QMutex configurationStoreMutex;
  41. ctkConfigurationStore* configurationStore;
  42. // managedServiceFactoryMutex guards both managedServiceFactories and managedServiceFactoryReferences
  43. mutable QMutex managedServiceFactoryMutex;
  44. QHash<QString, ctkManagedServiceFactory*> managedServiceFactories;
  45. QHash<QString, ctkServiceReference> managedServiceFactoryReferences;
  46. ctkCMSerializedTaskQueue queue;
  47. void addManagedServiceFactory(const ctkServiceReference& reference,
  48. const QString& factoryPid,
  49. ctkManagedServiceFactory* service);
  50. void removeManagedServiceFactory(const ctkServiceReference& reference,
  51. const QString& factoryPid);
  52. bool trackManagedServiceFactory(const QString& factoryPid,
  53. const ctkServiceReference& reference,
  54. ctkManagedServiceFactory* service);
  55. void untrackManagedServiceFactory(const QString& factoryPid,
  56. const ctkServiceReference& reference);
  57. ctkManagedServiceFactory* getManagedServiceFactory(const QString& factoryPid) const;
  58. ctkServiceReference getManagedServiceFactoryReference(const QString& factoryPid) const;
  59. QString getPidForManagedServiceFactory(ctkManagedServiceFactory* service) const;
  60. void asynchDeleted(ctkManagedServiceFactory* service, const QString& pid);
  61. void asynchUpdated(ctkManagedServiceFactory* service, const QString& pid,
  62. const ctkDictionary& properties);
  63. };
  64. #endif // CTKMANAGEDSERVICEFACTORYTRACKER_P_H