00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 namespace cmil {
00027
00028 class Ev : public Logger {
00029 public:
00030 typedef std::vector<Ev> Sequence;
00031
00032
00033 static std::string sdev;
00034
00035
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
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
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 }