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: 2019-08-08 02:52:36 Functions: 2 4 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Event Dispatcher
       2             : // Copyright (c) 2012-2019  Made to Order Software Corp.  All Rights Reserved
       3             : //
       4             : // This program is free software; you can redistribute it and/or modify
       5             : // it under the terms of the GNU General Public License as published by
       6             : // the Free Software Foundation; either version 2 of the License, or
       7             : // (at your option) any later version.
       8             : //
       9             : // This program is distributed in the hope that it will be useful,
      10             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      12             : // GNU General Public License for more details.
      13             : //
      14             : // You should have received a copy of the GNU General Public License
      15             : // along with this program; if not, write to the Free Software
      16             : // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
      17             : #pragma once
      18             : 
      19             : // self
      20             : //
      21             : #include "eventdispatcher/utils.h"
      22             : 
      23             : 
      24             : 
      25             : namespace ed
      26             : {
      27             : 
      28             : 
      29             : 
      30             : typedef int                         message_version_t;
      31             : 
      32             : // this version defines the protocol version, it should really rarely
      33             : // change if ever
      34             : //
      35             : constexpr message_version_t         MESSAGE_VERSION = 1;
      36             : 
      37             : constexpr char const                MESSAGE_VERSION_NAME[]  = "version";
      38             : 
      39             : 
      40             : 
      41           4 : class message
      42             : {
      43             : public:
      44             :     typedef std::vector<message>    vector_t;
      45             :     typedef string_map_t            parameters_t;
      46             : 
      47             :     bool                    from_message(std::string const & msg);
      48             :     std::string             to_message() const;
      49             : 
      50             :     std::string const &     get_sent_from_server() const;
      51             :     void                    set_sent_from_server(std::string const & server);
      52             :     std::string const &     get_sent_from_service() const;
      53             :     void                    set_sent_from_service(std::string const & service);
      54             :     std::string const &     get_server() const;
      55             :     void                    set_server(std::string const & server);
      56             :     std::string const &     get_service() const;
      57             :     void                    set_service(std::string const & service);
      58             :     void                    reply_to(message const & msg);
      59             :     std::string const &     get_command() const;
      60             :     void                    set_command(std::string const & command);
      61             :     message_version_t       get_message_version() const;
      62             :     bool                    check_version_parameter() const;
      63             :     void                    add_version_parameter();
      64             :     void                    add_parameter(std::string const & name, std::string const & value);
      65             :     void                    add_parameter(std::string const & name, std::int32_t value);
      66             :     void                    add_parameter(std::string const & name, std::uint32_t value);
      67             :     void                    add_parameter(std::string const & name, long long value);
      68             :     void                    add_parameter(std::string const & name, unsigned long long value);
      69             :     void                    add_parameter(std::string const & name, std::int64_t value);
      70             :     void                    add_parameter(std::string const & name, std::uint64_t value);
      71             :     bool                    has_parameter(std::string const & name) const;
      72             :     std::string             get_parameter(std::string const & name) const;
      73             :     std::int64_t            get_integer_parameter(std::string const & name) const;
      74             :     parameters_t const &    get_all_parameters() const;
      75             : 
      76             : private:
      77             :     std::string             f_sent_from_server = std::string();
      78             :     std::string             f_sent_from_service = std::string();
      79             :     std::string             f_server = std::string();
      80             :     std::string             f_service = std::string();
      81             :     std::string             f_command = std::string();
      82             :     parameters_t            f_parameters = parameters_t();
      83             :     mutable std::string     f_cached_message = std::string();
      84             : };
      85             : 
      86             : 
      87             : void        verify_message_name(
      88             :                   std::string const & name
      89             :                 , bool can_be_empty = false
      90             :                 , bool can_be_lowercase = true);
      91             : 
      92             : 
      93             : 
      94             : } // namespace snap
      95             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.12