LCOV - code coverage report
Current view: top level - eventdispatcher - message.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1 100.0 %
Date: 2021-09-19 09:06:58 Functions: 3 6 50.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
      17             : // along with this program; if not, write to the Free Software
      18             : // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
      19             : #pragma once
      20             : 
      21             : /** \file
      22             :  * \brief Event dispatch class.
      23             :  *
      24             :  * Class used to handle events.
      25             :  */
      26             : 
      27             : // self
      28             : //
      29             : #include    "eventdispatcher/utils.h"
      30             : 
      31             : 
      32             : 
      33             : namespace ed
      34             : {
      35             : 
      36             : 
      37             : 
      38             : typedef int                         message_version_t;
      39             : 
      40             : // this version defines the protocol version, it should really rarely
      41             : // change if ever
      42             : //
      43             : constexpr message_version_t         MESSAGE_VERSION = 1;
      44             : 
      45             : constexpr char const                MESSAGE_VERSION_NAME[]  = "version";
      46             : 
      47             : 
      48             : 
      49          40 : class message
      50             : {
      51             : public:
      52             :     typedef std::shared_ptr<message>    pointer_t;
      53             :     typedef std::vector<message>        vector_t;
      54             :     typedef string_map_t                parameters_t;
      55             : 
      56             :     bool                    from_message(std::string const & msg);
      57             :     std::string             to_message() const;
      58             : 
      59             :     std::string const &     get_sent_from_server() const;
      60             :     void                    set_sent_from_server(std::string const & server);
      61             :     std::string const &     get_sent_from_service() const;
      62             :     void                    set_sent_from_service(std::string const & service);
      63             :     std::string const &     get_server() const;
      64             :     void                    set_server(std::string const & server);
      65             :     std::string const &     get_service() const;
      66             :     void                    set_service(std::string const & service);
      67             :     void                    reply_to(message const & msg);
      68             :     std::string const &     get_command() const;
      69             :     void                    set_command(std::string const & command);
      70             :     message_version_t       get_message_version() const;
      71             :     bool                    check_version_parameter() const;
      72             :     void                    add_version_parameter();
      73             :     void                    add_parameter(std::string const & name, std::string const & value);
      74             :     void                    add_parameter(std::string const & name, std::int32_t value);
      75             :     void                    add_parameter(std::string const & name, std::uint32_t value);
      76             :     void                    add_parameter(std::string const & name, long long value);
      77             :     void                    add_parameter(std::string const & name, unsigned long long value);
      78             :     void                    add_parameter(std::string const & name, std::int64_t value);
      79             :     void                    add_parameter(std::string const & name, std::uint64_t value);
      80             :     bool                    has_parameter(std::string const & name) const;
      81             :     std::string             get_parameter(std::string const & name) const;
      82             :     std::int64_t            get_integer_parameter(std::string const & name) const;
      83             :     parameters_t const &    get_all_parameters() const;
      84             : 
      85             : private:
      86             :     std::string             f_sent_from_server = std::string();
      87             :     std::string             f_sent_from_service = std::string();
      88             :     std::string             f_server = std::string();
      89             :     std::string             f_service = std::string();
      90             :     std::string             f_command = std::string();
      91             :     parameters_t            f_parameters = parameters_t();
      92             :     mutable std::string     f_cached_message = std::string();
      93             : };
      94             : 
      95             : 
      96             : void        verify_message_name(
      97             :                   std::string const & name
      98             :                 , bool can_be_empty = false
      99             :                 , bool can_be_lowercase = true);
     100             : 
     101             : 
     102             : 
     103             : } // namespace ed
     104             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.13