zmqpp  4.1.2
C++ bindings for 0mq (libzmq)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
frame.hpp
Go to the documentation of this file.
1 /*
2  * This Source Code Form is subject to the terms of the Mozilla Public
3  * License, v. 2.0. If a copy of the MPL was not distributed with this
4  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
5  *
6  * This file is part of zmqpp.
7  * Copyright (c) 2011-2015 Contributors as noted in the AUTHORS file.
8  */
9 
17 #ifndef ZMQPP_MESSAGE_FRAME_HPP_
18 #define ZMQPP_MESSAGE_FRAME_HPP_
19 
20 #include <zmq.h>
21 
22 #include "compatibility.hpp"
23 
24 namespace zmqpp {
25 
33 class frame
34 {
35 public:
36  frame();
37  frame(size_t const size);
38  frame(void const* part, size_t const size);
39  frame(void* part, size_t const size, zmq_free_fn *ffn, void *hint);
40 
41  ~frame();
42 
43  bool is_sent() const { return _sent; }
44  void const* data() const { return zmq_msg_data( const_cast<zmq_msg_t*>(&_msg) ); }
45  size_t size() const { return zmq_msg_size( const_cast<zmq_msg_t*>(&_msg) ); }
46 
47  void mark_sent() { _sent = true; }
48  zmq_msg_t& msg() { return _msg; }
49 
50  // Move operators
51  frame(frame&& other);
52  frame& operator=(frame&& other);
53 
54  frame copy() const;
55 
56 private:
57  bool _sent;
58  zmq_msg_t _msg;
59 
60  // Disable implicit copy support, code must request a copy to clone
62  frame& operator=(frame const&) NOEXCEPT ZMQPP_EXPLICITLY_DELETED;
63 };
64 
65 } // namespace zmqpp
66 
67 #endif /* ZMQPP_MESSAGE_FRAME_HPP_ */
#define ZMQPP_EXPLICITLY_DELETED
Definition: compatibility.hpp:100
C++ wrapper around zmq.
Definition: actor.cpp:29
~frame()
Definition: frame.cpp:64
bool is_sent() const
Definition: frame.hpp:43
zmq_msg_t & msg()
Definition: frame.hpp:48
void mark_sent()
Definition: frame.hpp:47
frame & operator=(frame &&other)
Definition: frame.cpp:82
size_t size() const
Definition: frame.hpp:45
frame()
Definition: frame.cpp:25
#define NOEXCEPT
Definition: compatibility.hpp:104
zmq_msg_t _msg
Definition: frame.hpp:58
void const * data() const
Definition: frame.hpp:44
an internal frame wrapper for a single zmq message
Definition: frame.hpp:33
frame copy() const
Definition: frame.cpp:91
bool _sent
Definition: frame.hpp:57