Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Examples  

gadget::Input Class Reference

Input is the abstract base class that all input objects derive from. More...

#include <Input.h>

Inheritance diagram for gadget::Input:

Inheritance graph
[legend]
List of all members.

Public Methods

 Input ()
 Default Constructor. More...

virtual ~Input ()
 Input Destructor. More...

virtual bool config (jccl::ConfigElementPtr e)
 Config method. More...

virtual bool sample ()=0
 Sample the device. More...

virtual bool startSampling ()=0
 Start a device sampling. More...

virtual bool stopSampling ()=0
 StopSampling. More...

virtual void updateData ()=0
 Update the data. More...

std::string getInstanceName ()
 Returns the name identifying this instance of the device. More...

virtual std::string getBaseType ()
 Get the BaseType used later by the BaseTypeFactory to build a "virtual" representation of this to be used for remote input. More...

virtual vpr::ReturnStatus writeObject (vpr::ObjectWriter *writer)
 Serialize this device's data. More...

virtual vpr::ReturnStatus readObject (vpr::ObjectReader *reader)
 De-serialize this devices data. More...

bool isActive ()
 Is this input device active? More...


Static Public Methods

std::string getElementType ()
 Returns the string rep of the element type used to config this device. More...


Protected Methods

virtual void destroy ()=0
 Subclasses must implement this so that dynamically loaded device drivers delete themselves in the correct memory space. More...

 Input (const Input &o)
void operator= (const Input &o)

Protected Attributes

std::string mInstName
vpr::Thread * mThread
 The thread being used by the driver. More...

bool mActive
 Is the driver active? More...


Detailed Description

Input is the abstract base class that all input objects derive from.

Input is the base class for all Input Devices, all the devices are therefore forced to implement the pure virtual functions of Sample, StartSampling, StopSampling, and UpdateData.

Dummy devices can use a default constructor, but physical devices should have a Constructor which takes a config element and calls the Input constructor taking a jccl::ConfigElementPtr.

All Physical devices will inherit from not Input but another abstract class which inherits from Input, currently there is support for Positional Devices, Analog Devices, and Digital devices, each has its own added pure virtual functions providing a simple and equal interface to themselves.

Note:
We make the assumption in all devices that while updateData() is being called, no other process will try to read the current data. We can make this assumption because the whole idea of UpdateData() is to bring in a current copy of the data for threads to process for a frame. Because of this, threads should not be reading data while it is being updated to the most recent copy.

Definition at line 74 of file Input.h.


Constructor & Destructor Documentation

gadget::Input::Input  
 

Default Constructor.

The default constructor is intended only for use by the DummyProxies which do not need to have their serial port and baud rate etc set up. Also, initializes mThread and mActive to null values.

Definition at line 43 of file Input.cpp.

00044  : mInstName(""),
00045    mThread(NULL),
00046    mActive(false)
00047 {
00048 }

virtual gadget::Input::~Input   [inline, virtual]
 

Input Destructor.

Free the memory for the Instance Name and Serial Port strings if allocated.

Definition at line 91 of file Input.h.

00092    {
00093       ;
00094    }

gadget::Input::Input const Input &    o [inline, protected]
 

Definition at line 222 of file Input.h.

00222                          : vpr::SerializableObject(o)
00223    {;}


Member Function Documentation

bool gadget::Input::config jccl::ConfigElementPtr    e [virtual]
 

Config method.

This baselevel config will fill the base datamembers when found in the jccl::ConfigElementPtr such as instance name.

Reimplemented in gadget::EventWindowOSX.

Definition at line 50 of file Input.cpp.

References mInstName.

00051 {
00052   //if((!mPort.empty()) && (!mInstName.empty()))
00053   //{
00054      // ASSERT: We have already been configured
00055      //         this prevents config from being called multiple times (once for each derived class)
00056      //         ie. Digital, Analog, etc
00057   //   return true;
00058   //}
00059 
00060   mInstName = e->getFullName();
00061 
00062   return true;
00063 }

virtual bool gadget::Input::sample   [pure virtual]
 

Sample the device.

Read the next set of input. This method is normally used internally by threaded drivers to repetively sample data in a separate thread. (This new data is not accessable until UpdateData is called)

