#include <visx/trialevent.h>
Public Types | |
typedef void(Trial::* | CallbackType )() |
Public Member Functions | |
virtual rutz::fstring | obj_typename () const |
Overridden to return the typename that was passed to the constructor. | |
virtual void | read_from (io::reader &reader) |
virtual void | write_to (io::writer &writer) const |
unsigned int | getDelay () const |
Return the current requested delay time, in milliseconds. | |
void | setDelay (unsigned int msec) |
Set the requested delay time to msec milliseconds. | |
bool | is_pending () const |
Queries whether there is a pending callback to invoke() . | |
unsigned int | schedule (rutz::shared_ptr< nub::scheduler > s, Trial &trial, unsigned int minimum_msec=0) |
Schedules the event to occur after the requested delay,. | |
void | cancel () |
Cancels a pending event. | |
virtual io::version_id | class_version_id () const |
nub::uid | id () const throw () |
rutz::fstring | real_typename () const |
Returns the typename of the full object. | |
rutz::fstring | unique_name () const |
Returns a short string describing the object by its typename and id. | |
void * | operator new (size_t bytes) |
void | operator delete (void *space, size_t bytes) |
void | mark_as_volatile () throw () |
Mark this object as a volatile (unshareable) object. | |
void | incr_ref_count () const throw () |
Increment the object's reference count. | |
void | decr_ref_count () const throw () |
Decrement the object's reference count. | |
void | decr_ref_count_no_delete () const throw () |
Decrement the object's reference count, but don't delete it. | |
bool | is_shared () const throw () |
Returns true if no external client has sole ownership of the object. | |
bool | is_unshared () const throw () |
Returns true if there is a sole external owner of the object. | |
bool | is_not_shareable () const throw () |
ref_counts * | get_counts () const throw () |
Returns the object's reference count manager. | |
int | dbg_ref_count () const throw () |
FOR TEST/DEBUG ONLY! Returns the object's (strong) reference count. | |
int | dbg_weak_ref_count () const throw () |
FOR TEST/DEBUG ONLY! Returns the object's weak reference count. | |
Static Public Member Functions | |
static TrialMemFuncEvent * | make (CallbackType callback, const rutz::fstring &type, unsigned int msec=0) |
Make a new event bound to a given Trial member function. | |
Protected Member Functions | |
TrialMemFuncEvent (CallbackType callback, const rutz::fstring &type, unsigned int msec=0) | |
Constructor. | |
virtual | ~TrialMemFuncEvent () throw () |
Virtual destructor. | |
virtual void | invoke (Trial &trial) |
Called after the requested delay after a call to schedule() . |
Definition at line 174 of file trialevent.h.
void TrialMemFuncEvent::invoke | ( | Trial & | trial | ) | [protected, virtual] |
Called after the requested delay after a call to schedule()
.
Subclasses must override this function to take whatever specific action is desired when the callback triggers. The function is called internally by TrialEvent
, so subclasses should not call this function directly.
Implements TrialEvent.
Definition at line 225 of file trialevent.cc.
void TrialEvent::read_from | ( | io::reader & | reader | ) | [virtual, inherited] |
Subclasses implement this method to save the object's state via the generic interface provided by io::reader
. Parsing the format of the input is handled by the io::reader
, so implementors of read_from()
of don't need to deal with formatting.
Implements io::serializable.
Reimplemented in FileWriteEvent, GenericEvent, and MultiEvent.
Definition at line 100 of file trialevent.cc.
References TrialEvent::cancel(), and io::reader::read_value().
void TrialEvent::write_to | ( | io::writer & | writer | ) | const [virtual, inherited] |
Subclasses implement this method to restore the object's state via the generic interface provided by io::writer
. Formatting the output is handled by the io::writer
, so implementors of write_to()
of don't need to deal with formatting.
Implements io::serializable.
Reimplemented in FileWriteEvent, GenericEvent, and MultiEvent.
Definition at line 109 of file trialevent.cc.
References io::writer::write_value().
unsigned int TrialEvent::schedule | ( | rutz::shared_ptr< nub::scheduler > | s, | |
Trial & | trial, | |||
unsigned int | minimum_msec = 0 | |||
) | [inherited] |
Schedules the event to occur after the requested delay,.
Cancels any previously pending events that had not yet triggered. After this call, invoke()
will be called after the requested delay (to within the accuracy provided by the applications's event loop), unless there is an intervening call to cancel()
. If the requested delay is negative or zero, the invoke()
callback is triggered immediately without involving the event loop. The function returns the actual delay that was requested from the event loop (this may differ from the ideal delay request since the TrialEvent will try to learn what the typical error is between ideal/actual delays, and then compensate accordingly). Finally, The minimum_msec parameter specifies a minimum delay time; this may be used to ensure that proper relative ordering of TrialEvent's is maintained, even if the event loop is getting slowed down overall.
Definition at line 116 of file trialevent.cc.
References nub::timer::schedule(), and nub::timer::set_delay_msec().
void TrialEvent::cancel | ( | ) | [inherited] |
Cancels a pending event.
That is, if cancel()
is called after schedule()
has been called but before invoke()
has been triggered, then invoke()
will not be called until the event is rescheduled. If there is no pending event, this function does nothing.
Definition at line 143 of file trialevent.cc.
References nub::timer::cancel().
Referenced by TrialEvent::read_from().
io::version_id io::serializable::class_version_id | ( | ) | const [virtual, inherited] |
Returns a serialization version id for the class. The default implementation returns zero. Classes should override this when they make a change that requires a change to their serialization protocol. Overriding versions of this function should follow the convention that a higher id refers to a later version of the class. Implementations of io::reader
and io::writer
will provide a way for a class to store and retrieve the serialization version of an object.
Reimplemented in GxCache, GxPerspectiveCamera, GxFixedScaleCamera, GxPsyphyCamera, GxColor, GxCylinder, GxDisk, GxDrawStyle, GxLighting, GxLine, GxMaterial, GxPixmap, GxPointSet, GxShapeKit, GxSphere, GxText, GxTransform, io::proxy< C >, io::const_proxy< C >, Block, CloneFace, EventResponseHdlr, ExptDriver, Face, Fish, FixPt, Gabor, GaborArray, House, Jitter, MaskHatch, MorphyFace, TimingHandler, TimingHdlr, and Trial.
nub::uid nub::object::id | ( | ) | const throw () [inherited] |
rutz::fstring nub::object::real_typename | ( | ) | const [inherited] |
Returns the typename of the full object.
The result is a demangled version of typeid(*this)
.name(), which should very closely resemble the way the object was declared in source code.
Definition at line 67 of file object.cc.
References rutz::demangled_name().
Referenced by nub::object::obj_typename().
void * nub::ref_counted::operator new | ( | size_t | bytes | ) | [inherited] |
Class-specific operator new; protected to ensure that clients use factory functions.
Definition at line 157 of file refcounted.cc.
void nub::ref_counted::operator delete | ( | void * | space, | |
size_t | bytes | |||
) | [inherited] |
Class-specific operator delete; private since deletion should only happen in ref_counted::decr_ref_count.
Definition at line 163 of file refcounted.cc.
void nub::ref_counted::incr_ref_count | ( | ) | const throw () [inherited] |
Increment the object's reference count.
This operation (on the strong reference count) is not permitted if the object is unshareable. Unshareable objects can only have their weak reference counts manipulated.
Definition at line 207 of file refcounted.cc.
References nub::ref_counts::acquire_strong().
Referenced by GxEmptyNode::make().
void nub::ref_counted::decr_ref_count | ( | ) | const throw () [inherited] |
Decrement the object's reference count.
If this causes the reference count to fall to zero or below, the pointee and the pointer will be destroyed by a call to 'delete this'. This operation (on the strong reference count) is not permitted if the object is unshareable. Unshareable objects can only have their weak reference counts manipulated.
Definition at line 212 of file refcounted.cc.
References nub::ref_counts::release_strong().
void nub::ref_counted::decr_ref_count_no_delete | ( | ) | const throw () [inherited] |
Decrement the object's reference count, but don't delete it.
Unlike decr_ref_count(), the object will NOT be delete'd if the reference count falls to zero. This operation (on the strong reference count) is not permitted if the object is unshareable. Unshareable objects can only have their weak reference counts manipulated.
Definition at line 221 of file refcounted.cc.
References nub::ref_counts::release_strong_no_delete().
bool nub::ref_counted::is_shared | ( | ) | const throw () [inherited] |
Returns true if no external client has sole ownership of the object.
This may occur if either (1) the reference count is greater than one, or (2) the object is_not_shareable(), meaning that the object itself is the only "owner".
Definition at line 226 of file refcounted.cc.
References rutz::mutex_atomic_int::atomic_get(), nub::ref_counted::is_not_shareable(), and nub::ref_counts::m_strong.
Referenced by nub::ref_counted::is_unshared().
bool nub::ref_counted::is_unshared | ( | ) | const throw () [inherited] |
Returns true if there is a sole external owner of the object.
This occurs if the reference count is one or less and the object is shareable.
Definition at line 236 of file refcounted.cc.
References nub::ref_counted::is_shared().
bool nub::ref_counted::is_not_shareable | ( | ) | const throw () [inherited] |
Returns true if the object is not shareable for any reason. This could be because its lifespan is volatile (such as objects representing on-screen windows that can be dismissed by the user). The default is for objects to be shareable; objects can declare themselves as unshareable by calling mark_as_volatile().
Definition at line 242 of file refcounted.cc.
References nub::ref_counts::m_volatile.
Referenced by nub::ref_counted::is_shared().