ctkLogEntry.h 4.8 KB

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