hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
trivial_proto.hpp
Go to the documentation of this file.
1 
6 #ifndef IROHA_SHARED_MODEL_TRIVIAL_PROTO_HPP
7 #define IROHA_SHARED_MODEL_TRIVIAL_PROTO_HPP
8 
10 
11 namespace shared_model {
12  namespace proto {
18  template <typename Iface, typename Proto>
19  class TrivialProto final : public Iface {
20  public:
25  template <typename ProtoLoader>
26  explicit TrivialProto(ProtoLoader &&ref)
27  : proto_(std::forward<ProtoLoader>(ref)) {}
28 
29  protected:
30  typename Iface::ModelType *clone() const override {
31  return new TrivialProto(Proto(*proto_));
32  }
33 
34  private:
36  };
37 
44  template <typename Iface, typename Proto, typename Impl>
45  class CopyableProto : public Iface {
46  public:
51  template <typename ProtoLoader>
52  explicit CopyableProto(ProtoLoader &&ref)
53  : proto_(std::forward<ProtoLoader>(ref)) {}
54 
55  using TransportType = Proto;
56 
57  const Proto &getTransport() const {
58  return *proto_;
59  }
60 
61  protected:
62  typename Iface::ModelType *clone() const override final {
63  return new Impl(Proto(*proto_));
64  }
66  };
67  } // namespace proto
68 } // namespace shared_model
69 
70 #endif // IROHA_SHARED_MODEL_TRIVIAL_PROTO_HPP
detail::ReferenceHolder< Proto > proto_
Definition: trivial_proto.hpp:65
CopyableProto(ProtoLoader &&ref)
Definition: trivial_proto.hpp:52
Iface::ModelType * clone() const override
Definition: trivial_proto.hpp:30
Definition: peer.hpp:48
const Proto & getTransport() const
Definition: trivial_proto.hpp:57
Definition: trivial_proto.hpp:19
Definition: command_executor.hpp:12
Iface::ModelType * clone() const overridefinal
Definition: trivial_proto.hpp:62
Definition: trivial_proto.hpp:45
TrivialProto(ProtoLoader &&ref)
Definition: trivial_proto.hpp:26