LCOV - code coverage report
Current view: top level - zeroeq - types.h (source / functions) Hit Total Coverage
Test: ZeroEQ Lines: 5 5 100.0 %
Date: 2017-12-01 01:44:57 Functions: 0 0 -

          Line data    Source code
       1             : 
       2             : /* Copyright (c) 2014-2017, Human Brain Project
       3             :  *                          Daniel Nachbaur <daniel.nachbaur@epfl.ch>
       4             :  *                          Juan Hernando <jhernando@fi.upm.es>
       5             :  */
       6             : 
       7             : #pragma once
       8             : 
       9             : #include <functional>
      10             : #include <memory>
      11             : #include <servus/serializable.h>
      12             : #include <servus/servus.h>
      13             : #include <servus/types.h>
      14             : #include <servus/uint128_t.h>
      15             : #include <zeroeq/defines.h>
      16             : 
      17             : #ifdef _WIN32
      18             : #define NOMINMAX
      19             : #include <winsock2.h> // SOCKET
      20             : #ifdef DELETE
      21             : #undef DELETE
      22             : #endif
      23             : #endif
      24             : 
      25             : /**
      26             :  * Publish-subscribe and request-reply.
      27             :  *
      28             :  * A Publisher opens a listening port on the network, and publishes an Event on
      29             :  * this port. It announces its session for automatic discovery.
      30             :  *
      31             :  * A Subscriber either explicitely subscribes to the publisher port, or uses
      32             :  * automatic discovery to find publishers using the same session. Automatic
      33             :  * discovery is implemented using zeroconf networking (avahi or Apple Bonjour).
      34             :  *
      35             :  * A Server serves requests from a Client. Like publish-subscribe, clients
      36             :  * connect to servers using zeroconf discovery or explicit addressing.
      37             :  *
      38             :  * A Monitor can be used on any Sender to receive notification on incoming
      39             :  * connections.
      40             :  *
      41             :  * The connection::Broker and connection::Service may be used to introduce a
      42             :  * subscriber to a remote, not zeroconf visible, publisher.
      43             :  */
      44             : namespace zeroeq
      45             : {
      46             : using servus::uint128_t;
      47             : class Monitor;
      48             : class Publisher;
      49             : class Sender;
      50             : class Subscriber;
      51             : class URI;
      52             : 
      53             : using URIs = std::vector<URI>; //!< A vector of URIs
      54             : 
      55             : /** Callback for receival of subscribed event without payload. */
      56             : using EventFunc = std::function<void()>;
      57             : 
      58             : /** Callback for receival of subscribed event with payload. */
      59             : using EventPayloadFunc = std::function<void(const void*, size_t)>;
      60             : 
      61             : /** Callback for the reply of a Client::request() (reply ID, reply data). */
      62             : using ReplyFunc = std::function<void(const uint128_t&, const void*, size_t)>;
      63             : 
      64             : /** Return value of Server::handle() function (reply ID, reply data) */
      65             : using ReplyData = std::pair<uint128_t, servus::Serializable::Data>;
      66             : 
      67             : /** Callback for serving a Client::request() in Server::handle(). */
      68             : using HandleFunc = std::function<ReplyData(const void*, size_t)>;
      69             : 
      70             : #ifdef WIN32
      71             : typedef SOCKET SocketDescriptor;
      72             : #else
      73             : typedef int SocketDescriptor;
      74             : #endif
      75             : 
      76             : /** Constant defining 'wait forever' in methods with wait parameters. */
      77             : // Attn: identical to Win32 INFINITE!
      78             : static const uint32_t TIMEOUT_INDEFINITE = 0xffffffffu;
      79             : 
      80             : using servus::make_uint128;
      81             : 
      82         127 : static const std::string DEFAULT_SESSION("__zeroeq");
      83         127 : static const std::string NULL_SESSION("__null_session");
      84         127 : static const std::string TEST_SESSION(servus::TEST_DRIVER);
      85         127 : static const std::string ENV_PUB_SESSION("ZEROEQ_PUB_SESSION");
      86         127 : static const std::string ENV_REP_SESSION("ZEROEQ_SERVER_SESSION");
      87             : 
      88             : namespace detail
      89             : {
      90             : struct Socket;
      91             : }
      92             : namespace zmq
      93             : {
      94             : using ContextPtr = std::shared_ptr<void>;
      95             : using SocketPtr = std::shared_ptr<void>;
      96             : }
      97             : }

Generated by: LCOV version 1.11