Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches

Contains information of the current progress of a task being performed. More...

#include <ms_progress_info.hpp>

Public Types

enum  STATUS {
  S_NOT_STARTED ,
  S_RUNNING ,
  S_RUNNING_INDETERMINATE ,
  S_STOPPED_FAIL ,
  S_STOPPED_BREAK ,
  S_STOPPED_COMPLETE
}
 Enum containing progress status information values. More...
 

Public Member Functions

 ms_progress_info ()
 Default constructor; for standard library collections.
 
 ms_progress_info (const std::string &description, size_t total)
 Constructor.
 
 ~ms_progress_info ()
 Destructor.
 
void addSubtask (const ms_progress_info *task)
 Adds the passed ms_progress_info item as a subtask.
 
ms_progress_infoaddSubtask (const std::string &description, size_t total)
 Adds a subtask with the specified description and total number of items.
 
void clear (const std::string &description="", size_t total=0)
 Clear any existing progress information ready to start a new long running operation using the same process names.
 
const std::string & getDescription () const
 Returns the task description.
 
int getNumberOfSubtasks () const
 Returns the total number of child ms_progress_info objects associated directly with the ms_progress_info instance.
 
size_t getProgress () const
 Returns the number of work items currently completed by the process running the task.
 
STATUS getStatus () const
 Gets the current ms_progress_info::STATUS associated with the task.
 
const ms_progress_infogetSubtaskProgress (int index) const
 Returns the child ms_progress_info object at the specified index.
 
size_t getTotal () const
 Returns the total number of work items the task is expected to complete.
 
bool isBreaking () const
 Returns whether or not a break request has been made by the user/client software.
 
void removeSubtask (int index)
 Removes and deletes the child ms_progress_info object at the specified index.
 
void setBreak () const
 Sends a break/cancel request to this and all child ms_progress_info tasks.
 
void updateBreak ()
 Updates the status to a break state.
 
void updateComplete ()
 Updates the status to a completed state.
 
void updateFail ()
 Updates the status to a fail state.
 
void updateIndeterminate ()
 Updates the status to an indeterminate running state.
 
void updateProgress (size_t progress, size_t total)
 Updates the current progress and total number of work items with the passed values.
 

Detailed Description

Contains information of the current progress of a task being performed.

If there are sub-jobs that are carried out then these are represented as child objects.

Member Enumeration Documentation

◆ STATUS

enum STATUS

Enum containing progress status information values.

Enumerator
S_NOT_STARTED 

Task has not started.

S_RUNNING 

Task is currently running.

S_RUNNING_INDETERMINATE 

Task is running but progress is indeterminate.

S_STOPPED_FAIL 

Task failed.

S_STOPPED_BREAK 

Task was cancelled by the user.

S_STOPPED_COMPLETE 

Task completed successfully.

Constructor & Destructor Documentation

◆ ms_progress_info()

ms_progress_info ( const std::string &  description,
size_t  total 
)

Constructor.

Creates a new ms_progress_info object with the specified description and total number of items

Parameters
descriptionThe task description associated with the generated ms_progress_info object
totalThe total number of jobs the task will complete

◆ ~ms_progress_info()

Destructor.

The desctrutor deletes all subtasks that it has created

If a subtask has been created by calling addSubtask(const std::string & description, size_t) then the object will be deleted here by the parent object.

If an ms_progress_info object was created separately, and then added as a subtask, by calling: addSubtask(const ms_progress_info *), then it won't be deleted in this destructor. It's up to the code that created it to perform the deletion after any object(s) it was added to have been deleted.

Member Function Documentation

◆ getDescription()

const std::string & getDescription ( ) const

Returns the task description.

Returns
The task description

◆ getNumberOfSubtasks()

int getNumberOfSubtasks ( ) const

Returns the total number of child ms_progress_info objects associated directly with the ms_progress_info instance.

Only the number of direct child items is returned.

Returns
The number of child ms_progress_info objects

◆ getProgress()

size_t getProgress ( ) const

Returns the number of work items currently completed by the process running the task.

See also
getTotal()
Returns
The number of items the task has completed.

◆ getStatus()

ms_progress_info::STATUS getStatus ( ) const

Gets the current ms_progress_info::STATUS associated with the task.

Returns
The current status of the task associated with the ms_progress_info object

◆ getSubtaskProgress()

const ms_progress_info * getSubtaskProgress ( int  index) const

Returns the child ms_progress_info object at the specified index.

See also
getNumberOfSubtasks()
Parameters
indexThe index of the subtask to return. Must be in the range 1 .. getNumberOfSubtasks()
Returns
The ms_progress_info object at the specified index, or NULL is the passed value of index is invalid.

◆ getTotal()

size_t getTotal ( ) const

Returns the total number of work items the task is expected to complete.

See also
getProgress()
Returns
The total number of items the task is expected to complete

◆ setBreak()

void setBreak ( ) const

Sends a break/cancel request to this and all child ms_progress_info tasks.

Use from the client code to request that a long running process is cancelled. It is the responsibility of the process running the task to honour the break request.


The documentation for this class was generated from the following files: