cmil::Ev Class Reference

#include <InputEv.h>

Inheritance diagram for cmil::Ev:

Inheritance graph
[legend]
Collaboration diagram for cmil::Ev:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::vector< EvSequence

Public Member Functions

 Ev (const std::string input)
 Ev (unsigned long margin, const std::string input)
 Ev (const std::string dev, std::string input)
 Ev (unsigned long margin, const std::string dev, std::string input)
 Ev (unsigned int ndev, const std::string dev, std::string input)
 Ev (unsigned int margin, unsigned int ndev, const std::string dev, std::string input)
virtual ~Ev ()
InputAction *const getAction () const
 Returns the action member of this class.
std::string getDeviceName () const
unsigned int getDeviceMultiple () const
Sequence *const getSequence () const
unsigned long getTimeMargin () const
std::string getName () const
Evoperator<< (const Ev &event)
Evoperator<< (InputAction *action)
 This operator also assigns the action to the sequence.
bool operator== (const Ev &event) const
bool operator< (const Ev &event) const
bool operator> (const Ev &event) const
 Ev (const Ev &rhs)
 This is mainly so the m_sequence doesn't get copied to events within that structure,.
Evoperator= (const Ev &rhs)
 This is mainly so the m_sequence doesn't get copied to events within that structure,.

Static Public Member Functions

static void setDefaultDevice (const std::string &name)
static void setDefaultTimeMargin (unsigned long time)
static std::string getDefaultDevice ()
static unsigned long getDefaultTimeMargin ()
static unsigned getEventCount (const Sequence &seq, const Ev &event)

Static Public Attributes

static std::string sdev = std::string("")
 This initializes the static default device name.
static unsigned long smargin = 500
 This initializes the static default margin.

Private Member Functions

InputAction *const seqAction () const
bool isAdded (const Ev &event) const
 determines if an event of this kind has been added

Private Attributes

unsigned int m_time_margin
 the time allowed for this event to occur, respective to others in a sequence, recommended in miliseconds
unsigned int m_ndev
 the device multiple (what number of the same kind of device) IE: joystick[0]
std::string m_input
 which input name identifier IE: button0
std::string m_dev
 the type of device, IE: joystick
Sequence::iterator m_iter
Sequencem_sequence
InputActionm_action
 the action, this should only be non-null as the last event of a sequence.

Detailed Description

This class is one of the main parts of the CMIL interface, it describes event sequences in conjunction with InputContext functions.

Definition at line 28 of file InputEv.h.


Member Typedef Documentation

typedef std::vector<Ev> cmil::Ev::Sequence

Definition at line 30 of file InputEv.h.


Constructor & Destructor Documentation

cmil::Ev::Ev ( const std::string  input  )  [inline]

Definition at line 60 of file InputEv.h.

00060                                 : 
00061         m_time_margin(Ev::getDefaultTimeMargin()),
00062         m_ndev(0),
00063         m_input(input), 
00064         m_dev(Ev::getDefaultDevice()), 
00065         m_sequence(NULL),
00066         m_action(NULL) {}

cmil::Ev::Ev ( unsigned long  margin,
const std::string  input 
) [inline]

Definition at line 68 of file InputEv.h.

00068                                                       : 
00069         m_time_margin(margin),
00070         m_ndev(0),
00071         m_input(input), 
00072         m_dev(Ev::getDefaultDevice()), 
00073         m_sequence(NULL),
00074         m_action(NULL) {}

cmil::Ev::Ev ( const std::string  dev,
std::string  input 
) [inline]

Definition at line 76 of file InputEv.h.

00076                                                :
00077         m_time_margin(Ev::getDefaultTimeMargin()),
00078         m_ndev(0), 
00079         m_input(input), 
00080         m_dev(dev), 
00081         m_sequence(NULL),
00082         m_action(NULL) {}

cmil::Ev::Ev ( unsigned long  margin,
const std::string  dev,
std::string  input 
) [inline]

Definition at line 84 of file InputEv.h.

