LCOV - code coverage report
Current view: top level - eventdispatcher - communicator.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 1 0.0 %
Date: 2021-09-19 09:06:58 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2012-2021  Made to Order Software Corp.  All Rights Reserved
       2             : //
       3             : // https://snapwebsites.org/project/eventdispatcher
       4             : // contact@m2osw.com
       5             : //
       6             : // This program is free software; you can redistribute it and/or modify
       7             : // it under the terms of the GNU General Public License as published by
       8             : // the Free Software Foundation; either version 2 of the License, or
       9             : // (at your option) any later version.
      10             : //
      11             : // This program is distributed in the hope that it will be useful,
      12             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             : // GNU General Public License for more details.
      15             : //
      16             : // You should have received a copy of the GNU General Public License along
      17             : // with this program; if not, write to the Free Software Foundation, Inc.,
      18             : // 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
      19             : #pragma once
      20             : 
      21             : /** \file
      22             :  * \brief Declaration of the communicator class.
      23             :  *
      24             :  * The communicator is the manager of the event dispatcher connections.
      25             :  * It handles the run() function with a poll() loop listening to all the
      26             :  * connections and calling your virtual connection functions.
      27             :  */
      28             : 
      29             : 
      30             : // self
      31             : //
      32             : #include    "eventdispatcher/connection.h"
      33             : 
      34             : 
      35             : 
      36             : namespace ed
      37             : {
      38             : 
      39             : 
      40             : 
      41             : // WARNING: a communicator object must be allocated and held in a shared pointer (see pointer_t)
      42             : #pragma GCC diagnostic push
      43             : #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
      44           0 : class communicator
      45             :     : public std::enable_shared_from_this<communicator>
      46             : {
      47             : public:
      48             :     typedef std::shared_ptr<communicator>       pointer_t;
      49             : 
      50             :     static pointer_t                    instance();
      51             : 
      52             :     connection::vector_t const &        get_connections() const;
      53             :     bool                                add_connection(connection::pointer_t connection);
      54             :     bool                                remove_connection(connection::pointer_t connection);
      55             :     void                                set_force_sort(bool status = true);
      56             :     bool                                is_running() const;
      57             : 
      58             :     virtual bool                        run();
      59             : 
      60             : private:
      61             :                                         communicator();
      62             :                                         communicator(communicator const & communicator) = delete;
      63             : 
      64             :     communicator &                      operator = (communicator const & communicator) = delete;
      65             : 
      66             :     connection::vector_t                f_connections = connection::vector_t();
      67             :     bool                                f_force_sort = true;
      68             :     bool                                f_running = false;
      69             : };
      70             : #pragma GCC diagnostic pop
      71             : 
      72             : 
      73             : } // namespace ed
      74             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.13