/home/jpf/code/cc/project/cmil/include/InputEv.h

Go to the documentation of this file.
00001 // =====================================================================================
00002 //       Filename:  InputEv.h 
00003 //    Description:  
00004 //        Created:  02/15/2007 08:47:46 PM EST
00005 //       Revision:  none
00006 //       Compiler:  gcc 3.4.6
00007 // 
00008 //         Author:  John P. Feltz 
00009 //          Email:  jfeltz@gmail.com
00010 //        License:  Copyright (c) 2006-2007, John P. Feltz 
00011 //                  This program is free software; you can redistribute it and/or
00012 //                  modify it under the terms of the GNU General Public License as
00013 //                  published by the Free Software Foundation, version 2 of the
00014 //                  License.
00015 //                  This program is distributed in the hope that it will be
00016 //                  useful, but WITHOUT ANY WARRANTY; without even the implied
00017 //                  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00018 //                  PURPOSE.
00019 //                  See the GNU General Public License version 2 for more details.
00020 // 
00021 // =====================================================================================
00022 
00023 
00024 namespace cmil {
00027 
00028   class Ev : public Logger {
00029     public:
00030       typedef std::vector<Ev> Sequence;
00031 
00032       //the static default device type 
00033       static std::string sdev;  
00034 
00035       //the static default margin
00036       static unsigned long smargin; 
00037 
00038       static void setDefaultDevice(const std::string& name) {
00039         Ev::sdev = name;  
00040       }
00041 
00042       static void setDefaultTimeMargin(unsigned long time) {
00043         Ev::smargin= time;  
00044       }
00045 
00046       static std::string getDefaultDevice() { return Ev::sdev; }
00047       static unsigned long getDefaultTimeMargin() { return Ev::smargin; }
00048 
00049       static unsigned getEventCount(const Sequence& seq, const Ev& event) {
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       }
00057 
00058       //Main interface definitions for the event structure. 
00059 
00060       Ev(const std::string input) : 
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) {}
00067 
00068       Ev(unsigned long margin, const std::string input) : 
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) {}
00075 
00076       Ev(const std::string dev, std::string input) :
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) {}
00083 
00084       Ev(unsigned long margin, const std::string dev, std::string input) :
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) {}
00091   
00092   
00093       Ev(unsigned int ndev, const std::string dev, std::string input) :
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) {}
00100 
00101       Ev(unsigned int margin, unsigned int ndev, const std::string dev, std::string input) :
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) {}
00108 
00109       virtual ~Ev() { 
00110         if(m_sequence) 
00112           delete m_sequence;
00113       }
00114 
00115       InputAction* const getAction() const;
00116 
00117       std::string getDeviceName() const { return m_dev; }
00118 
00119       unsigned int getDeviceMultiple() const { return m_ndev; }
00120 
00121       Sequence* const getSequence() const;
00122 
00123       unsigned long getTimeMargin() const { return m_time_margin; }
00124 
00125       std::string getName() const { 
00126         return m_input; 
00127       }
00128 
00129       Ev& operator<<(const Ev& event);
00130       Ev& operator<<(InputAction* action);
00131 
00132       bool operator==(const Ev& event) const; 
00133       bool operator<(const Ev& event) const; 
00134       bool operator>(const Ev& event) const;
00135 
00136       Ev(const Ev& rhs);
00137       Ev& operator=(const Ev& rhs);
00138 
00139     private:
00140       InputAction* const seqAction() const;
00141 
00143       unsigned int m_time_margin;
00144 
00146       unsigned int m_ndev;
00147 
00149       std::string m_input; 
00150 
00152       std::string m_dev; 
00153 
00154       //this should only be initialized in the Ev responsible for the sequence
00155       Sequence::iterator m_iter;
00156 
00158       bool isAdded(const Ev& event ) const;
00159 
00162       Sequence* m_sequence;
00163 
00165       InputAction* m_action;
00166   };
00167 
00168 }

(c) 2006-2007 John P. Feltz
Generated on Wed Jul 25 16:08:02 2007 for Common Media Input Layer by doxygen 1.4.7

SourceForge.net Logo