ctkLogEntry.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 CTKLOGENTRY_H
  16. #define CTKLOGENTRY_H
  17. #include <QSharedPointer>
  18. #include <QDateTime>
  19. #include <QMetaType>
  20. #include <ctkServiceReference.h>
  21. class ctkRuntimeException;
  22. /**
  23. * \ingroup LogService
  24. *
  25. * Provides methods to access the information contained in an individual Log
  26. * Service log entry.
  27. *
  28. * <p>
  29. * A <code>ctkLogEntry</code> object may be acquired from the
  30. * <code>ctkLogReaderService#getLog()</code> method or by registering a
  31. * <code>ctkLogListener</code> object.
  32. *
  33. * @remarks This class is thread safe.
  34. * @see ctkLogReaderService#getLog()
  35. * @see ctkLogListener
  36. */
  37. struct ctkLogEntry
  38. {
  39. virtual ~ctkLogEntry() {}
  40. /**
  41. * Returns the plugin that created this <code>ctkLogEntry</code> object.
  42. *
  43. * @return The plugin that created this <code>ctkLogEntry</code> object;
  44. * null if no plugins is associated with this
  45. * <code>ctkLogEntry</code> object.
  46. */
  47. virtual QSharedPointer<ctkPlugin> getPlugin() const = 0;
  48. /**
  49. * Returns the <code>ctkServiceReference</code> object for the service associated
  50. * with this <code>ctkLogEntry</code> object.
  51. *
  52. * @return <code>ctkServiceReference</code> object for the service associated
  53. * with this <code>ctkLogEntry</code> object; A default constructed object if no
  54. * <code>ctkServiceReference</code> object was provided.
  55. */
  56. virtual ctkServiceReference getServiceReference() const = 0;
  57. /**
  58. * Returns the severity level of this <code>ctkLogEntry</code> object.
  59. *
  60. * <p>
  61. * This is one of the severity levels defined by the <code>ctkLogService</code>
  62. * interface.
  63. *
  64. * @return Severity level of this <code>ctkLogEntry</code> object.
  65. *
  66. * @see ctkLogService#LOG_ERROR
  67. * @see ctkLogService#LOG_WARNING
  68. * @see ctkLogService#LOG_INFO
  69. * @see ctkLogService#LOG_DEBUG
  70. */
  71. virtual int getLevel() const = 0;
  72. /**
  73. * Returns the human readable message associated with this <code>ctkLogEntry</code>
  74. * object.
  75. *
  76. * @return <code>QString</code> containing the message associated with this
  77. * <code>ctkLogEntry</code> object.
  78. */
  79. virtual QString getMessage() const = 0;
  80. /**
  81. * Returns the absolute file name of the source file with which this
  82. * <code>ctkLogEntry</code> is associated.
  83. *
  84. * @return The source file name or an empty string if no information
  85. * about the file name is available.
  86. */
  87. virtual QString getFileName() const = 0;
  88. /**
  89. * Returns the function name of the calling function with which this
  90. * <code>ctkLogEntry</code> is associated.
  91. *
  92. * @return The function name or an empty string if no information
  93. * about the function is available.
  94. */
  95. virtual QString getFunctionName() const = 0;
  96. /**
  97. * Returns the line number in the source file with which this
  98. * <code>ctkLogEntry</code> is associated.
  99. *
  100. * @return The line number (a positive integer) or 0 if no information
  101. * about the line number is available.
  102. */
  103. virtual int getLineNumber() const = 0;
  104. /**
  105. * Returns the exception object associated with this <code>ctkLogEntry</code>
  106. * object.
  107. *
  108. * <p>
  109. * In some implementations, the returned exception may not be the original
  110. * exception. For example, STL exceptions associated with log entries may be wrapped
  111. * in a derived ctkRuntimeException. The returned object will attempt to provide as much
  112. * information as possible from the original exception object.
  113. *
  114. * @return <code>ctkRuntimeException</code> object of the exception associated with this
  115. * <code>ctkLogEntry</code>; <code>null</code> if no exception is
  116. * associated with this <code>ctkLogEntry</code> object.
  117. */
  118. virtual ctkRuntimeException* getException() const = 0;
  119. /**
  120. * Returns the value of <code>QDateTime::currentDateTime()</code> at the time this
  121. * <code>ctkLogEntry</code> object was created.
  122. *
  123. * @return The system time when this <code>ctkLogEntry</code>
  124. * object was created.
  125. * @see "QDateTime::currentDateTime()"
  126. */
  127. virtual QDateTime getTime() const = 0;
  128. };
  129. /**
  130. * \ingroup LogService
  131. * @{
  132. */
  133. typedef QSharedPointer<ctkLogEntry> ctkLogEntryPtr;
  134. Q_DECLARE_METATYPE(ctkLogEntryPtr)
  135. /** @}*/
  136. #endif // CTKLOGENTRY_H