source: appstream-generator/build/girepo/glib/Timer.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 3.6 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module glib.Timer;
22
23private import gi.glib;
24public  import gi.glibtypes;
25private import glib.ConstructionException;
26
27
28/**
29 * Opaque datatype that records a start time.
30 */
31public class Timer
32{
33        /** the main Gtk struct */
34        protected GTimer* gTimer;
35        protected bool ownedRef;
36
37        /** Get the main Gtk struct */
38        public GTimer* getTimerStruct()
39        {
40                return gTimer;
41        }
42
43        /** the main Gtk struct as a void* */
44        protected void* getStruct()
45        {
46                return cast(void*)gTimer;
47        }
48
49        /**
50         * Sets our main struct and passes it to the parent class.
51         */
52        public this (GTimer* gTimer, bool ownedRef = false)
53        {
54                this.gTimer = gTimer;
55                this.ownedRef = ownedRef;
56        }
57
58
59        /**
60         * Resumes a timer that has previously been stopped with
61         * g_timer_stop(). g_timer_stop() must be called before using this
62         * function.
63         *
64         * Since: 2.4
65         */
66        public void continu()
67        {
68                g_timer_continue(gTimer);
69        }
70
71        /**
72         * Destroys a timer, freeing associated resources.
73         */
74        public void destroy()
75        {
76                g_timer_destroy(gTimer);
77        }
78
79        /**
80         * If @timer has been started but not stopped, obtains the time since
81         * the timer was started. If @timer has been stopped, obtains the
82         * elapsed time between the time it was started and the time it was
83         * stopped. The return value is the number of seconds elapsed,
84         * including any fractional part. The @microseconds out parameter is
85         * essentially useless.
86         *
87         * Params:
88         *     microseconds = return location for the fractional part of seconds
89         *         elapsed, in microseconds (that is, the total number
90         *         of microseconds elapsed, modulo 1000000), or %NULL
91         *
92         * Returns: seconds elapsed as a floating point value, including any
93         *     fractional part.
94         */
95        public double elapsed(gulong* microseconds)
96        {
97                return g_timer_elapsed(gTimer, microseconds);
98        }
99
100        /**
101         * This function is useless; it's fine to call g_timer_start() on an
102         * already-started timer to reset the start time, so g_timer_reset()
103         * serves no purpose.
104         */
105        public void reset()
106        {
107                g_timer_reset(gTimer);
108        }
109
110        /**
111         * Marks a start time, so that future calls to g_timer_elapsed() will
112         * report the time since g_timer_start() was called. g_timer_new()
113         * automatically marks the start time, so no need to call
114         * g_timer_start() immediately after creating the timer.
115         */
116        public void start()
117        {
118                g_timer_start(gTimer);
119        }
120
121        /**
122         * Marks an end time, so calls to g_timer_elapsed() will return the
123         * difference between this end time and the start time.
124         */
125        public void stop()
126        {
127                g_timer_stop(gTimer);
128        }
129
130        /**
131         * Creates a new timer, and starts timing (i.e. g_timer_start() is
132         * implicitly called for you).
133         *
134         * Returns: a new #GTimer.
135         *
136         * Throws: ConstructionException GTK+ fails to create the object.
137         */
138        public this()
139        {
140                auto p = g_timer_new();
141               
142                if(p is null)
143                {
144                        throw new ConstructionException("null returned by new");
145                }
146               
147                this(cast(GTimer*) p);
148        }
149}
Note: See TracBrowser for help on using the repository browser.