ctkConfigurationEvent.h 5.6 KB

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