+ /**
+ * Manually fire the timer event. Usually, the timer event will be
+ * fired when the timer expires, but this can be used to fire it
+ * prematurely. If the timer is scheduled, it will be invalidated. If
+ * the timer is already invalid (but is initialized with an event
+ * handler), the event will be fired and the timer will remain invalid.
+ * \param t The absolute time passed to the timer event function.
+ */
+ void fire(scalar t = ticks());
+
+
+ /**
+ * Fire the timer event if it is expired.
+ * \param t The absolute time used as a reference to determine if the
+ * timer is expired; defaults to the current time.
+ * \return The absolute time of the next expiration (if repeating), or
+ * 0.0 otherwise.
+ */
+ scalar fire_if_expired(scalar t = ticks())
+ {
+ if (is_expired()) fire();
+ return absolute_;
+ }
+
+
+ /**
+ * Get the number of seconds remaining before the timer is scheduled to
+ * expired. If the timer is invalid, the retured value will be
+ * negative.
+ * \param t The absolute time used as a reference to determine the
+ * amount of time left; defaults to the current time.
+ * \return Seconds.
+ */
+ scalar seconds_remaining(scalar t = ticks()) const
+ {
+ return next_expiration() - t;
+ }
+
+ /**
+ * Get the absolute time of the next expiration of this timer.
+ * \return Seconds.
+ */
+ scalar next_expiration() const
+ {
+ return absolute_;
+ }
+
+
+ /**
+ * Get whether or not the timer is expired. A timer on a repeating
+ * schedule will never be expired since it will always have a scheduled
+ * expiration time in the future. If the timer is expired but not
+ * invalid, the timer event has not yet fired; the timer will be
+ * invalidated when it does fire.
+ * \param t The absolute time used as a reference to determine if the
+ * timer is expired; defaults to the current time.
+ * \return True if the timer is expired, false otherwise.
+ */
+ bool is_expired(scalar t = ticks()) const
+ {
+ return seconds_remaining(t) < SCALAR(0.0);
+ }
+
+ /**
+ * Get whether or not the timer is on a repeating schedule.
+ * \return True if the timer is repeating, false otherwise.
+ */
+ bool is_repeating() const
+ {
+ return mode_ == repeat;
+ }