0031189: Draw Harness, ViewerTest - send messages to Message::DefaultMessenger()
[occt.git] / src / Message / Message.hxx
CommitLineData
42cf5bc1 1// Created on: 1999-07-29
2// Created by: Roman LYGIN
3// Copyright (c) 1999 Matra Datavision
4// Copyright (c) 1999-2014 OPEN CASCADE SAS
5//
6// This file is part of Open CASCADE Technology software library.
7//
8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
13//
14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
16
17#ifndef _Message_HeaderFile
18#define _Message_HeaderFile
19
23fe70ec 20#include <Message_Messenger.hxx>
42cf5bc1 21
22//! Defines
23//! - tools to work with messages
24//! - basic tools intended for progress indication
23fe70ec 25class Message
42cf5bc1 26{
27public:
28
29 DEFINE_STANDARD_ALLOC
30
42cf5bc1 31 //! Defines default messenger for OCCT applications.
32 //! This is global static instance of the messenger.
04232180 33 //! By default, it contains single printer directed to std::cout.
42cf5bc1 34 //! It can be customized according to the application needs.
23fe70ec 35 //!
36 //! The following syntax can be used to print messages:
37 //! @begincode
38 //! Message::DefaultMessenger()->Send ("My Warning", Message_Warning);
39 //! Message::SendWarning ("My Warning"); // short-cut for Message_Warning
40 //! Message::SendWarning() << "My Warning with " << theCounter << " arguments";
41 //! Message::SendFail ("My Failure"); // short-cut for Message_Fail
42 //! @endcode
42cf5bc1 43 Standard_EXPORT static const Handle(Message_Messenger)& DefaultMessenger();
23fe70ec 44
45public:
46 //!@name Short-cuts to DefaultMessenger
47
48 static Message_Messenger::StreamBuffer Send(Message_Gravity theGravity)
49 {
50 return DefaultMessenger()->Send (theGravity);
51 }
52
53 static void Send(const TCollection_AsciiString& theMessage, Message_Gravity theGravity)
54 {
55 DefaultMessenger()->Send (theMessage, theGravity);
56 }
57
58 static Message_Messenger::StreamBuffer SendFail() { return DefaultMessenger()->SendFail (); }
59 static Message_Messenger::StreamBuffer SendAlarm() { return DefaultMessenger()->SendAlarm (); }
60 static Message_Messenger::StreamBuffer SendWarning() { return DefaultMessenger()->SendWarning (); }
61 static Message_Messenger::StreamBuffer SendInfo() { return DefaultMessenger()->SendInfo (); }
62 static Message_Messenger::StreamBuffer SendTrace() { return DefaultMessenger()->SendTrace (); }
63
64 static void SendFail (const TCollection_AsciiString& theMessage) { return DefaultMessenger()->SendFail (theMessage); }
65 static void SendAlarm (const TCollection_AsciiString& theMessage) { return DefaultMessenger()->SendAlarm (theMessage); }
66 static void SendWarning (const TCollection_AsciiString& theMessage) { return DefaultMessenger()->SendWarning (theMessage); }
67 static void SendInfo (const TCollection_AsciiString& theMessage) { return DefaultMessenger()->SendInfo (theMessage); }
68 static void SendTrace (const TCollection_AsciiString& theMessage) { return DefaultMessenger()->SendTrace (theMessage); }
69
70public:
71
42cf5bc1 72 //! Returns the string filled with values of hours, minutes and seconds.
73 //! Example:
74 //! 1. (5, 12, 26.3345) returns "05h:12m:26.33s",
75 //! 2. (0, 6, 34.496 ) returns "06m:34.50s",
76 //! 3. (0, 0, 4.5 ) returns "4.50s"
77 Standard_EXPORT static TCollection_AsciiString FillTime (const Standard_Integer Hour, const Standard_Integer Minute, const Standard_Real Second);
78
42cf5bc1 79};
80
42cf5bc1 81#endif // _Message_HeaderFile