summaryrefslogtreecommitdiffstats
path: root/src/extension/timer.h
blob: ce9c495571e9c61c8e54dbdde1b9a0ef8bb3c27c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Here is where the extensions can get timed on when they load and
 * unload.  All of the timing is done in here.
 *
 * Authors:
 *   Ted Gould <ted@gould.cx>
 *
 * Copyright (C) 2004 Authors
 *
 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
 */

#ifndef INKSCAPE_EXTENSION_TIMER_H__
#define INKSCAPE_EXTENSION_TIMER_H__

#include <cstddef>
#include <sigc++/sigc++.h>
#include <glibmm/datetime.h>

namespace Inkscape {
namespace Extension {

class Extension;

class ExpirationTimer {
    /** \brief Circularly linked list of all timers */
    static ExpirationTimer * timer_list;
    /** \brief Which timer was on top when we started the idle loop */
    static ExpirationTimer * idle_start;
    /** \brief What the current timeout is (in seconds) */
    static long timeout;
    /** \brief Has the timer been started? */
    static bool timer_started;

    /** \brief Is this extension locked from being unloaded? */
    int locked;
    /** \brief Next entry in the list */
    ExpirationTimer * next;
    /** \brief When this timer expires */
    Glib::DateTime expiration;
    /** \brief What extension this function relates to */
    Extension * extension;

    bool expired() const;

    static bool idle_func ();
    static bool timer_func ();

public:
    ExpirationTimer(Extension * in_extension);
    virtual ~ExpirationTimer();

    void touch ();
    void lock ()   { locked++;  };
    void unlock () { locked--; };

    /** \brief Set the timeout variable */
    static void set_timeout (long in_seconds) { timeout = in_seconds; };
};

}; }; /* namespace Inkscape, Extension */

#endif /* INKSCAPE_EXTENSION_TIMER_H__ */

/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :