~youscribe/parted/3.1

« back to all changes in this revision

Viewing changes to include/parted/timer.in.h

  • Committer: Guilhem Lettron
  • Date: 2012-10-22 14:37:59 UTC
  • Revision ID: guilhem+ubuntu@lettron.fr-20121022143759-m403kecgz13sknvp
3.1 from tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    libparted - a library for manipulating disk partitions
 
3
    Copyright (C) 2001-2002, 2007, 2009-2012 Free Software Foundation, Inc.
 
4
 
 
5
    This program is free software; you can redistribute it and/or modify
 
6
    it under the terms of the GNU General Public License as published by
 
7
    the Free Software Foundation; either version 3 of the License, or
 
8
    (at your option) any later version.
 
9
 
 
10
    This program is distributed in the hope that it will be useful,
 
11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
    GNU General Public License for more details.
 
14
 
 
15
    You should have received a copy of the GNU General Public License
 
16
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
17
*/
 
18
 
 
19
/**
 
20
 * \addtogroup PedTimer
 
21
 * @{
 
22
 */
 
23
 
 
24
/** \file timer.h */
 
25
 
 
26
#ifndef PED_TIMER_H_INCLUDED
 
27
#define PED_TIMER_H_INCLUDED
 
28
 
 
29
#include <time.h>
 
30
 
 
31
typedef struct _PedTimer PedTimer;
 
32
 
 
33
typedef void PedTimerHandler (PedTimer* timer, void* context);
 
34
 
 
35
/*
 
36
 * Structure keeping track of progress and time
 
37
 */
 
38
struct _PedTimer {
 
39
        float                   frac;           /**< fraction of operation done */
 
40
        time_t                  start;          /**< time of start of op */
 
41
        time_t                  now;            /**< time of last update (now!) */
 
42
        time_t                  predicted_end;  /**< expected finish time */
 
43
        const char*             state_name;     /**< eg: "copying data" */
 
44
        PedTimerHandler*        handler;        /**< who to notify on updates */
 
45
        void*                   context;        /**< context to pass to handler */
 
46
};
 
47
 
 
48
extern PedTimer* ped_timer_new (PedTimerHandler* handler, void* context);
 
49
extern void ped_timer_destroy (PedTimer* timer);
 
50
 
 
51
/* a nested timer automatically notifies it's parent.  You should only
 
52
 * create one when you are going to use it (not before)
 
53
 */
 
54
extern PedTimer* ped_timer_new_nested (PedTimer* parent, float nest_frac);
 
55
extern void ped_timer_destroy_nested (PedTimer* timer);
 
56
 
 
57
extern void ped_timer_touch (PedTimer* timer);
 
58
extern void ped_timer_reset (PedTimer* timer);
 
59
extern void ped_timer_update (PedTimer* timer, float new_frac);
 
60
extern void ped_timer_set_state_name (PedTimer* timer, const char* state_name);
 
61
 
 
62
#endif /* PED_TIMER_H_INCLUDED */
 
63
 
 
64
 
 
65
/** @} */