ctkLogReaderService.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 CTKLOGREADERSERVICE_H
  16. #define CTKLOGREADERSERVICE_H
  17. #include <QList>
  18. #include "ctkLogEntry.h"
  19. /**
  20. * \ingroup LogService
  21. *
  22. * Provides methods to retrieve <code>ctkLogEntry</code> objects from the log.
  23. * <p>
  24. * There are three ways to retrieve <code>ctkLogEntry</code> objects:
  25. * <ul>
  26. * <li>The primary way to retrieve <code>ctkLogEntry</code> objects is to register a
  27. * <code>ctkLogListener</code> object with the service registry whose
  28. * <code>ctkLogListener#logged()</code> method will
  29. * be called for each entry added to the log. This way you do not need to retrieve
  30. * any service object to express an interest in log entries.
  31. * <li>A Qt slot can be connected to the <code>ctkLogReaderService</code> by using
  32. * <code>connectLogListener()</code>.
  33. * <li>To retrieve past <code>ctkLogEntry</code> objects, the <code>getLog()</code>
  34. * method can be called which will return a QList of all
  35. * <code>ctkLogEntry</code> objects in the log.
  36. *
  37. * @ThreadSafe
  38. * @see ctkLogEntry
  39. * @see ctkLogListener
  40. * @see ctkLogListener#logged(ctkLogEntryPtr)
  41. */
  42. struct ctkLogReaderService
  43. {
  44. virtual ~ctkLogReaderService() {}
  45. /**
  46. * Subscribes to <code>ctkLogEntry</code> objects.
  47. *
  48. * <p>
  49. * This method connects a Qt slot with the Log Reader
  50. * Service. The slot must take a <code>ctkLogEntryPtr</code> as the
  51. * only argument and will be
  52. * called for each <code>ctkLogEntry</code> object placed into the log.
  53. *
  54. * <p>
  55. * When a plugin which connects a Qt slot is stopped, the Log Reader
  56. * Service must disconnect all of the plugin's connected slots.
  57. *
  58. * <p>
  59. * If the same slot from the same object is already connected, this
  60. * method does nothing.
  61. *
  62. * @param receiver The object to connect to.
  63. * @param slot The name of the slot to be connected.
  64. * @returns <code>true</code> if the connection was successfull;
  65. * <code>false</code> otherwise.
  66. * @see ctkLogListener
  67. * @see ctkLogEntry
  68. * @see ctkLogListener#logged(ctkLogEntryPtr)
  69. */
  70. virtual bool connectLogListener(const QObject* receiver, const char* slot) = 0;
  71. /**
  72. * Returns a QList of all <code>ctkLogEntry</code> objects in
  73. * the log.
  74. *
  75. * <p>
  76. * Each element of the QList is a <code>ctkLogEntry</code> object, ordered
  77. * with the most recent entry first. Whether the list is of all
  78. * <code>ctkLogEntry</code> objects since the Log Service was started or some
  79. * recent past is implementation-specific. Also implementation-specific is
  80. * whether informational and debug <code>ctkLogEntry</code> objects are included
  81. * in the list.
  82. * @return A QList of all <code>ctkLogEntry</code> objects in
  83. * the log.
  84. */
  85. virtual QList<ctkLogEntryPtr> getLog() = 0;
  86. };
  87. Q_DECLARE_INTERFACE(ctkLogReaderService, "org.commontk.service.log.LogReaderService")
  88. #endif // CTKLOGREADERSERVICE_H