## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# csTextProgressMeter Class Reference

The csTextProgressMeter class displays a simple percentage-style textual progress meter. More...

`#include <csutil/cspmeter.h>`

Inheritance diagram for csTextProgressMeter:

[legend]
List of all members.

## Public Member Functions

virtual void | Abort ()
| Abort the meter.
| csTextProgressMeter (iConsoleOutput *console, int total=100)
| Constructs a new progress meter.
virtual void | Finalize ()
| Finalize the meter (i.e. we completed the task sooner than expected).
virtual int | GetCurrent () const
| Get the current value of the meter (<= total).
virtual int | GetGranularity () const
| Get the refresh granularity.
int | GetTickScale () const
| Get the tick scale.
virtual int | GetTotal () const
| Get the total element count represented by the meter.
virtual void | Reset ()
| Reset the meter to 0%.
virtual void | Restart ()
| Reset the meter and print the initial tick mark ("0%").
virtual void | SetGranularity (int)
| Set the refresh granularity.
virtual void | SetProgressDescription (const char *, const char *,...)
| Set the id and description of what we are currently monitoring.
virtual void | SetProgressDescriptionV (const char *, const char *, va_list)
| Set the id and description of what we are currently monitoring.
void | SetTickScale (int)
| Set the tick scale.
virtual void | SetTotal (int n)
| Set the total element count represented by the meter and perform a reset.
virtual void | Step (unsigned int n=1)
| Increment the meter by n units (default 1) and print a tick mark.
virtual | ~csTextProgressMeter ()
| Destroys the progress meter.

## Detailed Description

The csTextProgressMeter class displays a simple percentage-style textual progress meter.

By default, the meter is presented to the user by passing CS_MSG_INITIALIZATION to the system print function. This setting may be changed with the SetMessageType() method. After constructing a progress meter, call SetTotal() to set the total number of steps represented by the meter. The default is 100. To animate the meter, call the Step() method each time a unit of work has been completed. At most Step() should be called 'total' times. Calling Step() more times than this will not break anything, but if you do so, then the meter will not accurately reflect the progress being made. Calling Reset() will reset the meter to zero, but will not update the display. Reset() is provided so that the meter can be re-used, but it is the client's responsibility to ensure that the display is in a meaningful state. For instance, the client should probably ensure that a newline '
' has been printed before re-using a meter which has been reset. The complementary method Restart() both resets the meter and prints the initial tick mark ("0%"). The meter does not print a newline after 100% has been reached, on the assumption that the client may wish to print some text on the same line on which the meter appeared. If the client needs a newline printed after 100% has been reached, then it is the client's responsibility to print it.

Definition at line 55 of file cspmeter.h.

## Constructor & Destructor Documentation

csTextProgressMeter::csTextProgressMeter | ( | iConsoleOutput * | console,
|  | int | total = `100`
| ) |

| Constructs a new progress meter.

virtual csTextProgressMeter::~csTextProgressMeter | ( |  | ) | `[virtual]`

| Destroys the progress meter.

## Member Function Documentation

virtual void csTextProgressMeter::Abort | ( |  | ) | `[virtual]`

| Abort the meter. Implements iProgressMeter.

virtual void csTextProgressMeter::Finalize | ( |  | ) | `[virtual]`

| Finalize the meter (i.e. we completed the task sooner than expected). Implements iProgressMeter.

virtual int csTextProgressMeter::GetCurrent | ( |  | ) | const`[inline, virtual]`

| Get the current value of the meter (<= total). Implements iProgressMeter. Definition at line 108 of file cspmeter.h.

virtual int csTextProgressMeter::GetGranularity | ( |  | ) | const`[inline, virtual]`

| Get the refresh granularity. Implements iProgressMeter. Definition at line 118 of file cspmeter.h.

int csTextProgressMeter::GetTickScale | ( |  | ) | const`[inline]`

| Get the tick scale. Definition at line 80 of file cspmeter.h.

virtual int csTextProgressMeter::GetTotal | ( |  | ) | const`[inline, virtual]`

| Get the total element count represented by the meter. Implements iProgressMeter. Definition at line 106 of file cspmeter.h.

virtual void csTextProgressMeter::Reset | ( |  | ) | `[inline, virtual]`

| Reset the meter to 0%. Implements iProgressMeter. Definition at line 95 of file cspmeter.h.

virtual void csTextProgressMeter::Restart | ( |  | ) | `[virtual]`

| Reset the meter and print the initial tick mark ("0%"). Implements iProgressMeter.

virtual void csTextProgressMeter::SetGranularity | ( | int |  | ) | `[virtual]`

| Set the refresh granularity. Valid values are 1-100, inclusive. Default is 10. The meter is only refreshed after each "granularity" * number of units have passed. For instance, if granularity is 20, then * the meter will only be updated at most 5 times, or every 20%. Implements iProgressMeter.

virtual void csTextProgressMeter::SetProgressDescription | ( | const char * | ,
|  | const char * | ,
|  |  | ...
| ) | `[inline, virtual]`

Set the id and description of what we are currently monitoring.

An id can be something like "crystalspace.engine.lighting.calculation".

See also:
  Notes about string formatting in Crystal Space

Implements iProgressMeter.

Definition at line 88 of file cspmeter.h.

virtual void csTextProgressMeter::SetProgressDescriptionV | ( | const char * | ,
|  | const char * | ,
|  | va_list |
| ) | `[inline, virtual]`

Set the id and description of what we are currently monitoring.

An id can be something like "crystalspace.engine.lighting.calculation".

See also:
  Notes about string formatting in Crystal Space

Implements iProgressMeter.

Definition at line 90 of file cspmeter.h.

void csTextProgressMeter::SetTickScale | ( | int |  | ) |

| Set the tick scale. Valid values are 1-100, inclusive. Default is 2. A value of 1 means that each printed tick represents one unit, thus a total of 100 ticks will be printed. A value of 2 means that each tick represents two units, thus a total of 50 ticks will be printed, etc.

virtual void csTextProgressMeter::SetTotal | ( | int | n | ) | `[inline, virtual]`

| Set the total element count represented by the meter and perform a reset. Implements iProgressMeter. Definition at line 104 of file cspmeter.h.

virtual void csTextProgressMeter::Step | ( | unsigned int | n = `1` | ) | `[virtual]`

| Increment the meter by n units (default 1) and print a tick mark. Implements iProgressMeter.

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

- csutil/cspmeter.h