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_fwd.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(logger::LoggerPtr log);
41 
42  private:
43  // Query serializer:
44  protocol::Query serializeGetAccount(
45  std::shared_ptr<const Query> query) const;
46  protocol::Query serializeGetAccountAssets(
47  std::shared_ptr<const Query> query) const;
48  protocol::Query serializeGetAccountDetail(
49  std::shared_ptr<const Query> query) const;
50  protocol::Query serializeGetTransactions(
51  std::shared_ptr<const Query> query) const;
52  protocol::Query serializeGetAccountTransactions(
53  std::shared_ptr<const Query> query) const;
54  protocol::Query serializeGetAccountAssetTransactions(
55  std::shared_ptr<const Query> query) const;
56  protocol::Query serializeGetSignatories(
57  std::shared_ptr<const Query> query) const;
58  protocol::Query serializeGetAssetInfo(
59  std::shared_ptr<const Query> query) const;
60  protocol::Query serializeGetRoles(
61  std::shared_ptr<const Query> query) const;
62  protocol::Query serializeGetRolePermissions(
63  std::shared_ptr<const Query> query) const;
64 
70  void serializeQueryMetaData(protocol::Query &pb_query,
71  std::shared_ptr<const Query> query) const;
72 
73  using Serializer = protocol::Query (PbQueryFactory::*)(
74  std::shared_ptr<const Query>) const;
75  std::unordered_map<std::type_index, Serializer> serializers_;
76 
77  logger::LoggerPtr log_;
78  };
79 
80  } // namespace converters
81  } // namespace model
82 } // namespace iroha
83 
84 #endif // IROHA_PB_QUERY_FACTORY_HPP
Definition: pb_query_factory.hpp:22
boost::optional< std::shared_ptr< T >> optional_ptr
Definition: common.hpp:16
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
boost::optional< protocol::Query > serialize(std::shared_ptr< const model::Query > query) const
Definition: pb_query_factory.cpp:162
PbQueryFactory(logger::LoggerPtr log)
Definition: pb_query_factory.cpp:23
Definition: block_query.hpp:14
optional_ptr< model::Query > deserialize(const protocol::Query &pb_query) const
Definition: pb_query_factory.cpp:45