ctkLogEntry.h 4.9 KB

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