Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:16

0001 // Created on: 1999-07-29
0002 // Created by: Roman LYGIN
0003 // Copyright (c) 1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Message_HeaderFile
0018 #define _Message_HeaderFile
0019 
0020 #include <Message_Messenger.hxx>
0021 #include <Message_Gravity.hxx>
0022 #include <Message_MetricType.hxx>
0023 #include <NCollection_Vector.hxx>
0024 #include <OSD_MemInfo.hxx>
0025 
0026 #include <TCollection_AsciiString.hxx>
0027 
0028 class Message_Report;
0029 
0030 //! Defines
0031 //! - tools to work with messages
0032 //! - basic tools intended for progress indication
0033 class Message
0034 {
0035 public:
0036 
0037   DEFINE_STANDARD_ALLOC
0038 
0039   //! Defines default messenger for OCCT applications.
0040   //! This is global static instance of the messenger.
0041   //! By default, it contains single printer directed to std::cout.
0042   //! It can be customized according to the application needs.
0043   //!
0044   //! The following syntax can be used to print messages:
0045   //! @code
0046   //!   Message::DefaultMessenger()->Send ("My Warning", Message_Warning);
0047   //!   Message::SendWarning ("My Warning"); // short-cut for Message_Warning
0048   //!   Message::SendWarning() << "My Warning with " << theCounter << " arguments";
0049   //!   Message::SendFail ("My Failure"); // short-cut for Message_Fail
0050   //! @endcode
0051   Standard_EXPORT static const Handle(Message_Messenger)& DefaultMessenger();
0052 
0053 public:
0054   //!@name Short-cuts to DefaultMessenger
0055 
0056   static Message_Messenger::StreamBuffer Send(Message_Gravity theGravity)
0057   {
0058     return DefaultMessenger()->Send (theGravity);
0059   }
0060 
0061   static void Send(const TCollection_AsciiString& theMessage, Message_Gravity theGravity)
0062   {
0063     DefaultMessenger()->Send (theMessage, theGravity);
0064   }
0065 
0066   static Message_Messenger::StreamBuffer SendFail()    { return DefaultMessenger()->SendFail ();    }
0067   static Message_Messenger::StreamBuffer SendAlarm()   { return DefaultMessenger()->SendAlarm ();   }
0068   static Message_Messenger::StreamBuffer SendWarning() { return DefaultMessenger()->SendWarning (); }
0069   static Message_Messenger::StreamBuffer SendInfo()    { return DefaultMessenger()->SendInfo ();    }
0070   static Message_Messenger::StreamBuffer SendTrace()   { return DefaultMessenger()->SendTrace ();   }
0071 
0072   static void SendFail    (const TCollection_AsciiString& theMessage) { return DefaultMessenger()->SendFail    (theMessage); }
0073   static void SendAlarm   (const TCollection_AsciiString& theMessage) { return DefaultMessenger()->SendAlarm   (theMessage); }
0074   static void SendWarning (const TCollection_AsciiString& theMessage) { return DefaultMessenger()->SendWarning (theMessage); }
0075   static void SendInfo    (const TCollection_AsciiString& theMessage) { return DefaultMessenger()->SendInfo    (theMessage); }
0076   static void SendTrace   (const TCollection_AsciiString& theMessage) { return DefaultMessenger()->SendTrace   (theMessage); }
0077 
0078 public:
0079 
0080   //! Returns the string filled with values of hours, minutes and seconds.
0081   //! Example:
0082   //! 1. (5, 12, 26.3345) returns "05h:12m:26.33s",
0083   //! 2. (0,  6, 34.496 ) returns "06m:34.50s",
0084   //! 3. (0,  0,  4.5   ) returns "4.50s"
0085   Standard_EXPORT static TCollection_AsciiString FillTime (const Standard_Integer Hour, const Standard_Integer Minute, const Standard_Real Second);
0086 
0087 public:
0088   //! returns the only one instance of Report
0089   //! When theToCreate is true - automatically creates message report when not exist.
0090   Standard_EXPORT static const Handle(Message_Report)& DefaultReport (const Standard_Boolean theToCreate = Standard_False);
0091 
0092   //! Determines the metric from the given string identifier.
0093   //! @param theString string identifier
0094   //! @param theType detected type of metric
0095   //! @return TRUE if string identifier is known
0096   Standard_EXPORT static Standard_Boolean MetricFromString (const Standard_CString theString,
0097                                                             Message_MetricType& theType);
0098 
0099   //! Returns the string name for a given metric type.
0100   //! @param theType metric type
0101   //! @return string identifier from the list of Message_MetricType
0102   Standard_EXPORT static Standard_CString MetricToString (const Message_MetricType theType);
0103 
0104   //! Returns the metric type from the given string identifier.
0105   //! @param theString string identifier
0106   //! @return metric type or Message_MetricType_None if string identifier is invalid
0107   static Message_MetricType MetricFromString (const Standard_CString theString)
0108   {
0109     Message_MetricType aMetric = Message_MetricType_None;
0110     MetricFromString (theString, aMetric);
0111     return aMetric;
0112   }
0113 
0114   //! Converts message metric to OSD memory info type.
0115   //! @param theMetric [in] message metric
0116   //! @param theMemInfo [out] filled memory info type
0117   //! @return true if converted
0118   static Standard_EXPORT Standard_Boolean ToOSDMetric (const Message_MetricType theMetric, OSD_MemInfo::Counter& theMemInfo);
0119 
0120   //! Converts OSD memory info type to message metric.
0121   //! @param theMemInfo [int] memory info type
0122   //! @param theMetric [out] filled message metric
0123   //! @return true if converted
0124   static Standard_EXPORT Standard_Boolean ToMessageMetric (const OSD_MemInfo::Counter theMemInfo, Message_MetricType& theMetric);
0125 
0126 };
0127 
0128 #endif // _Message_HeaderFile