ctkErrorLogAbstractMessageHandler.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. #ifndef CTKERRORLOGABSTRACTMESSAGEHANDLER_H
  15. #define CTKERRORLOGABSTRACTMESSAGEHANDLER_H
  16. // Qt includes
  17. #include <QObject>
  18. #include <QDateTime>
  19. // CTK includes
  20. #include "ctkCoreExport.h"
  21. #include "ctkErrorLogLevel.h"
  22. #include "ctkErrorLogTerminalOutput.h"
  23. //------------------------------------------------------------------------------
  24. class ctkErrorLogAbstractMessageHandlerPrivate;
  25. struct ctkErrorLogContext;
  26. //------------------------------------------------------------------------------
  27. /// \ingroup Core
  28. class CTK_CORE_EXPORT ctkErrorLogAbstractMessageHandler : public QObject
  29. {
  30. Q_OBJECT
  31. public:
  32. typedef QObject Superclass;
  33. /// Disabled by default.
  34. ctkErrorLogAbstractMessageHandler();
  35. virtual ~ctkErrorLogAbstractMessageHandler();
  36. virtual QString handlerName()const = 0;
  37. QString handlerPrettyName()const;
  38. bool enabled()const;
  39. void setEnabled(bool value);
  40. void handleMessage(const QString& threadId, ctkErrorLogLevel::LogLevel logLevel,
  41. const QString& origin, const ctkErrorLogContext& logContext,
  42. const QString &text);
  43. ctkErrorLogTerminalOutput* terminalOutput(ctkErrorLogTerminalOutput::TerminalOutput terminalOutputType)const;
  44. void setTerminalOutput(ctkErrorLogTerminalOutput::TerminalOutput terminalOutputType,
  45. ctkErrorLogTerminalOutput * terminalOutput);
  46. Q_SIGNALS:
  47. void messageHandled(const QDateTime& currentDateTime, const QString& threadId,
  48. ctkErrorLogLevel::LogLevel logLevel, const QString& origin,
  49. const ctkErrorLogContext& logContext, const QString& text);
  50. protected:
  51. void setHandlerPrettyName(const QString& newHandlerPrettyName);
  52. virtual void setEnabledInternal(bool value) = 0;
  53. protected:
  54. QScopedPointer<ctkErrorLogAbstractMessageHandlerPrivate> d_ptr;
  55. private:
  56. Q_DECLARE_PRIVATE(ctkErrorLogAbstractMessageHandler)
  57. Q_DISABLE_COPY(ctkErrorLogAbstractMessageHandler)
  58. };
  59. #endif // CTKERRORLOGABSTRACTMESSAGEHANDLER_H