Hot Door CORE  0.7.0
Adobe® Illustrator® Plug-in Library
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. More...
 
 Timer (const Timer &t_)
 Constructs a new Timer object from an existing Timer object (copy constructor) More...
 
 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. More...
 
virtual ~Timer ()
 Destructs a Timer object, deactivating the timer first. More...
 
virtual Timeroperator= (const Timer &rhs_)
 Assigns one Timer object to another. More...
 
virtual bool operator== (const Timer &rhs_) const
 Tests whether a given Timer object is the same as another. More...
 
virtual bool operator!= (const Timer &rhs_) const
 Tests whether a given Timer object is not the same as another. More...
 
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) More...
 
virtual AITimerHandle aiTimerHandle () const
 Gets the timer handle around which the target object is wrapped. More...
 
virtual bool isEmpty () const
 Gets whether the target Timer object is empty (constructed with the default ctor) More...
 
virtual std::string name () const
 Gets the unique timer name. More...
 
virtual bool active () const
 Gets whether the timer is active. More...
 
virtual void setActive (const bool active_)
 Sets whether the timer is active. More...
 
virtual void activate ()
 Activates (enables) the timer. More...
 
virtual void deactivate ()
 Deactivates (disables) the timer, preventing it from firing. More...
 
virtual double delay () const
 Gets the delay in seconds for the target Timer object. More...
 
virtual void setDelay (const double delay_)
 Sets the delay in seconds for the target Timer object. More...
 
virtual Callback *const callback () const
 Gets the registered callback for the timer. More...
 
virtual void setCallback (const Callback &cb_)
 Sets the callback for the timer. More...
 

Friends

plugin::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

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).
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
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
virtual hdi::core::Timer::~Timer ( )
virtual

Destructs a Timer object, deactivating the timer first.

Author
GW
Date
08/2013

Member Function Documentation

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

Activates (enables) the timer.

Author
GW
Date
08/2013
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
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.
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
virtual void hdi::core::Timer::deactivate ( )
virtual

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

Author
GW
Date
08/2013
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
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.
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
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
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
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
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
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
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
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