Mir
mir_event_distributor.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2014 Canonical Ltd.
3  *
4  * This program is free software: you can redistribute it and/or modify it
5  * under the terms of the GNU Lesser General Public License version 3,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General 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  * Authored by: Nick Dedekind <nick.dedekind@canonical.com>
17  */
18 
19 #ifndef MIR_EVENT_DISTRIBUTOR_H
20 
21 #include "event_distributor.h"
22 
23 #include <mutex>
24 #include <map>
25 
27 {
28 public:
30  ~MirEventDistributor() = default;
31 
32  int register_event_handler(std::function<void(MirEvent const&)> const&) override;
33  void unregister_event_handler(int id) override;
34 
35  void handle_event(MirEvent const& event) override;
36 
37 private:
38  mutable std::recursive_mutex mutex;
39  std::map<int, std::function<void(MirEvent const&)>> event_handlers;
40  int next_fn_id;
41 };
42 
43 #endif /* MIR_EVENT_DISTRIBUTOR_H */
Definition: mir_event_distributor.h:26
MirEventDistributor()
Definition: mir_event_distributor.cpp:21
Definition: event_distributor.h:30
void unregister_event_handler(int id) override
Definition: mir_event_distributor.cpp:35
void handle_event(MirEvent const &event) override
Definition: mir_event_distributor.cpp:42
int register_event_handler(std::function< void(MirEvent const &)> const &) override
Definition: mir_event_distributor.cpp:26
Definition: event.h:30
~MirEventDistributor()=default

Copyright © 2012-2015 Canonical Ltd.
Generated on Thu Sep 8 14:50:19 UTC 2016