ctkManagedServiceTracker_p.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 CTKMANAGEDSERVICETRACKER_P_H
  16. #define CTKMANAGEDSERVICETRACKER_P_H
  17. #include <ctkServiceTracker.h>
  18. #include <service/cm/ctkManagedService.h>
  19. #include "ctkCMSerializedTaskQueue_p.h"
  20. class ctkConfigurationAdminFactory;
  21. class ctkConfigurationStore;
  22. class ctkConfigurationImpl;
  23. /**
  24. * ctkManagedServiceTracker tracks... ManagedServices and notifies them about related configuration changes
  25. */
  26. class ctkManagedServiceTracker : public ctkServiceTracker<ctkManagedService*>
  27. {
  28. public:
  29. ctkManagedServiceTracker(ctkConfigurationAdminFactory* configurationAdminFactory,
  30. ctkConfigurationStore* configurationStore,
  31. ctkPluginContext* context);
  32. ctkManagedService* addingService(const ctkServiceReference& reference);
  33. void modifiedService(const ctkServiceReference& reference, ctkManagedService* service);
  34. void removedService(const ctkServiceReference& reference, ctkManagedService* 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. // managedServiceMutex guards both managedServices and managedServiceReferences
  43. mutable QMutex managedServiceMutex;
  44. QHash<QString, ctkManagedService*> managedServices;
  45. QHash<QString, ctkServiceReference> managedServiceReferences;
  46. ctkCMSerializedTaskQueue queue;
  47. void addManagedService(const ctkServiceReference& reference, const QString& pid,
  48. ctkManagedService* service);
  49. void removeManagedService(const ctkServiceReference& reference, const QString& pid);
  50. bool trackManagedService(const QString& pid, const ctkServiceReference& reference,
  51. ctkManagedService* service);
  52. void untrackManagedService(const QString& pid, const ctkServiceReference& reference);
  53. ctkManagedService* getManagedService(const QString& pid) const;
  54. ctkServiceReference getManagedServiceReference(const QString& pid) const;
  55. QString getPidForManagedService(ctkManagedService* service) const;
  56. void asynchUpdated(ctkManagedService* service, const ctkDictionary& properties);
  57. };
  58. #endif // CTKMANAGEDSERVICETRACKER_P_H