hyperledger/iroha
Iroha - A simple, decentralized ledger http://iroha.tech
pb_query_factory.hpp
Go to the documentation of this file.
1 
5 #ifndef IROHA_PB_QUERY_FACTORY_HPP
6 #define IROHA_PB_QUERY_FACTORY_HPP
7 
8 #include <typeindex>
9 #include <unordered_map>
10 #include "logger/logger.hpp"
11 #include "model/common.hpp"
12 #include "model/query.hpp"
13 #include "queries.pb.h"
14 
15 namespace iroha {
16  namespace model {
17  namespace converters {
18 
23  public:
30  const protocol::Query &pb_query) const;
31 
37  boost::optional<protocol::Query> serialize(
38  std::shared_ptr<const model::Query> query) const;
39 
40  explicit PbQueryFactory(
41  logger::Logger log = logger::log("PbQueryFactory"));
42 
43  private:
44  // Query serializer:
45  protocol::Query serializeGetAccount(
46  std::shared_ptr<const Query> query) const;
47  protocol::Query serializeGetAccountAssets(
48  std::shared_ptr<const Query> query) const;
49  protocol::Query serializeGetAccountDetail(
50  std::shared_ptr<const Query> query) const;
51  protocol::Query serializeGetTransactions(
52  std::shared_ptr<const Query> query) const;
53  protocol::Query serializeGetAccountTransactions(
54  std::shared_ptr<const Query> query) const;
55  protocol::Query serializeGetAccountAssetTransactions(
56  std::shared_ptr<const Query> query) const;
57  protocol::Query serializeGetSignatories(
58  std::shared_ptr<const Query> query) const;
59  protocol::Query serializeGetAssetInfo(
60  std::shared_ptr<const Query> query) const;
61  protocol::Query serializeGetRoles(
62  std::shared_ptr<const Query> query) const;
63  protocol::Query serializeGetRolePermissions(
64  std::shared_ptr<const Query> query) const;
65 
71  void serializeQueryMetaData(protocol::Query &pb_query,
72  std::shared_ptr<const Query> query) const;
73 
74  using Serializer = protocol::Query (PbQueryFactory::*)(
75  std::shared_ptr<const Query>) const;
76  std::unordered_map<std::type_index, Serializer> serializers_;
77 
78  logger::Logger log_;
79  };
80 
81  } // namespace converters
82  } // namespace model
83 } // namespace iroha
84 
85 #endif // IROHA_PB_QUERY_FACTORY_HPP
Definition: pb_query_factory.hpp:22
PbQueryFactory(logger::Logger log=logger::log("PbQueryFactory"))
Definition: pb_query_factory.cpp:22
boost::optional< std::shared_ptr< T >> optional_ptr
Definition: common.hpp:16
boost::optional< protocol::Query > serialize(std::shared_ptr< const model::Query > query) const
Definition: pb_query_factory.cpp:161
std::shared_ptr< spdlog::logger > Logger
Definition: logger.hpp:26
Definition: block_query.hpp:16
Logger log(const std::string &tag)
Definition: logger.cpp:48
optional_ptr< model::Query > deserialize(const protocol::Query &pb_query) const
Definition: pb_query_factory.cpp:44