Hot Door CORE 0.8.2
Adobe® Illustrator® Plug-in Library
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
hdi::core::Timer Class Reference

Deals with timer registration and callbacks. More...

#include <hdicoreTimer.h>

Public Member Functions

 Timer ()
 Constructs an empty Timer object.
 
 Timer (const Timer &t_)
 Constructs a new Timer object from an existing Timer object (copy constructor)
 
 Timer (const std::string &name_, const double delay_, const Callback &responder_)
 Constructs a Timer object to fire a responder (target and action) in a given number of seconds.
 
virtual ~Timer ()
 Destructs a Timer object, deactivating the timer first.
 
virtual Timeroperator= (const Timer &rhs_)
 Assigns one Timer object to another.
 
virtual bool operator== (const Timer &rhs_) const
 Tests whether a given Timer object is the same as another.
 
virtual bool operator!= (const Timer &rhs_) const
 Tests whether a given Timer object is not the same as another.
 
virtual void destroy ()
 Destroys the timer, converting the target object to an empty Timer object (see the default constructor for more info on empty Timer objects)
 
virtual AITimerHandle aiTimerHandle () const
 Gets the timer handle around which the target object is wrapped.
 
virtual bool isEmpty () const
 Gets whether the target Timer object is empty (constructed with the default ctor)
 
virtual std::string name () const
 Gets the unique timer name.
 
virtual bool active () const
 Gets whether the timer is active.
 
virtual void setActive (const bool active_)
 Sets whether the timer is active.
 
virtual void activate ()
 Activates (enables) the timer.
 
virtual void deactivate ()
 Deactivates (disables) the timer, preventing it from firing.
 
virtual double delay () const
 Gets the delay in seconds for the target Timer object.
 
virtual void setDelay (const double delay_)
 Sets the delay in seconds for the target Timer object.
 
virtual Callback *const callback () const
 Gets the registered callback for the timer.
 
virtual void setCallback (const Callback &cb_)
 Sets the callback for the timer.
 

Friends

aip::Timer * __accessImpl (const Timer &)
 

Detailed Description

Deals with timer registration and callbacks.

Timers will fire over and over at the set delay until deactivate() is called (though they can be fired again later after activate() is called).

Constructor & Destructor Documentation

◆ Timer() [1/3]

hdi::core::Timer::Timer ( )

Constructs an empty Timer object.

Author
GW
Date
08/2013
Note
To test if a Timer object is empty, call isEmpty() on it
Empty Timer objects do not relate to any Illustrator timer; they are designed to be "receivers" of some other Timer object via the overloaded assignment operator. Empty Timer objects are useless until such time (though it is safe to call any of their methods).

◆ Timer() [2/3]

hdi::core::Timer::Timer ( const Timer t_)

Constructs a new Timer object from an existing Timer object (copy constructor)

Author
GW
Date
08/2013
Parameters
t_Existing Timer object

◆ Timer() [3/3]

hdi::core::Timer::Timer ( const std::string &  name_,
const double  delay_,
const Callback responder_ 
)

Constructs a Timer object to fire a responder (target and action) in a given number of seconds.

Author
GW
Date
08/2013
Parameters
name_Unique name for the timer, as UTF-8
delay_Delay in seconds before the responder should fire
responder_Target and action to fire after delay_ seconds

◆ ~Timer()

virtual hdi::core::Timer::~Timer ( )
virtual

Destructs a Timer object, deactivating the timer first.

Author
GW
Date
08/2013

Member Function Documentation

◆ activate()

virtual void hdi::core::Timer::activate ( )
virtual

Activates (enables) the timer.

Author
GW
Date
08/2013

◆ active()

virtual bool hdi::core::Timer::active ( ) const
virtual

Gets whether the timer is active.

Author
GW
Date
08/2013
Returns
true if the timer is enabled, false otherwise

◆ aiTimerHandle()

virtual AITimerHandle hdi::core::Timer::aiTimerHandle ( ) const
virtual

Gets the timer handle around which the target object is wrapped.

Author
GW
Date
11/2013
Returns
AITimerHandle for this object
Note
Generally, you shouldn't need to call this method. Only use it if you know what you're doing. If a specific piece of functionality provided by Illustrator is not handled by this class (or related classes), then it should probably be added to the hdi_core library.

◆ callback()

virtual Callback *const hdi::core::Timer::callback ( ) const
virtual

Gets the registered callback for the timer.

Author
GW
Date
08/2013
Returns
Currently registered timer callback, or NULL if none

◆ deactivate()

virtual void hdi::core::Timer::deactivate ( )
virtual

Deactivates (disables) the timer, preventing it from firing.

Author
GW
Date
08/2013

◆ delay()

virtual double hdi::core::Timer::delay ( ) const
virtual

Gets the delay in seconds for the target Timer object.

Author
GW
Date
08/2013
Returns
The number of seconds between firings of the timer callback

◆ destroy()

virtual void hdi::core::Timer::destroy ( )
virtual

Destroys the timer, converting the target object to an empty Timer object (see the default constructor for more info on empty Timer objects)

Author
GW
Date
03/2014
Precondition
If you have registered the timer with Dispatcher::registerTimer(), then be sure to unregister the timer before calling the destroy() method.
Note
This method must be called for any existing timers by the time the plugin is shutting down. If you no longer retain any of your own references to a timer then the lib will call this method for you as it is shutting down.

◆ isEmpty()

virtual bool hdi::core::Timer::isEmpty ( ) const
virtual

Gets whether the target Timer object is empty (constructed with the default ctor)

Author
GW
Date
08/2013
Returns
true if the target Timer object is empty, false otherwise

◆ name()

virtual std::string hdi::core::Timer::name ( ) const
virtual

Gets the unique timer name.

Author
GW
Date
08/2013
Returns
Name of the timer, as UTF-8

◆ operator!=()

virtual bool hdi::core::Timer::operator!= ( const Timer rhs_) const
virtual

Tests whether a given Timer object is not the same as another.

Author
GW
Date
08/2013
Parameters
rhs_Timer to compare against (righthand side of inequality operator)
Returns
true for the target and rhs_ being different timers, false otherwise

◆ operator=()

virtual Timer & hdi::core::Timer::operator= ( const Timer rhs_)
virtual

Assigns one Timer object to another.

Author
GW
Date
08/2013
Parameters
rhs_Existing Timer object to copy values from
Returns
The target Timer object, but with its values updated to match that of the rhs_ argument

◆ operator==()

virtual bool hdi::core::Timer::operator== ( const Timer rhs_) const
virtual

Tests whether a given Timer object is the same as another.

Author
GW
Date
08/2013
Parameters
rhs_Timer to compare against (righthand side of equality operator)
Returns
true for the target and rhs_ being the same timer, false otherwise

◆ setActive()

virtual void hdi::core::Timer::setActive ( const bool  active_)
virtual

Sets whether the timer is active.

Author
GW
Date
08/2013
Parameters
active_true to enable the timer, false to disable
Note
This method simply calls activate() or deactivate() as appropriate

◆ setCallback()

virtual void hdi::core::Timer::setCallback ( const Callback cb_)
virtual

Sets the callback for the timer.

Author
GW
Date
08/2013
Parameters
cb_New callback to be performed when the timer fires

◆ setDelay()

virtual void hdi::core::Timer::setDelay ( const double  delay_)
virtual

Sets the delay in seconds for the target Timer object.

Author
GW
Date
08/2013
Parameters
delay_New delay, in seconds, between firings of the timer callback
Note
The new delay is not guaranteed to be respected until after the next time the timer callback is fired.