00084                                                                      :
00085         m_time_margin(margin),
00086         m_ndev(0), 
00087         m_input(input), 
00088         m_dev(dev), 
00089         m_sequence(NULL),
00090         m_action(NULL) {}
  

cmil::Ev::Ev ( unsigned int  ndev,
const std::string  dev,
std::string  input 
) [inline]

Definition at line 93 of file InputEv.h.

00093                                                                   :
00094         m_time_margin(Ev::getDefaultTimeMargin()),
00095         m_ndev(ndev), 
00096         m_input(input), 
00097         m_dev(dev), 
00098         m_sequence(NULL),
00099         m_action(0) {}

cmil::Ev::Ev ( unsigned int  margin,
unsigned int  ndev,
const std::string  dev,
std::string  input 
) [inline]

Definition at line 101 of file InputEv.h.

00101                                                                                        :
00102         m_time_margin(margin),
00103         m_ndev(ndev), 
00104         m_input(input), 
00105         m_dev(dev), 
00106         m_sequence(NULL),
00107         m_action(0) {}

virtual cmil::Ev::~Ev (  )  [inline, virtual]

Definition at line 109 of file InputEv.h.

References m_sequence.

00109                     { 
00110         if(m_sequence) 
00112           delete m_sequence;
00113       }

cmil::Ev::Ev ( const Ev rhs  ) 

This is mainly so the m_sequence doesn't get copied to events within that structure,.

Done to prevent circular pointer confusion/chaos

Definition at line 107 of file InputEv.cpp.

References m_action, m_dev, m_input, m_ndev, m_sequence, and m_time_margin.

00107                       {
00108     m_time_margin = rhs.m_time_margin; 
00109     m_ndev        = rhs.m_ndev; 
00110     m_input       = rhs.m_input;
00111     m_dev         = rhs.m_dev;
00112 
00113     m_action = rhs.m_action;
00114 
00116     m_sequence = NULL;
00117   }


Member Function Documentation

InputAction *const cmil::Ev::getAction (  )  const

Returns the action member of this class.

Definition at line 41 of file InputEv.cpp.

References m_action.

Referenced by seqAction().

00041                                          { 
00042     return m_action;
00043   }

Here is the caller graph for this function:

static std::string cmil::Ev::getDefaultDevice (  )  [inline, static]

Definition at line 46 of file InputEv.h.

References sdev.

00046 { return Ev::sdev; }

static unsigned long cmil::Ev::getDefaultTimeMargin (  )  [inline, static]

Definition at line 47 of file InputEv.h.

References smargin.

00047 { return Ev::smargin; }

unsigned int cmil::Ev::getDeviceMultiple (  )  const [inline]

Definition at line 119 of file InputEv.h.

References m_ndev.

Referenced by cmil::DeviceRegistry::getData().

00119 { return m_ndev; }

Here is the caller graph for this function:

std::string cmil::Ev::getDeviceName (  )  const [inline]

Definition at line 117 of file InputEv.h.

References m_dev.

Referenced by cmil::DeviceRegistry::getData().

00117 { return m_dev; }

Here is the caller graph for this function:

static unsigned cmil::Ev::getEventCount ( const Sequence seq,
const Ev event 
) [inline, static]

Definition at line 49 of file InputEv.h.

Referenced by cmil::NormalHandler::isNormal().

00049                                                                           {
00050         unsigned int ev_count = 0;
00051 
00052         for(Sequence::const_iterator i = seq.begin() ; i != seq.end() ; i++) 
00053           if(*i == event) { ev_count++; }
00054 
00055         return ev_count;
00056       }

Here is the caller graph for this function:

std::string cmil::Ev::getName (  )  const [inline, virtual]

Implements Logger.

Definition at line 125 of file InputEv.h.

References m_input.

Referenced by cmil::DeviceRegistry::getData(), and operator<<().

00125                                 { 
00126         return m_input; 
00127       }

Here is the caller graph for this function:

Ev::Sequence *const cmil::Ev::getSequence (  )  const

