1 /** \file 2 * \brief Processing Counter 3 * 4 * See Copyright Notice in im_lib.d 5 */ 6 7 module im.counter; 8 9 extern (C) @safe nothrow: 10 11 /** \defgroup counter Counter 12 * \par 13 * Used to notify the application that a step in the loading, saving or processing operation has been performed. 14 * \par 15 * See \ref im_counter.h 16 * \ingroup util */ 17 18 /** Counter callback, informs the progress of the operation to the client. \n 19 * Text contains a constant string that is NULL during normal counting, a title in the begining of a sequence 20 * and a message in the begining of a count. 21 * Counter id identifies diferrent counters. \n 22 * Progress in a count reports a value from 0 to 1000. 23 * If -1 indicates the start of a sequence of operations, 1001 ends the sequence. \n 24 * If returns 0 the client should abort the operation. \n 25 * If the counter is aborted, the callback will be called one last time at 1001. 26 * \ingroup counter */ 27 alias imCounterCallback = int function(int counter, void* user_data, const(char) * text, int progress); 28 29 /** Changes the counter callback. Returns old callback. \n 30 * User data is changed only if not NULL. 31 * \ingroup counter */ 32 imCounterCallback imCounterSetCallback(void* user_data, imCounterCallback counter_func); 33 34 /** Returns true if the counter callback is set. 35 * When the callback is NULL the counter is inactive and all functions do nothing. 36 * \ingroup counter */ 37 int imCounterHasCallback(); 38 39 /** Begins a new count, or a partial-count in a sequence. \n 40 * Calls the callback with "-1" and text=title, if it is at the top level. \n 41 * This is to be used by the operations. Returns a counter Id. 42 * \ingroup counter */ 43 int imCounterBegin(const(char) * title); 44 45 /** Ends a count, or a partial-count in a sequence. \n 46 * Calls the callback with "1001", text=null, and releases the counter if it is at top level count. \n 47 * \ingroup counter */ 48 void imCounterEnd(int counter); 49 50 /** Increments a count. Must set the total first. \n 51 * Calls the callback, text=message if it is the first increment for the count. \n 52 * Returns 0 if the callback aborted, 1 if returns normally. 53 * \ingroup counter */ 54 int imCounterInc(int counter); 55 56 /** Set a specific count. Must set the total first. \n 57 * Calls the callback, text=message if it is the first increment for the count. \n 58 * Returns 0 if the callback aborted, 1 if returns normally. 59 * \ingroup counter */ 60 int imCounterIncTo(int counter, int count); 61 62 /** Sets the total increments of a count. 63 * \ingroup counter */ 64 void imCounterTotal(int counter, int total, const(char) * message); 65 66 /** Sets an additional user data in the counter. 67 * Used to save the lock in multi-threaded configurations. 68 * \ingroup counter */ 69 void* imCounterGetUserData(int counter); 70 71 /** Returns the additional user data in the counter. 72 * \ingroup counter */ 73 void imCounterSetUserData(int counter, void* userdata); 74