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

gadget::SimDigital Class Reference

Simulated digital device. More...

#include <SimDigital.h>

Inheritance diagram for gadget::SimDigital:

Inheritance graph
[legend]
Collaboration diagram for gadget::SimDigital:

Collaboration graph
[legend]
List of all members.

Public Methods

 SimDigital ()
 Default Constructor. More...

virtual ~SimDigital ()
 Destructor. More...

virtual bool config (jccl::ConfigElementPtr element)
virtual bool startSampling ()
 These functions don't do anything. More...

virtual bool stopSampling ()
virtual bool sample ()
virtual void updateData ()
 Updates the state of the digital data vector. More...

virtual std::vector< KeyModPair > getKeys ()
void operator delete (void *p)
 Invokes the global scope delete operator. More...


Static Public Methods

std::string getElementType ()

Protected Methods

virtual void destroy ()
 Deletes this object. More...


Detailed Description

Simulated digital device.

Simulates a digital device from a keyboard device. It allows any number of simulated digital devices to be created.

When the key configured is held down, the digital device is on. When the key is released, the device is no longer set.

This class should not be used directly by the user.

Definition at line 57 of file SimDigital.h.


Constructor & Destructor Documentation

gadget::SimDigital::SimDigital  
 

Default Constructor.

Definition at line 41 of file SimDigital.cpp.

00042 {
00043    vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)<<"*** SimDigital::SimDigital()\n"<< vprDEBUG_FLUSH;
00044 }

gadget::SimDigital::~SimDigital   [virtual]
 

Destructor.

Definition at line 47 of file SimDigital.cpp.

00048 {
00049    //vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)<<"*** SimDigital::~SimDigital()\n"<< vprDEBUG_FLUSH;
00050 }


Member Function Documentation

bool gadget::SimDigital::config jccl::ConfigElementPtr    element [virtual]
 

Reimplemented from gadget::Digital.

Definition at line 57 of file SimDigital.cpp.

00058 {
00059    //vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)<<"*** SimDigital::config()\n"<< vprDEBUG_FLUSH;
00060    if (! (Input::config(element) && Digital::config(element) &&
00061           SimInput::config(element)) )
00062    {
00063       return false;
00064    }
00065 
00066    std::vector<jccl::ConfigElementPtr> key_list;
00067    int key_count = element->getNum("key_pair");
00068    for ( int i = 0; i < key_count; ++i )
00069    {
00070       key_list.push_back(element->getProperty<jccl::ConfigElementPtr>("key_pair", i));
00071    }
00072    mSimKeys = readKeyList(key_list);
00073 
00074    return true;
00075 }

virtual bool gadget::SimDigital::startSampling   [inline, virtual]
 

These functions don't do anything.

Definition at line 66 of file SimDigital.h.

00066 { return 1; }

virtual bool gadget::SimDigital::stopSampling   [inline, virtual]
 

Definition at line 67 of file SimDigital.h.

00067 { return 1; }

virtual bool gadget::SimDigital::sample   [inline, virtual]
 

Definition at line 68 of file SimDigital.h.

00068 { return 1; }

void gadget::SimDigital::updateData   [virtual]
 

Updates the state of the digital data vector.

Note:
Digital is on when key is held down. When key is release, digital goes to off state.

Definition at line 83 of file SimDigital.cpp.

References gadget::Digital::addDigitalSample, and gadget::Digital::swapDigitalBuffers.

00084 {
00085    //vprDEBUG(vprDBG_ALL, vprDBG_VERB_LVL)<<"*** SimDigital::updateData()\n"<< vprDEBUG_FLUSH;
00086    std::vector<DigitalData>  digital_data_sample(mSimKeys.size());   // The digital data that makes up the sample
00087 
00088    // -- Update digital data --- //
00089    for (unsigned int i = 0; i < mSimKeys.size(); i++)
00090    {
00091       digital_data_sample[i].setTime();
00092       if(checkKeyPair(mSimKeys[i]))             // If keys pressed
00093       {
00094          digital_data_sample[i] = 1;
00095       }
00096       else
00097       {
00098          digital_data_sample[i] = 0;
00099       }
00100    }
00101 
00102    // Add a sample
00103    addDigitalSample(digital_data_sample);
00104       
00105    swapDigitalBuffers();
00106 }

std::string gadget::SimDigital::getElementType   [static]
 

Definition at line 52 of file SimDigital.cpp.

00053 {
00054    return "simulated_digital_device";
00055 }

virtual std::vector<KeyModPair> gadget::SimDigital::getKeys   [inline, virtual]
 

Definition at line 75 of file SimDigital.h.

00075 { return mSimKeys; }

void gadget::SimDigital::operator delete void *    p [inline]
 

Invokes the global scope delete operator.

This is required for proper releasing of memory in DLLs on Win32.

Definition at line 81 of file SimDigital.h.

00082    {
00083       ::operator delete(p);
00084    }

virtual void gadget::SimDigital::destroy   [inline, protected, virtual]
 

Deletes this object.

This is an implementation of the pure virtual gadget::Input::destroy() method.

Definition at line 91 of file SimDigital.h.

00092    {
00093       delete this;
00094    }


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