Definition at line 57 of file InputEv.cpp.

References m_sequence.

Referenced by cmil::InputSequencer::addCombo(), cmil::InputSequencer::addNormal(), and cmil::InputSequencer::removeNormal().

00057                                           { 
00058      return m_sequence;
00059   }

Here is the caller graph for this function:

unsigned long cmil::Ev::getTimeMargin (  )  const [inline]

Definition at line 123 of file InputEv.h.

References m_time_margin.

00123 { return m_time_margin; }

bool cmil::Ev::isAdded ( const Ev event  )  const [private]

determines if an event of this kind has been added

bool cmil::Ev::operator< ( const Ev event  )  const

Definition at line 142 of file InputEv.cpp.

References m_dev, m_input, and m_ndev.

00142                                           { 
00144     if(m_dev < event.m_dev) 
00145       return true;
00146     else if (m_ndev < event.m_ndev)
00147       return true;
00148     else if(m_ndev < event.m_ndev) 
00149       return true;
00150     else if(m_input < event.m_input) 
00151       return true;
00152 
00153     return false;
00154   }

Ev & cmil::Ev::operator<< ( InputAction action  ) 

This operator also assigns the action to the sequence.

Set the action to what should be the last added event.

Apply the action.

Definition at line 88 of file InputEv.cpp.

References Logger::log_debug(), m_action, and m_sequence.

00088                                         { 
00089     log_debug("(Ev) operator<<(InputAction* action)" );
00090     
00092     if(!m_sequence) {
00093       m_sequence = new Ev::Sequence(1, *this);
00094       
00095       log_debug("(Ev) operator<< InputAction* : creating sequence "); 
00096     }
00097 
00098     log_debug(std::string("(Ev) operator<< InputAction*  assigning action to: ").append(m_sequence->back().getName()));
00099     
00101     (m_sequence->back()).m_action = action;
00102 
00103     return *this;  
00104   }

Here is the call graph for this function:

Ev & cmil::Ev::operator<< ( const Ev event  ) 

This operator assigns responsibility in building an event sequence to this instance. Note that no checking is done as to the validity of the events. It is up to the InputSequencer to objectively determine that.

Ensure an action isn't already assigned to this sequence prior to adding

Create our sequence if necessary, adding this instance as the first entry.

add the event

Definition at line 65 of file InputEv.cpp.

References getName(), Logger::log_error(), m_sequence, and seqAction().

00065                                     { 
00067     
00068     if( !seqAction() ) {
00070        if(!m_sequence) {
00071          //log_debug( "(Ev) operator<< initializing new sequence");
00072          m_sequence = new Sequence(1, *this);
00073        }
00074 
00076        m_sequence->push_back(event);
00077 
00078        return *this;  
00079     }
00080     else 
00081       log_error(std::string("(Ev) operator<< addition not possible due to action already applied in sequence. (").append( 
00082       getName()).append(")"));
00083 
00084     return *this;  
00085   }                                           

Here is the call graph for this function:

Ev & cmil::Ev::operator= ( const Ev rhs  ) 

This is mainly so the m_sequence doesn't get copied to events within that structure,.

Done to prevent circular pointer confusion/chaos

Definition at line 120 of file InputEv.cpp.

References m_action, m_dev, m_input, m_ndev, m_sequence, and m_time_margin.

00120                                  { 
00121     //log_debug("calling Ev& operator=(const Ev& rhs)"); 
00122     m_time_margin = rhs.m_time_margin; 
00123     m_ndev        = rhs.m_ndev; 
00124     m_input       = rhs.m_input;
00125     m_dev         = rhs.m_dev;
00126 
00127     m_action = rhs.m_action;
00128     
00130     m_sequence = NULL;
00131 
00132     return *this;
00133   }

bool cmil::Ev::operator== ( const Ev event  )  const

Definition at line 135 of file InputEv.cpp.

References m_dev, m_input, and m_ndev.

