ExptDriver Class Reference

#include <visx/exptdriver.h>

Inheritance diagram for ExptDriver:

Inheritance graph
[legend]
Collaboration diagram for ExptDriver:

Collaboration graph
[legend]

List of all members.

Public Types

enum  ChildStatus { CHILD_OK, CHILD_ABORTED, CHILD_REPEAT }
 Status type for child to tell its parent how it ended.

Public Member Functions

virtual ~ExptDriver () throw ()
 Virtual destructor.
virtual io::version_id class_version_id () const
virtual void read_from (io::reader &reader)
virtual void write_to (io::writer &writer) const
virtual const nub::soft_ref
< Toglet > & 
getWidget () const
 Return the Widget in which the experiment is running.
virtual void vxRun (Element &parent)
 Run this element with a reference to its parent.
virtual void vxEndTrialHook ()
 End the current trial normally, and move on to the next trial.
virtual void vxAllChildrenFinished ()
 Stop the experiment since all child elements are finished.
const rutz::fstringgetAutosaveFile () const
 Return the name of the file currently being used for autosaves.
void setAutosaveFile (const rutz::fstring &str)
 Change the name of the file to use for autosaves.
int getAutosavePeriod () const
 Return the current autosave period.
void setAutosavePeriod (int period)
 Change the autosave period to period.
const rutz::fstringgetFilePrefix () const
 Get the string used as a prefix for output files generated by the experiment.
void setFilePrefix (const rutz::fstring &str)
 Specify a string to be used as a prefix for output files generated by the experiment.
void claimLogFile () const
 Make the global log file (handled by nub::logging) be named after this expt.
const char * getInfoLog () const
 Return the full contents of the info log.
rutz::fstring getDoWhenComplete () const
 Get the script to be executed when the experiment completes.
void setDoWhenComplete (const rutz::fstring &script)
 Specify a script to be executed when the experiment completes.
void setWidget (const nub::soft_ref< Toglet > &widg)
 Specify the widget in which the experiment should run.
void edBeginExpt ()
 Begin the experiment.
void edResumeExpt ()
 Resume the experiment after it has been halted.
void storeData ()
virtual int trialType () const
 Returns the trial type of the current element.
virtual int lastResponse () const
 Returns the last valid response.
virtual rutz::fstring vxInfo () const
 Returns a string naming the current element, plus a count of completed elements.
virtual void vxHalt () const
 Halt the current child element.
virtual void vxReturn (ChildStatus s)
 Delegates partially on to vxAllChildrenFinished().
virtual void vxUndo ()
 Undo the previous element.
virtual void vxReset ()
 Reset all of the contained child elements.
void addElement (nub::ref< Element > element, unsigned int repeat=1)
 Add the specified element to the sequence, 'repeat' number of times.
void setRandSeed (int s)
 Set the random seed for shuffling child elements.
int getRandSeed () const
 Get the current random seed used for shuffling child elements.
void shuffle (int seed=0)
 Randomly permute the sequence of elements.
void clearElements ()
 Clear the container of all its contained elements.
nub::soft_ref< ElementcurrentElement () const
 Get a reference to the current element.
unsigned int numElements () const
 Returns the total number of child elements in the container.
unsigned int numCompleted () const
 Returns the number of elements that have been completed.
rutz::fwd_iter< const nub::ref
< Element > > 
getElements () const
 Returns an iterator to all the contained child elements.
bool isComplete () const
 Returns true if the all child elements are complete, false otherwise.
nub::uid id () const throw ()
rutz::fstring real_typename () const
 Returns the typename of the full object.
virtual rutz::fstring obj_typename () const
 Returns the (apparent) 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 ExptDrivermake ()
 Factory function.

Static Public Attributes

static rutz::tracer tracer
 Dynamically controls the tracing of ExptDriver member functions.

Classes

class  Impl


Detailed Description

ExptDriver is an implementation of the Experiment interface that coordinates all objects necessary to run an experiment.

Definition at line 71 of file exptdriver.h.


Member Function Documentation

io::version_id ExptDriver::class_version_id (  )  const [virtual]

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 from io::serializable.

Definition at line 176 of file exptdriver.cc.

void ExptDriver::read_from ( io::reader reader  )  [virtual]

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.

Reimplemented from ElementContainer.

Definition at line 182 of file exptdriver.cc.

References rutz::fstring::c_str(), io::reader::ensure_version_id(), io::reader::read_base_class(), io::reader::read_owned_object(), io::reader::read_value(), and SRC_POS.

void ExptDriver::write_to ( io::writer writer  )  const [virtual]

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.

Reimplemented from ElementContainer.

Definition at line 208 of file exptdriver.cc.

References io::writer::ensure_output_version_id(), SRC_POS, io::writer::write_base_class(), io::writer::write_owned_object(), and io::writer::write_value().

void ExptDriver::storeData (  ) 

This saves the experiment file and a summary-of-responses file under unique filenames based on the date and time.

Definition at line 475 of file exptdriver.cc.

References rutz::fstring::c_str(), rutz::unixcall::chmod(), rutz::format_time(), rutz::sfmt(), rutz::time::wall_clock_now(), and TlistUtils::writeResponses().

Referenced by vxAllChildrenFinished().

int ElementContainer::lastResponse (  )  const [virtual, inherited]

Returns the last valid response.

But note that "valid" does not necessarily mean "correct".

Implements Element.

Definition at line 134 of file elementcontainer.cc.

void ElementContainer::vxUndo (  )  [virtual, inherited]

Undo the previous element.

The state of the experiment is restored to what it was just prior to the beginning of the most recent successfully completed element. Thus, the current element is changed to its previous value, and the response to the most recently successfully completed element is erased. After a call to vxUndo(), the next invocation of vxRun() will redo the element that was undone in the present command.

Implements Element.

Definition at line 232 of file elementcontainer.cc.

References ElementContainer::currentElement().

void ElementContainer::shuffle ( int  seed = 0  )  [inherited]

Randomly permute the sequence of elements.

Parameters:
seed used as the random seed for the shuffle.

Definition at line 297 of file elementcontainer.cc.

References ElementContainer::setRandSeed().

unsigned int ElementContainer::numCompleted (  )  const [inherited]

Returns the number of elements that have been completed.

This number will not include elements that have been aborted either due to an invalid response or due to a timeout.

Definition at line 334 of file elementcontainer.cc.

Referenced by ElementContainer::vxInfo(), and ElementContainer::vxReturn().

nub::uid nub::object::id (  )  const throw () [inherited]

Returns the unique id for this object. The unique id will always be strictly positive; zero is always an invalid unique id.

Definition at line 62 of file object.cc.

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().

rutz::fstring nub::object::obj_typename (  )  const [virtual, inherited]

Returns the (apparent) typename of the full object.

The default implementation just returns real_typename(). However, certain kinds of objects -- e.g., proxy objects -- might usefully choose to have obj_typename() return something besides the real_typename(), in order to masquerade as a different type of object.

Reimplemented in io::proxy< C >, io::const_proxy< C >, MtxObj, and TrialMemFuncEvent.

Definition at line 73 of file object.cc.

References nub::object::real_typename().

Referenced by io::legacy_reader::read_root(), and nub::object::unique_name().

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().


The documentation for this class was generated from the following files:

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:54:06 2008 by Doxygen version 1.5.5.