gadget::SimDigital Class Reference

Simulated digital device. More...

#include <gadget/Devices/Sim/SimDigital.h>

Inheritance diagram for gadget::SimDigital:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 SimDigital ()
 Default Constructor.
virtual ~SimDigital ()
 Destructor.
virtual bool config (jccl::ConfigElementPtr element)
virtual bool startSampling ()
 These functions don't do anything.
virtual bool stopSampling ()
virtual bool sample ()
virtual void updateData ()
 Updates the state of the digital data vector.
virtual std::vector< KeyModPair > getKeys ()
void operator delete (void *p)
 Invokes the global scope delete operator.

Static Public Member Functions

static std::string getElementType ()

Protected Member Functions

virtual void destroy ()
 Deletes this object.

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 59 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]

Definition at line 57 of file SimDigital.cpp.

References gadget::SimInput::config(), gadget::Digital::config(), and gadget::Input::config().

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 68 of file SimDigital.h.

00068 { return 1; }

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

Definition at line 69 of file SimDigital.h.

00069 { return 1; }

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

Definition at line 70 of file SimDigital.h.

00070 { 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.

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       // Set the time for the digital data to the KeyboardMouse timestamp
00092       digital_data_sample[i].setTime(mKeyboardMouse->getTimeStamp());
00093       if(checkKeyPair(mSimKeys[i]))             // If keys pressed
00094       {
00095          digital_data_sample[i] = 1;
00096       }
00097       else
00098       {
00099          digital_data_sample[i] = 0;
00100       }
00101    }
00102 
00103    // Add a sample
00104    addDigitalSample(digital_data_sample);
00105       
00106    swapDigitalBuffers();
00107 }

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 77 of file SimDigital.h.

00077 { 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 83 of file SimDigital.h.

00084    {
00085       ::operator delete(p);
00086    }

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 93 of file SimDigital.h.

00094    {
00095       delete this;
00096    }


The documentation for this class was generated from the following files:
Generated on Thu Jan 4 10:44:37 2007 for Gadgeteer by  doxygen 1.5.1