ctkConfigurationEvent.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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 CTKCONFIGURATIONEVENT_H
  16. #define CTKCONFIGURATIONEVENT_H
  17. #include <QSharedDataPointer>
  18. #include <QDebug>
  19. #include "ctkServiceReference.h"
  20. class ctkConfigurationEventData;
  21. /**
  22. * A Configuration Event.
  23. *
  24. * <p>
  25. * {@code ctkConfigurationEvent} objects are delivered to all registered
  26. * {@code ctkConfigurationListener} service objects. ctkConfigurationEvents
  27. * must be asynchronously delivered in chronological order with respect to each
  28. * listener.
  29. *
  30. * <p>
  31. * An enum type is used to identify the type of event. The following event types
  32. * are defined:
  33. * <ul>
  34. * <li>{@link #CM_UPDATED}
  35. * <li>{@link #CM_DELETED}
  36. * </ul>
  37. * Additional event types may be defined in the future.
  38. *
  39. * <p>
  40. * Security Considerations. {@code ctkConfigurationEvent} objects do not
  41. * provide {@code ctkConfiguration} objects, so no sensitive configuration
  42. * information is available from the event. If the listener wants to locate the
  43. * {@code ctkConfiguration} object for the specified pid, it must use
  44. * {@code ctkConfigurationAdmin}.
  45. *
  46. * @see ctkConfigurationListener
  47. */
  48. class CTK_PLUGINFW_EXPORT ctkConfigurationEvent
  49. {
  50. QSharedDataPointer<ctkConfigurationEventData> d;
  51. public:
  52. enum Type {
  53. /**
  54. * A {@code ctkConfiguration} has been updated.
  55. *
  56. * <p>
  57. * This {@code ctkConfigurationEvent} type indicates that a
  58. {@code ctkConfiguration} object has been updated with new properties.
  59. *
  60. * An event is fired when a call to {@link ctkConfiguration#update(const ctkDictionary&)}
  61. * successfully changes a configuration.
  62. *
  63. * <p>
  64. * The value of {@code CM_UPDATED} is 1.
  65. */
  66. CM_UPDATED = 0x00000001,
  67. /**
  68. * A {@code ctkConfiguration} has been deleted.
  69. *
  70. * <p>
  71. * This {@code ctkConfigurationEvent} type indicates that a
  72. * {@code ctkConfiguration} object has been deleted.
  73. *
  74. * An event is fired when a call to {@link ctkConfiguration#remove()}
  75. * successfully deletes a configuration.
  76. *
  77. * <p>
  78. * The value of {@code CM_DELETED} is 2.
  79. */
  80. CM_DELETED = 0x00000002
  81. };
  82. /**
  83. * Default constructor for use with the Qt meta object system.
  84. */
  85. ctkConfigurationEvent();
  86. ~ctkConfigurationEvent();
  87. /**
  88. * Can be used to check if this ctkConfigurationEvent instance is valid,
  89. * or if it has been constructed using the default constructor.
  90. *
  91. * @return <code>true</code> if this event object is valid,
  92. * <code>false</code> otherwise.
  93. */
  94. bool isNull() const;
  95. /**
  96. * Constructs a {@code ConfigurationEvent} object from the given
  97. * {@code ServiceReference} object, event type, and pids.
  98. *
  99. * @param reference The {@code ServiceReference} object of the
  100. * Configuration Admin service that created this event.
  101. * @param type The event type. See {@link #getType}.
  102. * @param factoryPid The factory pid of the associated configuration if the
  103. * target of the configuration is a ManagedServiceFactory. Otherwise
  104. * {@code null} if the target of the configuration is a
  105. * ManagedService.
  106. * @param pid The pid of the associated configuration.
  107. */
  108. ctkConfigurationEvent(const ctkServiceReference& reference,
  109. Type type, const QString& factoryPid,
  110. const QString& pid);
  111. ctkConfigurationEvent(const ctkConfigurationEvent& other);
  112. ctkConfigurationEvent& operator=(const ctkConfigurationEvent& other);
  113. /**
  114. * Returns the factory pid of the associated configuration.
  115. *
  116. * @return Returns the factory pid of the associated configuration if the
  117. * target of the configuration is a ctkManagedServiceFactory. Otherwise
  118. * an invalid string if the target of the configuration is a
  119. * ctkManagedService.
  120. */
  121. QString getFactoryPid() const;
  122. /**
  123. * Returns the pid of the associated configuration.
  124. *
  125. * @return Returns the pid of the associated configuration.
  126. */
  127. QString getPid() const;
  128. /**
  129. * Return the type of this event.
  130. * <p>
  131. * The type values are:
  132. * <ul>
  133. * <li>{@link #CM_UPDATED}
  134. * <li>{@link #CM_DELETED}
  135. * </ul>
  136. *
  137. * @return The type of this event.
  138. */
  139. int getType() const;
  140. /**
  141. * Return the {@code ctkServiceReference} object of the Configuration
  142. * Admin service that created this event.
  143. *
  144. * @return The {@code ctkServiceReference} object for the Configuration
  145. * Admin service that created this event.
  146. */
  147. ctkServiceReference getReference() const;
  148. };
  149. CTK_PLUGINFW_EXPORT QDebug operator<<(QDebug dbg, ctkConfigurationEvent::Type type);
  150. CTK_PLUGINFW_EXPORT QDebug operator<<(QDebug dbg, const ctkConfigurationEvent& event);
  151. #endif // CTKCONFIGURATIONEVENT_H