Line data Source code
1 : // Copyright (c) 2012-2019 Made to Order Software Corp. All Rights Reserved
2 : //
3 : // This program is free software; you can redistribute it and/or modify
4 : // it under the terms of the GNU General Public License as published by
5 : // the Free Software Foundation; either version 2 of the License, or
6 : // (at your option) any later version.
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 General Public License for more details.
12 : //
13 : // You should have received a copy of the GNU General Public License
14 : // along with this program; if not, write to the Free Software
15 : // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16 : #pragma once
17 :
18 : // self
19 : //
20 : #include "eventdispatcher/connection.h"
21 :
22 :
23 :
24 : namespace ed
25 : {
26 :
27 :
28 :
29 : // WARNING: a snap_communicator object must be allocated and held in a shared pointer (see pointer_t)
30 : #pragma GCC diagnostic push
31 : #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
32 0 : class communicator
33 : : public std::enable_shared_from_this<communicator>
34 : {
35 : public:
36 : typedef std::shared_ptr<communicator> pointer_t;
37 :
38 : static pointer_t instance();
39 :
40 : connection::vector_t const & get_connections() const;
41 : bool add_connection(connection::pointer_t connection);
42 : bool remove_connection(connection::pointer_t connection);
43 : void set_force_sort(bool status = true);
44 :
45 : virtual bool run();
46 :
47 : private:
48 : communicator();
49 : communicator(communicator const & communicator) = delete;
50 :
51 : communicator & operator = (communicator const & communicator) = delete;
52 :
53 : connection::vector_t f_connections = connection::vector_t();
54 : bool f_force_sort = true;
55 : };
56 : #pragma GCC diagnostic pop
57 :
58 :
59 : } // namespace snap
60 : // vim: ts=4 sw=4 et
|