UniSet  2.24.2
TriggerOUT.h
1 /*
2  * Copyright (c) 2015 Pavel Vainerman.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as
6  * published by the Free Software Foundation, version 2.1.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Lesser Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 // --------------------------------------------------------------------------
20 // --------------------------------------------------------------------------
21 //---------------------------------------------------------------------------
22 #ifndef TriggerOUT_H_
23 #define TriggerOUT_H_
24 //---------------------------------------------------------------------------
25 #include <unordered_map>
26 //---------------------------------------------------------------------------
27 namespace uniset
28 {
83  template<class Caller, typename OutIdType = int, typename ValueType = bool>
84  class TriggerOUT
85  {
86  public:
87 
92  typedef void(Caller::* Action)(OutIdType out, ValueType val);
93 
94  TriggerOUT(Caller* r, Action a) noexcept;
95  ~TriggerOUT() noexcept;
96 
97 
99  bool getState(OutIdType out) const noexcept;
100 
105  void set(OutIdType out, ValueType val);
106 
111  void add(OutIdType out, ValueType val);
112 
114  void remove(OutIdType out) noexcept;
115 
116  void update();
117  void reset();
118 
119  protected:
120  void resetOuts( OutIdType outIgnore );
121 
122  typedef std::unordered_map<OutIdType, ValueType> OutList;
123  OutList outs; // список выходов
124 
125  Caller* cal;
126  Action act;
127 
128  };
129  // -------------------------------------------------------------------------
130 #include "TriggerOUT.tcc"
131  //---------------------------------------------------------------------------
132 } // end of uniset namespace
133 //---------------------------------------------------------------------------
134 #endif
Definition: TriggerOUT.h:85
void add(OutIdType out, ValueType val)
void set(OutIdType out, ValueType val)
void(Caller::* Action)(OutIdType out, ValueType val)
Definition: TriggerOUT.h:92
void remove(OutIdType out) noexcept
bool getState(OutIdType out) const noexcept
Definition: CommonEventLoop.h:15