Status context, allows cancel checking and progress reporting. More...
#include <mi32/mistatus.h>
Public Member Functions | |
| MISTATUSCONTEXT (const MISTRING &taskstr, bool AllowCancel=true, bool CreateMgrIfNoActive=false) | |
| MISTATUSCONTEXT (MISTATUSMANAGER *pStatusMgr, const MISTRING &taskstr, bool AllowCancel=true) | |
| MISTATUSCONTEXT () | |
| ~MISTATUSCONTEXT () | |
| ERRVALUE | Create (const MISTRING &taskstr, bool AllowCancel=true, bool CreateMgrIfNoActive=false) |
| ERRVALUE | Create (MISTATUSMANAGER *pStatusMgr, const MISTRING &taskstr, bool AllowCancel=true) |
| MISTATUSMANAGER * | GetManager () const |
| MISTATUSMANAGER::CONTEXT_PRIV * | GetPriv () const |
| bool | HasManager () const |
| bool | IsCancelled () |
| ERRVALUE | ReportMessage (const MISTRING &msgstr) |
| ERRVALUE | ReportProgress (double pctdone=-1) |
| ERRVALUE | ReportProgressBegin (UINT32 NumSteps) |
| ERRVALUE | ReportProgressIncrement (INT32 IncSteps=1) |
| void | ReportProgressIncrementNoCancel (INT32 IncSteps=1) |
| void | ReportProgressNoCancel (double pctdone=-1) |
| void | SetCancelled () |
Status context, allows cancel checking and progress reporting.
Do not inherit from this class.
This class is designed to be constructed on the stack at the beginning of a task so when it goes out of scope the ending report will be made.
Example using active status manager:
ERRVALUE DoTask ( ) { ERRVALUE err; MISTATUSCONTEXT context(TEXTID_TaskName); context.ReportProgressBegin(NumSteps); for (int step = 0; (step < NumSteps); ++step) { if ((err = context.ReportProgressIncrement()) < 0) return (err); } return (0); }
Example using specified status manager and percentage:
ERRVALUE DoTask ( MISTATUSMANAGER *pStatusMgr ) { ERRVALUE err; MISTATUSCONTEXT context(pStatusMgr,TEXTID_TaskName); for (int step = 0; (step < NumSteps); ++step) { if ((err = context.ReportProgress(100.0*step/NumSteps)) < 0) return (err); } return (0); }
| MISTATUSCONTEXT::MISTATUSCONTEXT | ( | ) |
Construct without status manager.
Use Create() to setup with status manager.
| MISTATUSCONTEXT::MISTATUSCONTEXT | ( | MISTATUSMANAGER * | pStatusMgr, | |
| const MISTRING & | taskstr, | |||
| bool | AllowCancel = true | |||
| ) |
Construct using specified status manager.
| pStatusMgr | Status manager, if 0 then context will not report to any manager | |
| taskstr | Task description | |
| AllowCancel | Whether to allow cancel for this task |
| MISTATUSCONTEXT::MISTATUSCONTEXT | ( | const MISTRING & | taskstr, | |
| bool | AllowCancel = true, |
|||
| bool | CreateMgrIfNoActive = false | |||
| ) |
Construct using active status manager.
| taskstr | Task description | |
| AllowCancel | Whether to allow cancel for this task | |
| CreateMgrIfNoActive | Create own status manager if no active one set |
| MISTATUSCONTEXT::~MISTATUSCONTEXT | ( | ) |
Destructor.
| ERRVALUE MISTATUSCONTEXT::Create | ( | const MISTRING & | taskstr, | |
| bool | AllowCancel = true, |
|||
| bool | CreateMgrIfNoActive = false | |||
| ) | [inline] |
Create with active status manager.
Should only be used if default constructor was also used.
| taskstr | Task description | |
| AllowCancel | Whether to allow cancel for this task | |
| CreateMgrIfNoActive | Create own status manager if no active one set |
| ERRVALUE MISTATUSCONTEXT::Create | ( | MISTATUSMANAGER * | pStatusMgr, | |
| const MISTRING & | taskstr, | |||
| bool | AllowCancel = true | |||
| ) | [inline] |
Create with specified status manager.
Should only be used if default constructor was also used.
| pStatusMgr | Status manager, if 0 then context will not report to any manager | |
| taskstr | Task description | |
| AllowCancel | Whether to allow cancel for this task |
| MISTATUSMANAGER* MISTATUSCONTEXT::GetManager | ( | ) | const [inline] |
Get attached status manager.
| MISTATUSMANAGER::CONTEXT_PRIV* MISTATUSCONTEXT::GetPriv | ( | ) | const [inline] |
Get private manager-specific information.
| bool MISTATUSCONTEXT::HasManager | ( | ) | const [inline] |
Determine if attached to a status manager.
| bool MISTATUSCONTEXT::IsCancelled | ( | ) | [inline] |
Check if operation has been cancelled.
Report message.
Should not be used to report start/end of task, that is handled by ctor/dtor.
| ERRVALUE MISTATUSCONTEXT::ReportProgress | ( | double | pctdone = -1 |
) | [inline] |
Report progress by percentage.
| pctdone | Percentage complete, -1 indicates indeterminant |
Begin report of progress with known number of steps.
| NumSteps | Total number of steps for task |
Increment report of progress with known number of steps.
| IncSteps | Number of steps to increment by |
| void MISTATUSCONTEXT::ReportProgressIncrementNoCancel | ( | INT32 | IncSteps = 1 |
) | [inline] |
Increment report of progress without check for cancel.
| IncSteps | Number of steps to increment by |
| void MISTATUSCONTEXT::ReportProgressNoCancel | ( | double | pctdone = -1 |
) | [inline] |
Report progress by percentage without cancel check.
| pctdone | Percentage complete, -1 indicates indeterminant |
| void MISTATUSCONTEXT::SetCancelled | ( | ) | [inline] |
Set that context is cancelled.
1.6.1