ctkServiceRegistrationPrivate.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) 2010 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 CTKSERVICEREGISTRATIONPRIVATE_H
  16. #define CTKSERVICEREGISTRATIONPRIVATE_H
  17. #include <QHash>
  18. #include <QMutex>
  19. #include "ctkServiceReference.h"
  20. class ctkPluginPrivate;
  21. class ctkServiceRegistration;
  22. class ctkServiceRegistrationPrivate
  23. {
  24. protected:
  25. ctkServiceRegistration* const q_ptr;
  26. /**
  27. * Service or ctkServiceFactory object.
  28. */
  29. QObject* service;
  30. public:
  31. Q_DECLARE_PUBLIC(ctkServiceRegistration);
  32. /**
  33. * Plugin registering this service.
  34. */
  35. ctkPluginPrivate* plugin;
  36. /**
  37. * Reference object to this service registration.
  38. */
  39. ctkServiceReference* reference;
  40. /**
  41. * Service properties.
  42. */
  43. ServiceProperties properties;
  44. /**
  45. * Plugins dependent on this service. Integer is used as
  46. * reference counter, counting number of unbalanced getService().
  47. */
  48. QHash<ctkPlugin*,int> dependents;
  49. /**
  50. * Object instances that factory has produced.
  51. */
  52. QHash<ctkPlugin*, QObject*> serviceInstances;
  53. /**
  54. * Is service available. I.e., if <code>true</code> then holders
  55. * of a ctkServiceReference for the service are allowed to get it.
  56. */
  57. volatile bool available;
  58. /**
  59. * Avoid recursive unregistrations. I.e., if <code>true</code> then
  60. * unregistration of this service has started but is not yet
  61. * finished.
  62. */
  63. volatile bool unregistering;
  64. /**
  65. * Lock object for synchronous event delivery.
  66. */
  67. QMutex eventLock;
  68. QMutex propsLock;
  69. ctkServiceRegistrationPrivate(ctkServiceRegistration* sr, ctkPluginPrivate* plugin, QObject* service,
  70. const ServiceProperties& props);
  71. virtual ~ctkServiceRegistrationPrivate();
  72. /**
  73. * Check if a plugin uses this service
  74. *
  75. * @param p Plugin to check
  76. * @return true if plugin uses this service
  77. */
  78. bool isUsedByPlugin(ctkPlugin* p);
  79. virtual QObject* getService();
  80. };
  81. #endif // CTKSERVICEREGISTRATIONPRIVATE_H