ctkLogReaderService.h 3.6 KB

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