ctkLogEntry.h 5.0 KB

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