Typedefs | Functions

Counter
[Utilities]

Collaboration diagram for Counter:

Typedefs

typedef int(* imCounterCallback )(int counter, void *user_data, const char *text, int progress)

Functions

imCounterCallback imCounterSetCallback (void *user_data, imCounterCallback counter_func)
int imCounterHasCallback (void)
int imCounterBegin (const char *title)
void imCounterEnd (int counter)
int imCounterInc (int counter)
int imCounterIncTo (int counter, int count)
void imCounterTotal (int counter, int total, const char *message)
void * imCounterGetUserData (int counter)
void imCounterSetUserData (int counter, void *userdata)

Detailed Description

Used to notify the application that a step in the loading, saving or processing operation has been performed.
See im_counter.h

Typedef Documentation

typedef int(* imCounterCallback)(int counter, void *user_data, const char *text, int progress)

Counter callback, informs the progress of the operation to the client.
Text contains a constant string that is NULL during normal counting, a title in the begining of a sequence and a message in the begining of a count. Counter id identifies diferrent counters.
Progress in a count reports a value from 0 to 1000. If -1 indicates the start of a sequence of operations, 1001 ends the sequence.
If returns 0 the client should abort the operation.
If the counter is aborted, the callback will be called one last time at 1001.


Function Documentation

imCounterCallback imCounterSetCallback ( void *  user_data,
imCounterCallback  counter_func 
)

Changes the counter callback. Returns old callback.
User data is changed only if not NULL.

int imCounterHasCallback ( void   ) 

Returns true if the counter callback is set. When the callback is NULL the counter is inactive and all functions do nothing.

int imCounterBegin ( const char *  title  ) 

Begins a new count, or a partial-count in a sequence.
Calls the callback with "-1" and text=title, if it is at the top level.
This is to be used by the operations. Returns a counter Id.

void imCounterEnd ( int  counter  ) 

Ends a count, or a partial-count in a sequence.
Calls the callback with "1001", text=null, and releases the counter if it is at top level count.

int imCounterInc ( int  counter  ) 

Increments a count. Must set the total first.
Calls the callback, text=message if it is the first increment for the count.
Returns 0 if the callback aborted, 1 if returns normally.

int imCounterIncTo ( int  counter,
int  count 
)

Set a specific count. Must set the total first.
Calls the callback, text=message if it is the first increment for the count.
Returns 0 if the callback aborted, 1 if returns normally.

void imCounterTotal ( int  counter,
int  total,
const char *  message 
)

Sets the total increments of a count.

void* imCounterGetUserData ( int  counter  ) 

Sets an additional user data in the counter. Used to save the lock in multi-threaded configurations.

void imCounterSetUserData ( int  counter,
void *  userdata 
)

Returns the additional user data in the counter.