Statistics
| Branch: | Revision:

root / src / common / progressmonitor.h @ 81ad8b66

History | View | Annotate | Download (3.05 KB)

1 01873262 Georg Kunz
//=========================================================================
2
//  PROGRESSMONITOR.H - part of
3
//
4
//                  OMNeT++/OMNEST
5
//           Discrete System Simulation in C++
6
//
7
//  Author: Tamas Borbely
8
//
9
//=========================================================================
10
11
/*--------------------------------------------------------------*
12
  Copyright (C) 2006-2008 OpenSim Ltd.
13

14
  This file is distributed WITHOUT ANY WARRANTY. See the file
15
  `license' for details on this and other legal matters.
16
*--------------------------------------------------------------*/
17
18
#ifndef _PROGRESSMONITOR_H_
19
#define _PROGRESSMONITOR_H_
20
21
#include <string>
22
#include "platdefs.h"
23
24
NAMESPACE_BEGIN
25
26
/**
27
 * Interface for reporting progress. Compatible with Eclipse's IProgressMonitor class.
28
 */
29
class IProgressMonitor
30
{
31
    public:
32
33
    virtual ~IProgressMonitor() {}
34
35
    /* Constant indicating an unknown amount of work. */
36
    static const int UNKNOWN = -1;
37
38
    /**
39
     * Notifies that the main task is beginning.  This must only be called once
40
     * on a given progress monitor instance.
41
     *
42
     * @param name the name (or description) of the main task
43
     * @param totalWork the total number of work units into which
44
     *  the main task is been subdivided. If the value is <code>UNKNOWN</code>
45
     *  the implementation is free to indicate progress in a way which
46
     *  doesn't require the total number of work units in advance.
47
     */
48
    virtual void beginTask(std::string name, int totalWork) = 0;
49
50
    /**
51
     * Notifies that the work is done; that is, either the main task is completed
52
     * or the user canceled it. This method may be called more than once
53
     * (implementations should be prepared to handle this case).
54
     */
55
    virtual void done() = 0;
56
57
    /**
58
     * Returns whether cancelation of current operation has been requested.
59
     * Long-running operations should poll to see if cancelation
60
     * has been requested.
61
     *
62
     * @return <code>true</code> if cancellation has been requested,
63
     *    and <code>false</code> otherwise
64
     * @see #setCanceled(boolean)
65
     */
66
    virtual bool isCanceled() = 0;
67
68
    /**
69
     * Sets the cancel state to the given value.
70
     *
71
     * @param value <code>true</code> indicates that cancelation has
72
     *     been requested (but not necessarily acknowledged);
73
     *     <code>false</code> clears this flag
74
     * @see #isCanceled()
75
     */
76
    virtual void setCanceled(bool value) = 0;
77
78
    /**
79
     * Notifies that a subtask of the main task is beginning.
80
     * Subtasks are optional; the main task might not have subtasks.
81
     *
82
     * @param name the name (or description) of the subtask
83
     */
84
    virtual void subTask(std::string name) = 0;
85
86
    /**
87
     * Notifies that a given number of work unit of the main task
88
     * has been completed. Note that this amount represents an
89
     * installment, as opposed to a cumulative amount of work done
90
     * to date.
91
     *
92
     * @param work a non-negative number of work units just completed
93
     */
94
    virtual void worked(int work) = 0;
95
};
96
97
NAMESPACE_END
98
99
100
#endif