ctkErrorLogAbstractMessageHandler.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. //------------------------------------------------------------------------------
  26. /// \ingroup Core
  27. class CTK_CORE_EXPORT ctkErrorLogAbstractMessageHandler : public QObject
  28. {
  29. Q_OBJECT
  30. public:
  31. typedef QObject Superclass;
  32. /// Disabled by default.
  33. ctkErrorLogAbstractMessageHandler();
  34. virtual ~ctkErrorLogAbstractMessageHandler();
  35. virtual QString handlerName()const = 0;
  36. QString handlerPrettyName()const;
  37. bool enabled()const;
  38. void setEnabled(bool value);
  39. void handleMessage(const QString& threadId, ctkErrorLogLevel::LogLevel logLevel,
  40. const QString& origin, const QString& text);
  41. ctkErrorLogTerminalOutput* terminalOutput(ctkErrorLogTerminalOutput::TerminalOutput terminalOutputType)const;
  42. void setTerminalOutput(ctkErrorLogTerminalOutput::TerminalOutput terminalOutputType,
  43. ctkErrorLogTerminalOutput * terminalOutput);
  44. Q_SIGNALS:
  45. void messageHandled(const QDateTime& currentDateTime, const QString& threadId,
  46. ctkErrorLogLevel::LogLevel logLevel, const QString& origin,
  47. const QString& text);
  48. protected:
  49. void setHandlerPrettyName(const QString& newHandlerPrettyName);
  50. virtual void setEnabledInternal(bool value) = 0;
  51. protected:
  52. QScopedPointer<ctkErrorLogAbstractMessageHandlerPrivate> d_ptr;
  53. private:
  54. Q_DECLARE_PRIVATE(ctkErrorLogAbstractMessageHandler)
  55. Q_DISABLE_COPY(ctkErrorLogAbstractMessageHandler)
  56. };
  57. #endif // CTKERRORLOGABSTRACTMESSAGEHANDLER_H