|
|
|||
Warning, file /include/opencascade/Message_Algorithm.hxx was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // Created on: 2007-07-06 0002 // Created by: Pavel TELKOV 0003 // Copyright (c) 2007-2014 OPEN CASCADE SAS 0004 // 0005 // This file is part of Open CASCADE Technology software library. 0006 // 0007 // This library is free software; you can redistribute it and/or modify it under 0008 // the terms of the GNU Lesser General Public License version 2.1 as published 0009 // by the Free Software Foundation, with special exception defined in the file 0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT 0011 // distribution for complete text of the license and disclaimer of any warranty. 0012 // 0013 // Alternatively, this file may be used under the terms of Open CASCADE 0014 // commercial license or contractual agreement. 0015 0016 #ifndef _Message_Algorithm_HeaderFile 0017 #define _Message_Algorithm_HeaderFile 0018 0019 #include <Standard.hxx> 0020 #include <Standard_Type.hxx> 0021 0022 #include <Message_ExecStatus.hxx> 0023 #include <TColStd_HArray1OfTransient.hxx> 0024 #include <Standard_Transient.hxx> 0025 #include <Message_Status.hxx> 0026 #include <Standard_Integer.hxx> 0027 #include <Standard_CString.hxx> 0028 #include <Message_Gravity.hxx> 0029 #include <TCollection_HAsciiString.hxx> 0030 #include <TCollection_HExtendedString.hxx> 0031 #include <TColStd_HSequenceOfHExtendedString.hxx> 0032 #include <TColStd_SequenceOfHExtendedString.hxx> 0033 #include <Message_HArrayOfMsg.hxx> 0034 0035 class Message_Messenger; 0036 class TCollection_AsciiString; 0037 class TCollection_HAsciiString; 0038 class TCollection_ExtendedString; 0039 class TCollection_HExtendedString; 0040 class Message_Msg; 0041 class TColStd_HPackedMapOfInteger; 0042 0043 0044 class Message_Algorithm; 0045 DEFINE_STANDARD_HANDLE(Message_Algorithm, Standard_Transient) 0046 0047 //! Class Message_Algorithm is intended to be the base class for 0048 //! classes implementing algorithms or any operations that need 0049 //! to provide extended information on its execution to the 0050 //! caller / user. 0051 //! 0052 //! It provides generic mechanism for management of the execution 0053 //! status, collection and output of messages. 0054 //! 0055 //! The algorithm uses methods SetStatus() to set an execution status. 0056 //! It is possible to associate a status with a number or a string 0057 //! (second argument of SetStatus() methods) to indicate precisely 0058 //! the item (object, element etc.) in the input data which caused 0059 //! the problem. 0060 //! 0061 //! Each execution status generated by the algorithm has associated 0062 //! text message that should be defined in the resource file loaded 0063 //! with call to Message_MsgFile::LoadFile(). 0064 //! 0065 //! The messages corresponding to the statuses generated during the 0066 //! algorithm execution are output to Message_Messenger using 0067 //! methods SendMessages(). If status have associated numbers 0068 //! or strings, they are included in the message body in place of 0069 //! "%s" placeholder which should be present in the message text. 0070 //! 0071 //! The name of the message text in the resource file is constructed 0072 //! from name of the class and name of the status, separated by dot, 0073 //! for instance: 0074 //! 0075 //! .TObj_CheckModel.Alarm2 0076 //! Error: Some objects (%s) have references to dead object(s) 0077 //! 0078 //! If message for the status is not found with prefix of 0079 //! the current class type, the same message is searched for the base 0080 //! class(es) recursively. 0081 //! 0082 //! Message can be set explicitly for the status; in this case the 0083 //! above procedure is not used and supplied message is used as is. 0084 //! 0085 //! The messages are output to the messenger, stored in the field; 0086 //! though messenger can be changed, it is guaranteed to be non-null. 0087 //! By default, Message::DefaultMessenger() is used. 0088 class Message_Algorithm : public Standard_Transient 0089 { 0090 0091 public: 0092 0093 0094 //! Empty constructor 0095 Standard_EXPORT Message_Algorithm(); 0096 0097 //! Sets status with no parameter 0098 Standard_EXPORT void SetStatus (const Message_Status& theStat); 0099 0100 //! Sets status with integer parameter 0101 Standard_EXPORT void SetStatus (const Message_Status& theStat, const Standard_Integer theInt); 0102 0103 //! Sets status with string parameter. 0104 //! If noRepetitions is True, the parameter will be added only 0105 //! if it has not been yet recorded for the same status flag 0106 void SetStatus (const Message_Status& theStat, const Standard_CString theStr, const Standard_Boolean noRepetitions = Standard_True); 0107 0108 //! Sets status with string parameter 0109 //! If noRepetitions is True, the parameter will be added only 0110 //! if it has not been yet recorded for the same status flag 0111 void SetStatus (const Message_Status& theStat, const TCollection_AsciiString& theStr, const Standard_Boolean noRepetitions = Standard_True); 0112 0113 //! Sets status with string parameter 0114 //! If noRepetitions is True, the parameter will be added only 0115 //! if it has not been yet recorded for the same status flag 0116 void SetStatus (const Message_Status& theStat, const Handle(TCollection_HAsciiString)& theStr, const Standard_Boolean noRepetitions = Standard_True); 0117 0118 //! Sets status with string parameter 0119 //! If noRepetitions is True, the parameter will be added only 0120 //! if it has not been yet recorded for the same status flag 0121 void SetStatus (const Message_Status& theStat, const TCollection_ExtendedString& theStr, const Standard_Boolean noRepetitions = Standard_True); 0122 0123 //! Sets status with string parameter 0124 //! If noRepetitions is True, the parameter will be added only 0125 //! if it has not been yet recorded for the same status flag 0126 Standard_EXPORT void SetStatus (const Message_Status& theStat, const Handle(TCollection_HExtendedString)& theStr, const Standard_Boolean noRepetitions = Standard_True); 0127 0128 //! Sets status with preformatted message. This message will be 0129 //! used directly to report the status; automatic generation of 0130 //! status messages will be disabled for it. 0131 Standard_EXPORT void SetStatus (const Message_Status& theStat, const Message_Msg& theMsg); 0132 0133 //! Returns copy of exec status of algorithm 0134 const Message_ExecStatus& GetStatus() const; 0135 0136 //! Returns exec status of algorithm 0137 Message_ExecStatus& ChangeStatus(); 0138 0139 //! Clear exec status of algorithm 0140 Standard_EXPORT void ClearStatus(); 0141 0142 //! Sets messenger to algorithm 0143 Standard_EXPORT void SetMessenger (const Handle(Message_Messenger)& theMsgr); 0144 0145 //! Returns messenger of algorithm. 0146 //! The returned handle is always non-null and can 0147 //! be used for sending messages. 0148 Handle(Message_Messenger) GetMessenger() const; 0149 0150 //! Print messages for all status flags that have been set during 0151 //! algorithm execution, excluding statuses that are NOT set 0152 //! in theFilter. 0153 //! 0154 //! The messages are taken from resource file, names being 0155 //! constructed as {dynamic class type}.{status name}, 0156 //! for instance, "Message_Algorithm.Fail5". 0157 //! If message is not found in resources for this class and all 0158 //! its base types, surrogate text is printed. 0159 //! 0160 //! For the statuses having number or string parameters, 0161 //! theMaxCount defines maximal number of numbers or strings to be 0162 //! included in the message 0163 //! 0164 //! Note that this method is virtual; this allows descendant 0165 //! classes to customize message output (e.g. by adding 0166 //! messages from other sub-algorithms) 0167 Standard_EXPORT virtual void SendStatusMessages (const Message_ExecStatus& theFilter, const Message_Gravity theTraceLevel = Message_Warning, const Standard_Integer theMaxCount = 20) const; 0168 0169 //! Convenient variant of SendStatusMessages() with theFilter 0170 //! having defined all WARN, ALARM, and FAIL (but not DONE) 0171 //! status flags 0172 Standard_EXPORT void SendMessages (const Message_Gravity theTraceLevel = Message_Warning, const Standard_Integer theMaxCount = 20) const; 0173 0174 //! Add statuses to this algorithm from other algorithm 0175 //! (including messages) 0176 Standard_EXPORT void AddStatus (const Handle(Message_Algorithm)& theOther); 0177 0178 //! Add statuses to this algorithm from other algorithm, but 0179 //! only those items are moved that correspond to statuses 0180 //! set in theStatus 0181 Standard_EXPORT void AddStatus (const Message_ExecStatus& theStatus, const Handle(Message_Algorithm)& theOther); 0182 0183 //! Return the numbers associated with the indicated status; 0184 //! Null handle if no such status or no numbers associated with it 0185 Standard_EXPORT Handle(TColStd_HPackedMapOfInteger) GetMessageNumbers (const Message_Status& theStatus) const; 0186 0187 //! Return the strings associated with the indicated status; 0188 //! Null handle if no such status or no strings associated with it 0189 Standard_EXPORT Handle(TColStd_HSequenceOfHExtendedString) GetMessageStrings (const Message_Status& theStatus) const; 0190 0191 //! Prepares a string containing a list of integers contained 0192 //! in theError map, but not more than theMaxCount 0193 Standard_EXPORT static TCollection_ExtendedString PrepareReport (const Handle(TColStd_HPackedMapOfInteger)& theError, const Standard_Integer theMaxCount); 0194 0195 //! Prepares a string containing a list of names contained 0196 //! in theReportSeq sequence, but not more than theMaxCount 0197 Standard_EXPORT static TCollection_ExtendedString PrepareReport (const TColStd_SequenceOfHExtendedString& theReportSeq, const Standard_Integer theMaxCount); 0198 0199 0200 0201 0202 DEFINE_STANDARD_RTTIEXT(Message_Algorithm,Standard_Transient) 0203 0204 protected: 0205 0206 0207 Message_ExecStatus myStatus; 0208 Handle(Message_Messenger) myMessenger; 0209 0210 0211 private: 0212 0213 0214 Handle(TColStd_HArray1OfTransient) myReportIntegers; 0215 Handle(TColStd_HArray1OfTransient) myReportStrings; 0216 Message_HArrayOfMsg myReportMessages; 0217 0218 0219 }; 0220 0221 0222 #include <Message_Algorithm.lxx> 0223 0224 0225 0226 0227 0228 #endif // _Message_Algorithm_HeaderFile
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|