00135                                            { 
00136     if( (m_ndev  == event.m_ndev) && (m_dev  == event.m_dev) && (m_input == event.m_input) ) 
00137       return true;
00138 
00139     return false;
00140   }

bool cmil::Ev::operator> ( const Ev event  )  const

Definition at line 156 of file InputEv.cpp.

References m_dev, m_input, and m_ndev.

00156                                           { 
00158     if(m_dev > event.m_dev) 
00159       return true;
00160     else if (m_ndev > event.m_ndev)
00161       return true;
00162     else if(m_ndev > event.m_ndev) 
00163       return true;
00164     else if(m_input > event.m_input) 
00165       return true;
00166 
00167     return false;
00168   }

InputAction *const cmil::Ev::seqAction (  )  const [private]

returns the action member of the sequence associated with this instance If no sequence is available, it is not the responsible instance.

Definition at line 47 of file InputEv.cpp.

References getAction(), and m_sequence.

Referenced by operator<<().

00047                                          { 
00048     if(m_sequence) {
00049 //        log_debug("seqAction() returning action from last event in sequence");
00050         return m_sequence->back().getAction();
00051     }
00052 
00053 //    log_debug("seqAction() return the action of this instance instead of the sequence.");
00054     return getAction();
00055   }

Here is the call graph for this function:

Here is the caller graph for this function:

static void cmil::Ev::setDefaultDevice ( const std::string &  name  )  [inline, static]

Definition at line 38 of file InputEv.h.

References sdev.

00038                                                           {
00039         Ev::sdev = name;  
00040       }

static void cmil::Ev::setDefaultTimeMargin ( unsigned long  time  )  [inline, static]

Definition at line 42 of file InputEv.h.

References smargin.

00042                                                            {
00043         Ev::smargin= time;  
00044       }


Member Data Documentation

InputAction* cmil::Ev::m_action [private]

the action, this should only be non-null as the last event of a sequence.

Definition at line 165 of file InputEv.h.

Referenced by Ev(), getAction(), operator<<(), and operator=().

std::string cmil::Ev::m_dev [private]

the type of device, IE: joystick

Definition at line 152 of file InputEv.h.

Referenced by Ev(), getDeviceName(), operator<(), operator=(), operator==(), and operator>().

std::string cmil::Ev::m_input [private]

which input name identifier IE: button0

Definition at line 149 of file InputEv.h.

Referenced by Ev(), getName(), operator<(), operator=(), operator==(), and operator>().

Sequence::iterator cmil::Ev::m_iter [private]

Definition at line 155 of file InputEv.h.

unsigned int cmil::Ev::m_ndev [private]

the device multiple (what number of the same kind of device) IE: joystick[0]

Definition at line 146 of file InputEv.h.

Referenced by Ev(), getDeviceMultiple(), operator<(), operator=(), operator==(), and operator>().

Sequence* cmil::Ev::m_sequence [private]

this should only be initialized to non-NULL in the Ev responsible for the sequence, and remain NULL in all actual sequenced events, See the copy constructor.

Definition at line 162 of file InputEv.h.

Referenced by Ev(), getSequence(), operator<<(), operator=(), seqAction(), and ~Ev().

unsigned int cmil::Ev::m_time_margin [private]

the time allowed for this event to occur, respective to others in a sequence, recommended in miliseconds

Definition at line 143 of file InputEv.h.

Referenced by Ev(), getTimeMargin(), and operator=().

std::string cmil::Ev::sdev = std::string("") [static]

This initializes the static default device name.

Definition at line 33 of file InputEv.h.

Referenced by getDefaultDevice(), and setDefaultDevice().

unsigned long cmil::Ev::smargin = 500 [static]

This initializes the static default margin.

Definition at line 36 of file InputEv.h.

Referenced by getDefaultTimeMargin(), and setDefaultTimeMargin().


The documentation for this class was generated from the following files:
(c) 2006-2007 John P. Feltz
Generated on Wed Jul 25 16:08:03 2007 for Common Media Input Layer by doxygen 1.4.7

SourceForge.net Logo