Message
OCCT package Message: Message_Alert, Message_AlertExtended, Message_Algorithm, Message_Attribute, and 21 more bound classes.
Message_Alert
Base class of the hierarchy of classes describing various situations occurring during execution of some algorithm or procedure.
Alert should provide unique text identifier that can be used to distinguish particular type of alerts, e.g. to get text message string describing it. See method GetMessageKey(); by default, dynamic type name is used.
Alert can contain some data. To avoid duplication of data, new alert can be merged with another one of the same type. Method SupportsMerge() should return true if merge is supported; method Merge() should do the merge if possible and return true in that case and false otherwise.
Constructors(1)
Static methods(2)
- get_type_name(): string
Instance methods(4)
- GetMessageKey(): string
Return a C string to be used as a key for generating text user messages describing this alert. The messages are generated with help of
Message_Msgclass, inMessage_Report::Dump(). Base implementation returns dynamic type name of the instance. - SupportsMerge(): boolean
Return true if this type of alert can be merged with other of the same type to avoid duplication. Basis implementation returns true.
- Merge(theTarget: Message_Alert): boolean
If possible, merge data contained in this alert to theTarget.
Parameters (1)theTarget
ReturnsTrue if merged. Base implementation always returns true.
Message_AlertExtended
Inherited class of Message_Alert with some additional information. It has Message_Attributes to provide the alert name, and other custom information It has a container of composite alerts, if the alert might provide sub-alerts collecting.
Constructors(1)
Empty constructor.
Static methods(3)
- AddAlert(theReport: Message_Report, theAttribute: Message_Attribute, theGravity: Message_Gravity): Message_Alert
Creates new instance of the alert and put it into report with Message_Info gravity. It does nothing if such kind of gravity is not active in the report.
Parameters (3)theReport—the message report where new alert is placedtheAttribute—container of additional values of the alerttheGravity
Returnscreated alert or NULL if Message_Info is not active in report
- get_type_name(): string
Instance methods(7)
- GetMessageKey(): string
Return a C string to be used as a key for generating text user messages describing this alert. The messages are generated with help of
Message_Msgclass, inMessage_Report::Dump(). Base implementation returns dynamic type name of the instance. Returns container of the alert attributes.
- SetAttribute(theAttribute: Message_Attribute): void
Sets container of the alert attributes.
Parameters (1)theAttribute
- CompositeAlerts(theToCreate?: boolean): Message_CompositeAlerts
Returns class provided hierarchy of alerts if created or create if the parameter is true.
Parameters (1)theToCreate—if composite alert has not been created for this alert, it should be created
Returnsinstance or NULL
- SupportsMerge(): boolean
Return true if this type of alert can be merged with other of the same type to avoid duplication. Hierarchical alerts can not be merged Basis implementation returns true.
- Merge(theTarget: Message_Alert): boolean
If possible, merge data contained in this alert to theTarget. Base implementation always returns false.
Parameters (1)theTarget
ReturnsTrue if merged
Message_Algorithm
Class Message_Algorithm is intended to be the base class for classes implementing algorithms or any operations that need to provide extended information on its execution to the caller / user.
It provides generic mechanism for management of the execution status, collection and output of messages.
The algorithm uses methods SetStatus() to set an execution status. It is possible to associate a status with a number or a string (second argument of SetStatus() methods) to indicate precisely the item (object, element etc.) in the input data which caused the problem.
Each execution status generated by the algorithm has associated text message that should be defined in the resource file loaded with call to Message_MsgFile::LoadFile().
The messages corresponding to the statuses generated during the algorithm execution are output to Message_Messenger using methods SendMessages(). If status have associated numbers or strings, they are included in the message body in place of "%s" placeholder which should be present in the message text.
The name of the message text in the resource file is constructed from name of the class and name of the status, separated by dot, for instance:
.TObj_CheckModel.Alarm2 Error: Some objects (s) have references to dead object(s)
If message for the status is not found with prefix of the current class type, the same message is searched for the base class(es) recursively.
Message can be set explicitly for the status; in this case the above procedure is not used and supplied message is used as is.
The messages are output to the messenger, stored in the field; though messenger can be changed, it is guaranteed to be non-null. By default, Message::DefaultMessenger() is used.
Constructors(1)
Empty constructor.
Static methods(4)
- PrepareReport(theError: TColStd_HPackedMapOfInteger, theMaxCount: number): TCollection_ExtendedString
Prepares a string containing a list of integers contained in theError map, but not more than theMaxCount.
Parameters (2)theErrortheMaxCount
- PrepareReport(theReportSeq: NCollection_Sequence_handle_TCollection_HExtendedString, theMaxCount: number): TCollection_ExtendedString
Prepares a string containing a list of names contained in theReportSeq sequence, but not more than theMaxCount.
Parameters (2)theReportSeqtheMaxCount
- get_type_name(): string
Instance methods(17)
- SetStatus(theStat: Message_Status, theInt: number): void
Sets status with integer parameter.
Parameters (2)theStattheInt
- SetStatus(theStat: Message_Status, theMsg: Message_Msg): void
Sets status with preformatted message. This message will be used directly to report the status; automatic generation of status messages will be disabled for it.
Parameters (2)theStattheMsg
- SetStatus(theStat: Message_Status, theStr: string, noRepetitions: boolean): void
Sets status with string parameter. If noRepetitions is True, the parameter will be added only if it has not been yet recorded for the same status flag.
Parameters (3)theStattheStrnoRepetitions
- SetStatus(theStat: Message_Status, theStr: TCollection_AsciiString, noRepetitions: boolean): void
Sets status with string parameter If noRepetitions is True, the parameter will be added only if it has not been yet recorded for the same status flag.
Parameters (3)theStattheStrnoRepetitions
- SetStatus(theStat: Message_Status, theStr: TCollection_HAsciiString, noRepetitions: boolean): void
Sets status with string parameter If noRepetitions is True, the parameter will be added only if it has not been yet recorded for the same status flag.
Parameters (3)theStattheStrnoRepetitions
- SetStatus(theStat: Message_Status, theStr: TCollection_ExtendedString, noRepetitions: boolean): void
Sets status with string parameter If noRepetitions is True, the parameter will be added only if it has not been yet recorded for the same status flag.
Parameters (3)theStattheStrnoRepetitions
- SetStatus(theStat: Message_Status, theStr: TCollection_HExtendedString, noRepetitions: boolean): void
Sets status with string parameter If noRepetitions is True, the parameter will be added only if it has not been yet recorded for the same status flag.
Parameters (3)theStattheStrnoRepetitions
Returns copy of exec status of algorithm.
Returns exec status of algorithm.
- ClearStatus(): void
Clear exec status of algorithm.
- SendStatusMessages(theFilter: Message_ExecStatus, theTraceLevel?: Message_Gravity, theMaxCount?: number): void
Print messages for all status flags that have been set during algorithm execution, excluding statuses that are NOT set in theFilter.
The messages are taken from resource file, names being constructed as {dynamic class type}.{status name}, for instance, "Message_Algorithm.Fail5". If message is not found in resources for this class and all its base types, surrogate text is printed.
For the statuses having number or string parameters, theMaxCount defines maximal number of numbers or strings to be included in the message
Note that this method is virtual; this allows descendant classes to customize message output (e.g. by adding messages from other sub-algorithms)Parameters (3)theFiltertheTraceLeveltheMaxCount
- SendMessages(theTraceLevel?: Message_Gravity, theMaxCount?: number): void
Convenient variant of
SendStatusMessages()with theFilter having defined all WARN, ALARM, and FAIL (but not DONE) status flags.Parameters (2)theTraceLeveltheMaxCount
- AddStatus(theOther: Message_Algorithm): void
Add statuses to this algorithm from other algorithm (including messages).
Parameters (1)theOther
- AddStatus(theStatus: Message_ExecStatus, theOther: Message_Algorithm): void
Add statuses to this algorithm from other algorithm, but only those items are moved that correspond to statuses set in theStatus.
Parameters (2)theStatustheOther
- GetMessageNumbers(theStatus: Message_Status): TColStd_HPackedMapOfInteger
Return the numbers associated with the indicated status; Null handle if no such status or no numbers associated with it.
Parameters (1)theStatus
- GetMessageStrings(theStatus: Message_Status): NCollection_HSequence_handle_TCollection_HExtendedString
Return the strings associated with the indicated status; Null handle if no such status or no strings associated with it.
Parameters (1)theStatus
Message_Attribute
Additional information of extended alert attribute To provide other custom attribute container, it might be redefined.
Constructors(1)
- constructor(theName?: TCollection_AsciiString): Message_Attribute
Empty constructor.
Parameters (1)theName
Static methods(2)
- get_type_name(): string
Instance methods(4)
- GetMessageKey(): string
Return a C string to be used as a key for generating text user messages describing this alert. The messages are generated with help of
Message_Msgclass, inMessage_Report::Dump(). Base implementation returns dynamic type name of the instance. Returns custom name of alert if it is set.
Returnsalert name
- SetName(theName: TCollection_AsciiString): void
Sets the custom name of alert.
Parameters (1)theName—a name for the alert
Message_AttributeMeter
Alert object storing alert metrics values. Start and stop values for each metric.
Constructors(1)
- constructor(theName?: TCollection_AsciiString): Message_AttributeMeter
Constructor with string argument.
Parameters (1)theName
Static methods(6)
- UndefinedMetricValue(): number
Returns default value of the metric when it is not defined.
Returnsundefined value
- StartAlert(theAlert: Message_AlertExtended): void
Sets start values of default report metrics into the alert.
Parameters (1)theAlert—an alert
- StopAlert(theAlert: Message_AlertExtended): void
Sets stop values of default report metrics into the alert.
Parameters (1)theAlert—an alert
- SetAlertMetrics(theAlert: Message_AlertExtended, theStartValue: boolean): void
Sets current values of default report metrics into the alert. Processed only alert with
Message_AttributeMeterattribute.Parameters (2)theAlert—an alerttheStartValue—flag, if true, the start value is collected otherwise stop
- get_type_name(): string
Instance methods(7)
- HasMetric(theMetric: Message_MetricType): boolean
Checks whether the attribute has values for the metric.
Parameters (1)theMetric—metric type
Returnstrue if the metric values exist in the attribute
- IsMetricValid(theMetric: Message_MetricType): boolean
Returns true when both values of the metric are set.
Parameters (1)theMetric—metric type
Returnstrue if metric values are valid
- StartValue(theMetric: Message_MetricType): number
Returns start value for the metric.
Parameters (1)theMetric—metric type
Returnsreal value
- SetStartValue(theMetric: Message_MetricType, theValue: number): void
Sets start values for the metric.
Parameters (2)theMetric—metric typetheValue
- StopValue(theMetric: Message_MetricType): number
Returns stop value for the metric.
Parameters (1)theMetric—metric type
Returnsreal value
- SetStopValue(theMetric: Message_MetricType, theValue: number): void
Sets stop values for the metric.
Parameters (2)theMetric—metric typetheValue
Message_AttributeObject
Alert object storing a transient object.
Constructors(1)
- constructor(theObject: Standard_Transient, theName?: TCollection_AsciiString): Message_AttributeObject
Constructor with string argument.
Parameters (2)theObjecttheName
Static methods(2)
- get_type_name(): string
Instance methods(3)
Returns object.
Returnsthe object instance
- SetObject(theObject: Standard_Transient): void
Sets the object.
Parameters (1)theObject—an instance
Message_AttributeStream
Alert object storing stream value.
Static methods(2)
- get_type_name(): string
Instance methods(1)
Message_CompositeAlerts
Class providing container of alerts.
Constructors(1)
Empty constructor.
Static methods(2)
- get_type_name(): string
Instance methods(9)
- Alerts(theGravity: Message_Gravity): NCollection_List_handle_Message_Alert
Returns list of collected alerts with specified gravity.
Parameters (1)theGravity
- AddAlert(theGravity: Message_Gravity, theAlert: Message_Alert): boolean
Add alert with specified gravity. If the alert supports merge it will be merged.
Parameters (2)theGravity—an alert gravitytheAlert—an alert to be added as a child alert
Returnstrue if the alert is added or merged
- RemoveAlert(theGravity: Message_Gravity, theAlert: Message_Alert): boolean
Removes alert with specified gravity.
Parameters (2)theGravity—an alert gravitytheAlert—an alert to be removed from the children
Returnstrue if the alert is removed
- HasAlert(theAlert: Message_Alert): boolean
Returns true if the alert belong the list of the child alerts.
Parameters (1)theAlert—an alert to be checked as a child alert
Returnstrue if the alert is found in a container of children
- HasAlert(theType: Standard_Type, theGravity: Message_Gravity): boolean
Returns true if specific type of alert is recorded with specified gravity.
Parameters (2)theType—an alert typetheGravity—an alert gravity
Returnstrue if the alert is found in a container of children
- Clear(): void
Clears all collected alerts.
- Clear(theGravity: Message_Gravity): void
Clears collected alerts with specified gravity.
Parameters (1)theGravity—an alert gravity
- Clear(theType: Standard_Type): void
Clears collected alerts with specified type.
Parameters (1)theType—an alert type
Message_ConsoleColor
Properties(9)
Message_ExecStatus
Tiny class for extended handling of error / execution status of algorithm in universal way.
It is in fact a set of integers represented as a collection of bit flags for each of four types of status; each status flag has its own symbolic name and can be set/tested individually.
The flags are grouped in semantic groups:
- No flags means nothing done
- Done flags correspond to some operation successfully completed
- Warning flags correspond to warning messages on some potentially wrong situation, not harming algorithm execution
- Alarm flags correspond to more severe warnings about incorrect user data, while not breaking algorithm execution
- Fail flags correspond to cases when algorithm failed to complete
Constructors(2)
- constructor(theStatus: Message_Status): Message_ExecStatusParameters (1)
theStatus
Static methods(4)
- StatusIndex(theStatus: Message_Status): numberParameters (1)
theStatus
- LocalStatusIndex(theStatus: Message_Status): numberParameters (1)
theStatus
- TypeOfStatus(theStatus: Message_Status): Message_StatusTypeParameters (1)
theStatus
- StatusByIndex(theIndex: number): Message_StatusParameters (1)
theIndex
Instance methods(18)
- Set(theStatus: Message_Status): voidParameters (1)
theStatus
- IsSet(theStatus: Message_Status): booleanParameters (1)
theStatus
- Clear(theStatus: Message_Status): voidParameters (1)
theStatus
- Clear(): void
- IsDone(): boolean
- IsFail(): boolean
- IsWarn(): boolean
- IsAlarm(): boolean
- SetAllDone(): void
- SetAllWarn(): void
- SetAllAlarm(): void
- SetAllFail(): void
- ClearAllDone(): void
- ClearAllWarn(): void
- ClearAllAlarm(): void
- ClearAllFail(): void
- Add(theOther: Message_ExecStatus): voidParameters (1)
theOther
- And(theOther: Message_ExecStatus): voidParameters (1)
theOther
Message_Gravity
Properties(5)
Message_Level
This class is an instance of Sentry to create a level in a message report Constructor of the class add new (active) level in the report, destructor removes it While the level is active in the report, new alerts are added below the level root alert.
The first added alert is a root alert, other are added below the root alert
If alert has Message_AttributeMeter attribute, active metrics of the default report are stored in the attribute: start value of metric on adding alert, stop on adding another alert or closing (delete) the level in the report.
Processing of this class is implemented in Message_Report, it is used only inside it. Levels using should be only through using OCCT_ADD_MESSAGE_LEVEL_SENTRY only. No other code is required outside.
Constructors(1)
- constructor(theName?: TCollection_AsciiString): Message_Level
Constructor. One string key is used for all alert meters. The perf meter is not started automatically, it will be done in
AddAlert()method.Parameters (1)theName
Instance methods(3)
Returns root alert of the level.
Returnsalert instance or NULL
- SetRootAlert(theAlert: Message_AlertExtended, isRequiredToStart: boolean): void
Sets the root alert. Starts collects alert metrics if active.
Parameters (2)theAlert—an alertisRequiredToStart
- AddAlert(theGravity: Message_Gravity, theAlert: Message_Alert): boolean
Adds new alert on the level. Stops the last alert metric, appends the alert and starts the alert metrics collecting. Sets root alert beforehand this method using, if the root is NULL, it does nothing.
Parameters (2)theGravity—an alert gravitytheAlert—an alert
Returnstrue if alert is added
Message_MetricType
Properties(13)
Message_Msg
This class provides a tool for constructing the parametrized message basing on resources loaded by Message_MsgFile tool.
A Message is created from a keyword: this keyword identifies the message in a message file that should be previously loaded by call to Message_MsgFile::LoadFile().
The text of the message can contain placeholders for the parameters which are to be filled by the proper values when the message is prepared. Most of the format specifiers used in C can be used, for instance, s for string, d for integer etc. In addition, specifier f is supported for double numbers (for compatibility with previous versions).
User fills the parameter fields in the text of the message by calling corresponding methods Arg() or operators .
The resulting message, filled with all parameters, can be obtained by method Get(). If some parameters were not filled, the text UNKNOWN is placed instead.
Constructors(4)
Empty constructor.
- constructor(theMsg: Message_Msg): Message_Msg
Copy constructor.
Parameters (1)theMsg
- constructor(theKey: string): Message_Msg
Create a message using a corresponding entry in
Message_MsgFile.Parameters (1)theKey
- constructor(theKey: TCollection_ExtendedString): Message_Msg
Create a message using a corresponding entry in
Message_MsgFile.Parameters (1)theKey
Instance methods(13)
- Set(theMsg: string): void
Set a message body text - can be used as alternative to using messages from resource file.
Parameters (1)theMsg
- Set(theMsg: TCollection_ExtendedString): void
Set a message body text - can be used as alternative to using messages from resource file.
Parameters (1)theMsg
- Arg(theString: string): Message_Msg
Set a value for %..s conversion.
Parameters (1)theString
- Arg(theString: TCollection_AsciiString): Message_Msg
Set a value for %..s conversion.
Parameters (1)theString
- Arg(theString: TCollection_HAsciiString): Message_Msg
Set a value for %..s conversion.
Parameters (1)theString
- Arg(theString: TCollection_ExtendedString): Message_Msg
Set a value for %..s conversion.
Parameters (1)theString
- Arg(theString: TCollection_HExtendedString): Message_Msg
Set a value for %..s conversion.
Parameters (1)theString
- Arg(theInt: number): Message_Msg
Set a value for %..d, %..i, %..o, %..u, %..x or %..X conversion.
Parameters (1)theInt
- Arg(theReal: number): Message_Msg
Set a value for %..f, %..e, %..E, %..g or %..G conversion.
Parameters (1)theReal
Returns the original message text.
Returns current state of the message text with parameters to the moment.
- IsEdited(): boolean
Tells if Value differs from Original.
Return the resulting message string with all parameters filled. If some parameters were not yet filled by calls to methods Arg (or <<), these parameters are filled by the word UNKNOWN.
Message_MsgFile
A tool providing facility to load definitions of message strings from resource file(s).
The message file is an ASCII file which defines a set of messages. Each message is identified by its keyword (string).
All lines in the file starting with the exclamation sign (perhaps preceding by spaces and/or tabs) are ignored as comments.
Each line in the file starting with the dot character "." (perhaps preceding by spaces and/or tabs) defines the keyword. The keyword is a string starting from the next symbol after dot and ending at the symbol preceding ending newline character "\n".
All the lines in the file after the keyword and before next keyword (and which are not comments) define the message for that keyword. If the message consists of several lines, the message string will contain newline symbols "\n" between parts (but not at the end).
The experimental support of Unicode message files is provided. These are distinguished by two bytes FF.FE or FE.FF at the beginning.
The loaded messages are stored in static data map; all methods of that class are also static.
Constructors(1)
Static methods(8)
- Load(theDirName: string, theFileName: string): boolean
Load message file <theFileName> from directory <theDirName> or its sub-directory.
Parameters (2)theDirNametheFileName
- LoadFile(theFName: string): boolean
Load the messages from the given file, additive to any previously loaded messages. Messages with same keywords, if already present, are replaced with the new ones.
Parameters (1)theFName
- LoadFromEnv(theEnvName: string, theFileName: string, theLangExt?: string): booleanParameters (3)
theEnvNametheFileNametheLangExt
- LoadFromString(theContent: string, theLength?: number): booleanParameters (2)
theContenttheLength
- AddMsg(key: TCollection_AsciiString, text: TCollection_ExtendedString): booleanParameters (2)
keytext
- HasMsg(key: TCollection_AsciiString): booleanParameters (1)
key
- Msg(key: string): TCollection_ExtendedStringParameters (1)
key
- Parameters (1)
key
Message_Printer
Abstract interface class defining printer as output context for text messages.
The message, besides being text string, has associated gravity level, which can be used by printer to decide either to process a message or ignore it.
Static methods(2)
- get_type_name(): string
Instance methods(7)
Return trace level used for filtering messages; messages with lover gravity will be ignored.
- SetTraceLevel(theTraceLevel: Message_Gravity): void
Set trace level used for filtering messages. By default, trace level is Message_Info, so that all messages are output.
Parameters (1)theTraceLevel
- Send(theString: TCollection_ExtendedString, theGravity: Message_Gravity): void
Send a string message with specified trace level. The last Boolean argument is deprecated and unused. Default implementation redirects to
send().DeprecatedParameters (2)theStringtheGravity
- Send(theString: string, theGravity: Message_Gravity): void
Send a string message with specified trace level. The last Boolean argument is deprecated and unused. Default implementation redirects to
send().DeprecatedParameters (2)theStringtheGravity
- Send(theString: TCollection_AsciiString, theGravity: Message_Gravity): void
Send a string message with specified trace level. The last Boolean argument is deprecated and unused. Default implementation redirects to
send().DeprecatedParameters (2)theStringtheGravity
- SendObject(theObject: Standard_Transient, theGravity: Message_Gravity): void
Send a string message with specified trace level. The object is converted to string in format: <object kind> : <object pointer>. Default implementation calls first method
Send().Parameters (2)theObjecttheGravity
Message_PrinterOStream
Implementation of a message printer associated with an std::ostream The std::ostream may be either externally defined one (e.g. std::cout), or file stream maintained internally (depending on constructor).
Constructors(2)
- constructor(theTraceLevel?: Message_Gravity): Message_PrinterOStream
Empty constructor, defaulting to cout.
Parameters (1)theTraceLevel
- constructor(theFileName: string, theDoAppend: boolean, theTraceLevel?: Message_Gravity): Message_PrinterOStream
Create printer for output to a specified file. The option theDoAppend specifies whether file should be appended or rewritten. For specific file names (cout, cerr) standard streams are used.
Parameters (3)theFileNametheDoAppendtheTraceLevel
Static methods(2)
- get_type_name(): string
Instance methods(4)
- Close(): void
Flushes the output stream and destroys it if it has been specified externally with option doFree (or if it is internal file stream).
- ToColorize(): boolean
Returns TRUE if text output into console should be colorized depending on message gravity; TRUE by default.
- SetToColorize(theToColorize: boolean): void
Set if text output into console should be colorized depending on message gravity.
Parameters (1)theToColorize
Message_PrinterToReport
Implementation of a message printer associated with Message_Report Send will create a new alert of the report. If string is sent, an alert is created by Eol only. The alerts are sent into set report or default report of Message.
Constructors(1)
Create printer for redirecting messages into report.
Static methods(2)
- get_type_name(): string
Instance methods(4)
Returns the current or default report.
- SetReport(theReport: Message_Report): void
Sets the printer report.
Parameters (1)theReport—report for messages processing, if NULL, the default report is used
- SendObject(theObject: Standard_Transient, theGravity: Message_Gravity): void
Send a string message with specified trace level. The object is converted to string in format: <object kind> : <object pointer>. The parameter theToPutEol specified whether end-of-line should be added to the end of the message. Default implementation calls first method
Send().Parameters (2)theObjecttheGravity
Message_ProgressIndicator
Defines abstract interface from program to the user. This includes progress indication and user break mechanisms.
The progress indicator controls the progress scale with range from 0 to 1.
Method Start() should be called once, at the top level of the call stack, to reset progress indicator and get access to the root range:
To advance the progress indicator in the algorithm, use the class Message_ProgressScope that provides iterator-like interface for incrementing progress; see documentation of that class for details. The object of class Message_ProgressRange will automatically advance the indicator if it is not passed to any Message_ProgressScope.
The progress indicator supports concurrent processing and can be used in multithreaded applications.
The derived class should be created to connect this interface to actual implementation of progress indicator, to take care of visualization of the progress (e.g. show total position at the graphical bar, print scopes in text mode, or else), and for implementation of user break mechanism (if necessary).
See details in documentation of methods Show() and UserBreak().
Static methods(3)
- get_type_name(): string
- Start(theProgress: Message_ProgressIndicator): Message_ProgressRangeParameters (1)
theProgress
Instance methods(3)
- GetPosition(): number
Message_ProgressRange
Auxiliary class representing a part of the global progress scale allocated by a step of the progress scope, see Message_ProgressScope::Next().
A range object takes responsibility of advancing the progress by the size of allocated step, which is then performed depending on how it is used:
- If
Message_ProgressScopeobject is created using this range as argument, then this respondibility is taken over by that scope. - Otherwise, a range advances progress directly upon destruction.
A range object can be copied, the responsibility for progress advancement is then taken by the copy. The same range object may be used (either copied or used to create scope) only once. Any consequent attempts to use range will give no result on the progress; in debug mode, an assert message will be generated.
Constructors(2)
Constructor of the empty range.
- constructor(theOther: Message_ProgressRange): Message_ProgressRange
Copy constructor disarms the source.
Parameters (1)theOther
Instance methods(4)
Message_ProgressScope
Message_ProgressScope class provides convenient way to advance progress indicator in context of complex program organized in hierarchical way, where usually it is difficult (or even not possible) to consider process as linear with fixed step.
On every level (sub-operation) in hierarchy of operations the local instance of the Message_ProgressScope class is created. It takes a part of the upper-level scope (via Message_ProgressRange) and provides a way to consider this part as independent scale with locally defined range.
The position on the local scale may be advanced using the method Next(), which allows iteration-like advancement. This method can take argument to advance by the specified value (with default step equal to 1). This method returns Message_ProgressRange object that takes responsibility of making the specified step, either directly at its destruction or by delegating this task to another sub-scope created from that range object.
It is important that sub-scope must have life time less than the life time of its parent scope that provided the range. The usage pattern is to create scope objects as local variables in the functions that do the job, and pass range objects returned by Next() to the functions of the lower level, to allow them creating their own scopes.
The scope has a name that can be used in visualization of the progress. It can be null. Note that when C string literal is used as a name, then its value is not copied, just pointer is stored. In other variants (char pointer or a string class) the string is copied, which is additional overhead.
The same instance of the progress scope! must not be used concurrently from different threads. For the algorithm running its tasks in parallel threads, a common scope is created before the parallel execution, and the range objects produced by method Next() are used to initialise the data pertinent to each task. Then the progress is advanced within each task using its own range object. See example below.
Note that while a range of the scope is specified using double (double) parameter, it is expected to be a positive integer value. If the range is not an integer, method Next() shall be called with explicit step argument, and the rounded value returned by method Value() may be not coherent with the step and range.
A scope can be created with option "infinite". This is useful when the number of steps is not known by the time of the scope creation. In this case the progress will be advanced logarithmically, approaching the end of the scope at infinite number of steps. The parameter Max for infinite scope indicates number of steps corresponding to mid-range.
A progress scope created with empty constructor is not connected to any progress indicator, and passing the range created on it to any algorithm allows it executing safely without actual progress indication.
Example of preparation of progress indicator:
Example of usage in sequential process:
Example of usage in nested cycle:
Example of use in function:
Example of usage in parallel process:
For lightweight algorithms that do not need advancing the progress within individual tasks the code can be simplified to avoid inner scopes:
Constructors(3)
- constructor(theRange: Message_ProgressRange, theName: TCollection_AsciiString, theMax: number, isInfinite?: boolean): Message_ProgressScopeParameters (4)
theRangetheNametheMaxisInfinite
- constructor(theRange: Message_ProgressRange, theName: Message_ProgressScope_NullString, theMax: number, isInfinite?: boolean): Message_ProgressScopeParameters (4)
theRangetheNametheMaxisInfinite
Instance methods(13)
- SetName(theName: TCollection_AsciiString): voidParameters (1)
theName
- UserBreak(): boolean
- More(): boolean
- Next(theStep?: number): Message_ProgressRangeParameters (1)
theStep
- Show(): void
- IsActive(): boolean
- Name(): string
- MaxValue(): number
- Value(): number
- IsInfinite(): boolean
- GetPortion(): number
- Close(): void
Message_ProgressSentry
Functionality of this class (Message_ProgressSentry) has been superseded by Message_ProgressScope. This class is kept just to simplify transition of an old code and will be removed in future.
Constructors(1)
- constructor(theRange: Message_ProgressRange, theName: string, theMin: number, theMax: number, theStep: number, theIsInf?: boolean, theNewScopeSpan?: number): Message_ProgressSentry
Deprecated constructor,
Message_ProgressScopeshould be created instead.Parameters (7)theRangetheNametheMintheMaxtheSteptheIsInftheNewScopeSpan
Instance methods(1)
- Relieve(): void
Method
Relieve()was replaced byClose()inMessage_ProgressScope.
Message_Report
Container for alert messages, sorted according to their gravity.
For each gravity level, alerts are stored in simple list. If alert being added can be merged with another alert of the same type already in the list, it is merged and not added to the list.
This class is intended to be used as follows:
- In the process of execution, algorithm fills report by alert objects using methods
AddAlert() - The result can be queried for presence of particular alert using methods
HasAlert() - The reports produced by nested or sequentially executed algorithms can be collected in one using method
Merge() - The report can be shown to the user either as plain text with method
Dump()or in more advanced way, by iterating over lists returned byGetAlerts() - Report can be cleared by methods
Clear()(usually after reporting)
Message_PrinterToReportis a printer in Messenger to convert data sent to messenger into report
Constructors(1)
Empty constructor.
Static methods(2)
- get_type_name(): string
Instance methods(16)
- GetAlerts(theGravity: Message_Gravity): NCollection_List_handle_Message_Alert
Returns list of collected alerts with specified gravity.
Parameters (1)theGravity
- HasAlert(theType: Standard_Type): boolean
Returns true if specific type of alert is recorded.
Parameters (1)theType
- HasAlert(theType: Standard_Type, theGravity: Message_Gravity): boolean
Returns true if specific type of alert is recorded with specified gravity.
Parameters (2)theTypetheGravity
- AddLevel(theLevel: Message_Level, theName: TCollection_AsciiString): void
Add new level of alerts.
Parameters (2)theLevel—a leveltheName
- RemoveLevel(theLevel: Message_Level): void
Remove level of alerts.
Parameters (1)theLevel
- Clear(): void
Clears all collected alerts.
- Clear(theGravity: Message_Gravity): void
Clears collected alerts with specified gravity.
Parameters (1)theGravity
- Clear(theType: Standard_Type): void
Clears collected alerts with specified type.
Parameters (1)theType
Returns computed metrics when alerts are performed.
- SetActiveMetric(theMetricType: Message_MetricType, theActivate: boolean): void
Sets metrics to compute when alerts are performed.
Parameters (2)theMetricTypetheActivate
- ClearMetrics(): void
Removes all activated metrics.
- Limit(): number
Returns maximum number of collecting alerts. If the limit is achieved, first alert is removed, the new alert is added in the container.
Returnsthe limit value
- SetLimit(theLimit: number): void
Sets maximum number of collecting alerts.
Parameters (1)theLimit—limit value
- Merge(theOther: Message_Report): void
Merges data from theOther report into this.
Parameters (1)theOther
- Merge(theOther: Message_Report, theGravity: Message_Gravity): void
Merges alerts with specified gravity from theOther report into this.
Parameters (2)theOthertheGravity