hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
noncopyable_proto.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_NONCOPYABLE_PROTO_HPP
7 #define IROHA_NONCOPYABLE_PROTO_HPP
8 
15 template <typename Iface, typename Proto, typename Impl>
16 class NonCopyableProto : public Iface {
17  public:
18  using TransportType = Proto;
19 
20  /*
21  * Construct object from transport. Transport can be moved or copied.
22  */
23  template <typename Transport>
24  NonCopyableProto(Transport &&ref) : proto_(std::forward<Transport>(ref)){}
25 
26  NonCopyableProto(const NonCopyableProto &o) = delete;
27  NonCopyableProto &operator=(const NonCopyableProto &o) = delete;
28 
29  const Proto &getTransport() const {
30  return proto_;
31  }
32 
33  protected:
34  typename Iface::ModelType *clone() const override final {
35  return new Impl(proto_);
36  }
37 
38  Proto proto_;
39 };
40 
41 #endif // IROHA_NONCOPYABLE_PROTO_HPP
Definition: noncopyable_proto.hpp:16
const Proto & getTransport() const
Definition: noncopyable_proto.hpp:29
NonCopyableProto(Transport &&ref)
Definition: noncopyable_proto.hpp:24
Proto TransportType
Definition: noncopyable_proto.hpp:18
NonCopyableProto & operator=(const NonCopyableProto &o)=delete
Definition: peer.hpp:48
Iface::ModelType * clone() const overridefinal
Definition: noncopyable_proto.hpp:34
Proto proto_
Definition: noncopyable_proto.hpp:38