ctkApplicationDescriptor.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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 CTKAPPLICATIONDESCRIPTOR_H
  16. #define CTKAPPLICATIONDESCRIPTOR_H
  17. #include <ctkPluginFrameworkExport.h>
  18. #include <ctkPluginFramework_global.h>
  19. #include <QHash>
  20. #include <QVariant>
  21. #include <QString>
  22. #include <QLocale>
  23. struct ctkApplicationHandle;
  24. /**
  25. * A service that represents an installed application and stores
  26. * information about it. The application descriptor can be used for instance
  27. * creation.
  28. */
  29. struct CTK_PLUGINFW_EXPORT ctkApplicationDescriptor
  30. {
  31. /**
  32. * The property key for the localized name of the application.
  33. */
  34. static const QString APPLICATION_NAME; // = "application.name";
  35. /**
  36. * The property key for the localized icon of the application.
  37. */
  38. static const QString APPLICATION_ICON; // = "application.icon";
  39. /**
  40. * The property key for the unique identifier (PID) of the application.
  41. */
  42. static const QString APPLICATION_PID; // = ctkPluginConstants::SERVICE_PID;
  43. /**
  44. * The property key for the version of the application.
  45. */
  46. static const QString APPLICATION_VERSION; // = "application.version";
  47. /**
  48. * The property key for the name of the application vendor.
  49. */
  50. static const QString APPLICATION_VENDOR; // = ctkPluginConstants::SERVICE_VENDOR;
  51. /**
  52. * The property key for the visibility property of the application.
  53. */
  54. static const QString APPLICATION_VISIBLE; // = "application.visible";
  55. /**
  56. * The property key for the launchable property of the application.
  57. */
  58. static const QString APPLICATION_LAUNCHABLE; // = "application.launchable";
  59. /**
  60. * The property key for the locked property of the application.
  61. */
  62. static const QString APPLICATION_LOCKED; // = "application.locked";
  63. /**
  64. * The property key for the localized description of the application.
  65. */
  66. static const QString APPLICATION_DESCRIPTION; // = "application.description";
  67. /**
  68. * The property key for the localized documentation of the application.
  69. */
  70. static const QString APPLICATION_DOCUMENTATION; // = "application.documentation";
  71. /**
  72. * The property key for the localized copyright notice of the application.
  73. */
  74. static const QString APPLICATION_COPYRIGHT; // = "application.copyright";
  75. /**
  76. * The property key for the localized license of the application.
  77. */
  78. static const QString APPLICATION_LICENSE; // = "application.license";
  79. /**
  80. * The property key for the application container of the application.
  81. */
  82. static const QString APPLICATION_CONTAINER; // = "application.container";
  83. /**
  84. * The property key for the location of the application.
  85. */
  86. static const QString APPLICATION_LOCATION; // = "application.location";
  87. virtual ~ctkApplicationDescriptor() {}
  88. /**
  89. * Returns the identifier of the represented application.
  90. *
  91. * @return the identifier of the represented application
  92. */
  93. virtual QString getApplicationId() const = 0;
  94. /**
  95. * Returns the properties of the application descriptor as key-value pairs.
  96. * The return value contains the locale aware and unaware properties as
  97. * well. The returned <code>QHash</code> will include the service
  98. * properties of this <code>ctkApplicationDescriptor</code> as well.
  99. * <p>
  100. * The returned <code>QHash</code> will contain the standard CTK service
  101. * properties as well
  102. * (e.g. service.id, service.vendor etc.) and specialized application
  103. * descriptors may offer further service properties. The returned Map contains
  104. * a snapshot of the properties. It will not reflect further changes in the
  105. * property values nor will the update of the Map change the corresponding
  106. * service property.
  107. *
  108. * @param locale
  109. * the locale, defaults to the default constructed <code>QLocale()</code>.
  110. *
  111. * @return copy of the service properties of this application descriptor service,
  112. * according to the specified locale.
  113. *
  114. * @throws ctkIllegalStateException
  115. * if the application descriptor is unregistered
  116. */
  117. virtual ctkProperties getProperties(const QLocale& locale) const = 0;
  118. /**
  119. * Returns the properties of the application descriptor as key-value pairs.
  120. * The return value contains the raw (non-localized) property values.
  121. * The returned <code>QHash</code> will include the service
  122. * properties of this <code>ctkApplicationDescriptor</code> as well.
  123. * <p>
  124. * The returned <code>QHash</code> will contain the standard CTK service
  125. * properties as well
  126. * (e.g. service.id, service.vendor etc.) and specialized application
  127. * descriptors may offer further service properties. The returned QHash contains
  128. * a snapshot of the properties. It will not reflect further changes in the
  129. * property values nor will the update of the Map change the corresponding
  130. * service property.
  131. *
  132. * @return copy of the non-localized service properties of this application
  133. * descriptor service.
  134. *
  135. * @throws ctkIllegalStateException
  136. * if the application descriptor is unregistered
  137. */
  138. virtual ctkProperties getProperties() const = 0;
  139. /**
  140. * Launches a new instance of an application. The <code>arguments</code> parameter
  141. * specifies the startup parameters for the instance to be launched, it may
  142. * be empty.
  143. * <p>
  144. * The following steps are made:
  145. * <ul>
  146. * <li>Check the locking state of the application. If locked then throw an
  147. * {@link ctkApplicationException} with the reason code
  148. * {@link ctkApplicationException#APPLICATION_LOCKED}.
  149. * <li>Create and start an application instance.
  150. * <li>Returns the <code>ctkApplicationHandle</code>.
  151. * </ul>
  152. * <p>
  153. * The <code>QHash</code> argument of the launch method contains startup arguments
  154. * for the application. The keys used in the QHash must be non-empty
  155. * <code>QString</code> objects. They can be standard or application specific.
  156. * CTK defines the <code>org.commontk.triggeringevent</code> key to be used to pass
  157. * the triggering event to a scheduled application, however in the future it
  158. * is possible that other well-known keys will be defined. To avoid unwanted
  159. * clashes of keys, the following rules should be applied:
  160. * <ul>
  161. * <li>The keys starting with the dash (-) character are application
  162. * specific, no well-known meaning should be associated with them.</li>
  163. * <li>Well-known keys should follow the reverse domain name based naming.
  164. * In particular, the keys standardized in CTK should start with
  165. * <code>org.commontk.</code>.</li>
  166. * </ul>
  167. * <P>
  168. * The method is synchronous, it returns only when the application instance
  169. * was successfully started or the attempt to start it failed.
  170. * <P>
  171. * This method never returns <code>null</code>. If launching an application
  172. * fails, the appropriate exception is thrown.
  173. *
  174. * @param arguments Arguments for the newly launched application, may be
  175. * null
  176. *
  177. * @return the registered ctkApplicationHandle, which represents the newly
  178. * launched application instance. Never returns <code>null</code>.
  179. *
  180. * @throws ctkApplicationException if starting the application failed
  181. * @throws ctkIllegalStateException if the application descriptor is
  182. * unregistered
  183. * @throws std::invalid_argument if the specified <code>QHash</code> contains
  184. * invalid keys (empty <code>QString</code>)
  185. */
  186. virtual ctkApplicationHandle* launch(const QHash<QString, QVariant>& arguments) = 0;
  187. };
  188. Q_DECLARE_INTERFACE(ctkApplicationDescriptor, "org.commontk.service.application.ApplicationDescriptor")
  189. #endif // CTKAPPLICATIONDESCRIPTOR_H