00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00023
00024 #include "TriggerAND.h"
00025
00026 template<class Caller, typename InputType>
00027 TriggerAND<Caller,InputType>::TriggerAND(Caller* c, Action a):
00028 cal(c),
00029 act(a)
00030 {
00031 }
00032
00033 template<class Caller, typename InputType>
00034 TriggerAND<Caller,InputType>::~TriggerAND()
00035 {
00036 }
00037
00038
00039 template<class Caller, typename InputType>
00040 bool TriggerAND<Caller,InputType>::commit(InputType num, bool state)
00041 {
00042 typename InputMap::iterator it=inputs.find(num);
00043 if( it!=inputs.end() )
00044 {
00045 inputs[num] = state;
00046 check();
00047 return true;
00048 }
00049
00050 return false;
00051 }
00052
00053
00054 template<class Caller, typename InputType>
00055 void TriggerAND<Caller,InputType>::add(InputType num, bool state)
00056 {
00057 inputs[num] = state;
00058 check();
00059 }
00060
00061
00062 template<class Caller, typename InputType>
00063 void TriggerAND<Caller,InputType>::remove(InputType num)
00064 {
00065 typename InputMap::iterator it=inputs.find(num);
00066 if( it!=inputs.end() )
00067 inputs.erase(it);
00068
00069 check();
00070 }
00071
00072
00073 template<class Caller, typename InputType>
00074 bool TriggerAND<Caller,InputType>::getState(InputType num)
00075 {
00076 typename InputMap::iterator it=inputs.find(num);
00077 if( it!=inputs.end() )
00078 return it->second;
00079
00080 return false;
00081 }
00082
00083 template<class Caller, typename InputType>
00084 void TriggerAND<Caller,InputType>::check()
00085 {
00086 bool old = out;
00087 for( typename InputMap::iterator it=inputs.begin(); it!=inputs.end(); ++it )
00088 {
00089 if( !it->second )
00090 {
00091
00092
00093 out = false;
00094 if( old != out )
00095 {
00096
00097
00098 (cal->*act)(out);
00099
00100
00101 }
00102 return;
00103 }
00104 }
00105
00106 out = true;
00107 if( old != out )
00108 {
00109
00110
00111 (cal->*act)(out);
00112
00113
00114 }
00115 }
00116
00117 template<class Caller, typename InputType>
00118 void TriggerAND<Caller,InputType>::update()
00119 {
00120 (cal->*act)(out);
00121 }
00122
00123 template<class Caller, typename InputType>
00124 void TriggerAND<Caller,InputType>::reset()
00125 {
00126 out = false;
00127 (cal->*act)(out);
00128 }
00129