|
UniSet
2.6.0
|
00001 /* 00002 * Copyright (c) 2015 Pavel Vainerman. 00003 * 00004 * This program is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU Lesser General Public License as 00006 * published by the Free Software Foundation, version 2.1. 00007 * 00008 * This program is distributed in the hope that it will be useful, but 00009 * WITHOUT ANY WARRANTY; without even the implied warranty of 00010 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 * Lesser General Lesser Public License for more details. 00012 * 00013 * You should have received a copy of the GNU Lesser General Public License 00014 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00015 */ 00016 // -------------------------------------------------------------------------- 00020 // -------------------------------------------------------------------------- 00021 //--------------------------------------------------------------------------- 00022 #ifndef TriggerOUT_H_ 00023 #define TriggerOUT_H_ 00024 //--------------------------------------------------------------------------- 00025 #include <unordered_map> 00026 //--------------------------------------------------------------------------- 00027 namespace uniset 00028 { 00083 template<class Caller, typename OutIdType = int, typename ValueType = bool> 00084 class TriggerOUT 00085 { 00086 public: 00087 00092 typedef void(Caller::* Action)(OutIdType out, ValueType val); 00093 00094 TriggerOUT(Caller* r, Action a) noexcept; 00095 ~TriggerOUT() noexcept; 00096 00097 00099 bool getState(OutIdType out) const noexcept; 00100 00105 void set(OutIdType out, ValueType val); 00106 00111 void add(OutIdType out, ValueType val); 00112 00114 void remove(OutIdType out) noexcept; 00115 00116 void update(); 00117 void reset(); 00118 00119 protected: 00120 void resetOuts( OutIdType outIgnore ); 00121 00122 typedef std::unordered_map<OutIdType, ValueType> OutList; 00123 OutList outs; // список выходов 00124 00125 Caller* cal; 00126 Action act; 00127 00128 }; 00129 // ------------------------------------------------------------------------- 00130 #include "TriggerOUT.tcc" 00131 //--------------------------------------------------------------------------- 00132 } // end of uniset namespace 00133 //--------------------------------------------------------------------------- 00134 #endif
1.7.6.1