Implemented in gadget::EventWindowOSX.

virtual bool gadget::Input::startSampling   [pure virtual]
 

Start a device sampling.

Start the device sampling, normally this will spawn a thread which will just repeatedly call Sample(). This function should return true when it sucessfully starts, false otherwise.

Implemented in gadget::EventWindowOSX.

virtual bool gadget::Input::stopSampling   [pure virtual]
 

StopSampling.

Reverse the effects of StartSampling().

Implemented in gadget::EventWindowOSX.

virtual void gadget::Input::updateData   [pure virtual]
 

Update the data.

After this function is called subsequent calls to GetData(d) will return the most recent data at the time of THIS function call. Data is guaranteed to be valid and static until the next call to UpdateData.

Implemented in gadget::EventWindowOSX.

std::string gadget::Input::getElementType   [inline, static]
 

Returns the string rep of the element type used to config this device.

This string is used by the device factory to look up device drivers based up the type of element it is trying to load.

Reimplemented in gadget::EventWindowOSX.

Definition at line 145 of file Input.h.

00145 { return std::string("Undefined"); }

std::string gadget::Input::getInstanceName   [inline]
 

Returns the name identifying this instance of the device.

This is the name given to the device in its config element (e.g., "MyFlockOfBirds", "The Ibox", etc.).

Definition at line 152 of file Input.h.

Referenced by gadget::InputLogger::addRecordingSample.

00153    {
00154       if (mInstName.empty())
00155       {
00156          return std::string("Undefined");
00157       }
00158       return mInstName;
00159    }

virtual std::string gadget::Input::getBaseType   [inline, virtual]
 

Get the BaseType used later by the BaseTypeFactory to build a "virtual" representation of this to be used for remote input.

Reimplemented in gadget::InputMixer< Input, Position >.

Definition at line 165 of file Input.h.

00166    {
00167       return std::string("Input");
00168    }

virtual vpr::ReturnStatus gadget::Input::writeObject vpr::ObjectWriter *    writer [inline, virtual]
 

Serialize this device's data.

Reimplemented in gadget::InputMixer< Input, Position >.

Definition at line 173 of file Input.h.

Referenced by gadget::InputLogger::addRecordingSample.

00174    {
00175       boost::ignore_unused_variable_warning(writer);
00176       return vpr::ReturnStatus(vpr::ReturnStatus::Fail);
00177    }

virtual vpr::ReturnStatus gadget::Input::readObject vpr::ObjectReader *    reader [inline, virtual]
 

De-serialize this devices data.

Reimplemented in gadget::InputMixer< Input, Position >.

Definition at line 182 of file Input.h.

Referenced by gadget::InputLogger::playNextSample.

00183    {
00184       boost::ignore_unused_variable_warning(reader);
00185       return vpr::ReturnStatus(vpr::ReturnStatus::Fail);
00186    }

bool gadget::Input::isActive   [inline]
 

Is this input device active?

Definition at line 189 of file Input.h.

00190    {
00191       return mActive;
00192    }

virtual void gadget::Input::destroy   [protected, pure virtual]
 

Subclasses must implement this so that dynamically loaded device drivers delete themselves in the correct memory space.

This uses a template pattern.

Implemented in gadget::EventWindowOSX.

void gadget::Input::operator= const Input &    o [inline, protected]
 

Definition at line 224 of file Input.h.

00224 {;}


Member Data Documentation

std::string gadget::Input::mInstName [protected]
 

Definition at line 218 of file Input.h.

Referenced by config, gadget::EventWindowWin32::createWindowWin32, and gadget::EventWindowWin32::updKeys.

vpr::Thread* gadget::Input::mThread [protected]
 

The thread being used by the driver.

Definition at line 219 of file Input.h.

Referenced by gadget::EventWindowXWin::controlLoop, gadget::EventWindowXWin::startSampling, gadget::EventWindowWin32::startSampling, gadget::EventWindowXWin::stopSampling, and gadget::EventWindowWin32::stopSampling.

bool gadget::Input::mActive [protected]
 

Is the driver active?

Definition at line 220 of file Input.h.


The documentation for this class was generated from the following files:
Generated on Sun May 2 14:27:00 2004 for Gadgeteer by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002