Skip to content

Commit

Permalink
Merge pull request hyperledger-iroha#738 from hyperledger/feature/sha…
Browse files Browse the repository at this point in the history
…red_model_queries
  • Loading branch information
l4l authored and lebdron committed Dec 19, 2017
2 parents faa709b + 8840114 commit 058aed7
Show file tree
Hide file tree
Showing 19 changed files with 617 additions and 81 deletions.
2 changes: 1 addition & 1 deletion shared_model/backend/protobuf/common_objects/signature.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#define IROHA_PROTO_SIGNATURE_HPP

#include "interfaces/common_objects/signature.hpp"

#include "backend/protobuf/common_objects/trivial_proto.hpp"
#include "primitive.pb.h"

namespace shared_model {
Expand Down
2 changes: 0 additions & 2 deletions shared_model/backend/protobuf/queries/proto_get_account.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
* limitations under the License.
*/


#ifndef IROHA_PROTO_GET_ACCOUNT_H
#define IROHA_PROTO_GET_ACCOUNT_H

Expand Down Expand Up @@ -49,7 +48,6 @@ namespace shared_model {

private:
// ------------------------------| fields |-------------------------------

const detail::LazyInitializer<const iroha::protocol::GetAccount &>
account_id_;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved.
* http://soramitsu.co.jp
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef IROHA_GET_ACCOUNT_ASSET_TRANSACTIONS_H
#define IROHA_GET_ACCOUNT_ASSET_TRANSACTIONS_H

#include "interfaces/queries/get_account_transactions.hpp"

#include "queries.pb.h"
#include "utils/lazy_initializer.hpp"
#include "utils/reference_holder.hpp"

namespace shared_model {
namespace proto {
class GetAccountAssetTransactions final
: public CopyableProto<interface::GetAccountAssetTransactions,
iroha::protocol::Query,
GetAccountAssetTransactions> {
public:
template <typename QueryType>
explicit GetAccountAssetTransactions(QueryType &&query)
: CopyableProto(std::forward<QueryType>(query)),
account_id_(detail::makeReferenceGenerator(
&proto_->payload(),
&iroha::protocol::Query::Payload::get_account_transactions)),
asset_id_(detail::makeReferenceGenerator(
&proto_->payload(),
&iroha::protocol::Query::Payload::get_account_assets)) {}

GetAccountAssetTransactions(const GetAccountAssetTransactions &o)
: GetAccountAssetTransactions(o.proto_) {}

GetAccountAssetTransactions(GetAccountAssetTransactions &&o) noexcept
: GetAccountAssetTransactions(std::move(o.proto_)) {}

const interface::types::AccountIdType &accountId() const override {
return account_id_->account_id();
}

const interface::types::AssetIdType &assetId() const override {
return asset_id_->asset_id();
}

private:
// ------------------------------| fields |-------------------------------

template <typename T>
using Lazy = detail::LazyInitializer<T>;

const Lazy<const iroha::protocol::GetAccountTransactions &> account_id_;
const Lazy<const iroha::protocol::GetAccountAssets &> asset_id_;
};

} // namespace proto
} // namespace shared_model

#endif // IROHA_GET_ACCOUNT_ASSET_TRANSACTIONS_H
71 changes: 71 additions & 0 deletions shared_model/backend/protobuf/queries/proto_get_account_assets.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved.
* http://soramitsu.co.jp
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef IROHA_PROTO_GET_ACCOUNT_ASSETS_H
#define IROHA_PROTO_GET_ACCOUNT_ASSETS_H

#include "interfaces/queries/get_account_assets.hpp"

#include "queries.pb.h"
#include "utils/lazy_initializer.hpp"
#include "utils/reference_holder.hpp"

namespace shared_model {
namespace proto {
class GetAccountAssets final
: public CopyableProto<interface::GetAccountAssets,
iroha::protocol::Query,
GetAccountAssets> {
public:
template <typename QueryType>
explicit GetAccountAssets(QueryType &&query)
: CopyableProto(std::forward<QueryType>(query)),
account_id_(detail::makeReferenceGenerator(
&proto_->payload(),
&iroha::protocol::Query::Payload::get_account)),
asset_id_(detail::makeReferenceGenerator(
&proto_->payload(),
&iroha::protocol::Query::Payload::get_account_assets)) {}

GetAccountAssets(const GetAccountAssets &o)
: GetAccountAssets(o.proto_) {}

GetAccountAssets(GetAccountAssets &&o) noexcept
: GetAccountAssets(std::move(o.proto_)) {}

const interface::types::AccountIdType &accountId() const override {
return account_id_->account_id();
}

const interface::types::AssetIdType &assetId() const override {
return asset_id_->asset_id();
}

private:
// ------------------------------| fields |-------------------------------

template <typename T>
using Lazy = detail::LazyInitializer<T>;

const Lazy<const iroha::protocol::GetAccount &> account_id_;
const Lazy<const iroha::protocol::GetAccountAssets &> asset_id_;
};

} // namespace proto
} // namespace shared_model

#endif // IROHA_PROTO_GET_ACCOUNT_ASSETS_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved.
* http://soramitsu.co.jp
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef IROHA_GET_ACCOUNT_TRANSACTIONS_H
#define IROHA_GET_ACCOUNT_TRANSACTIONS_H

#include "interfaces/queries/get_account_transactions.hpp"

#include "queries.pb.h"
#include "utils/lazy_initializer.hpp"
#include "utils/reference_holder.hpp"

namespace shared_model {
namespace proto {
class GetAccountTransactions final
: public CopyableProto<interface::GetAccountTransactions,
iroha::protocol::Query,
GetAccountTransactions> {
public:
template <typename QueryType>
explicit GetAccountTransactions(QueryType &&query)
: CopyableProto(std::forward<QueryType>(query)),
account_id_(detail::makeReferenceGenerator(
&proto_->payload(),
&iroha::protocol::Query::Payload::get_account_transactions)) {}

GetAccountTransactions(const GetAccountTransactions &o)
: GetAccountTransactions(o.proto_) {}

GetAccountTransactions(GetAccountTransactions &&o) noexcept
: GetAccountTransactions(std::move(o.proto_)) {}

const interface::types::AccountIdType &accountId() const override {
return account_id_->account_id();
}

private:
// ------------------------------| fields |-------------------------------

template <typename T>
using Lazy = detail::LazyInitializer<T>;

const Lazy<const iroha::protocol::GetAccountTransactions &> account_id_;
};

} // namespace proto
} // namespace shared_model

#endif // IROHA_GET_ACCOUNT_TRANSACTIONS_H
58 changes: 58 additions & 0 deletions shared_model/backend/protobuf/queries/proto_get_asset_info.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved.
* http://soramitsu.co.jp
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef IROHA_PROTO_GET_ASSET_INFO_H
#define IROHA_PROTO_GET_ASSET_INFO_H

#include "interfaces/queries/get_asset_info.hpp"

#include "queries.pb.h"
#include "utils/lazy_initializer.hpp"
#include "utils/reference_holder.hpp"

namespace shared_model {
namespace proto {
class GetAssetInfo final : public CopyableProto<interface::GetAssetInfo,
iroha::protocol::Query,
GetAssetInfo> {
public:
template <typename QueryType>
explicit GetAssetInfo(QueryType &&query)
: CopyableProto(std::forward<QueryType>(query)),
asset_id_(detail::makeReferenceGenerator(
&proto_->payload(),
&iroha::protocol::Query::Payload::get_asset_info)) {}

GetAssetInfo(const GetAssetInfo &o) : GetAssetInfo(o.proto_) {}

GetAssetInfo(GetAssetInfo &&o) noexcept
: GetAssetInfo(std::move(o.proto_)) {}

const interface::types::AssetIdType &assetId() const override {
return asset_id_->asset_id();
}

private:
// ------------------------------| fields |-------------------------------
const detail::LazyInitializer<const iroha::protocol::GetAssetInfo &>
asset_id_;
};

} // namespace proto
} // namespace shared_model

#endif // IROHA_PROTO_GET_ASSET_INFO_H
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved.
* http://soramitsu.co.jp
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef IROHA_PROTO_GET_ROLE_PERMISSIONS_H
#define IROHA_PROTO_GET_ROLE_PERMISSIONS_H

#include "interfaces/queries/get_role_permissions.hpp"

#include "queries.pb.h"
#include "utils/lazy_initializer.hpp"
#include "utils/reference_holder.hpp"

namespace shared_model {
namespace proto {
class GetRolePermissions final
: public CopyableProto<interface::GetRolePermissions,
iroha::protocol::Query,
GetRolePermissions> {
public:
template <typename QueryType>
explicit GetRolePermissions(QueryType &&query)
: CopyableProto(std::forward<QueryType>(query)),
role_id_(detail::makeReferenceGenerator(
&proto_->payload(),
&iroha::protocol::Query::Payload::get_role_permissions)) {}

GetRolePermissions(const GetRolePermissions &o)
: GetRolePermissions(o.proto_) {}

GetRolePermissions(GetRolePermissions &&o) noexcept
: GetRolePermissions(std::move(o.proto_)) {}

const interface::types::RoleIdType &roleId() const override {
return role_id_->role_id();
}

private:
// ------------------------------| fields |-------------------------------
const detail::LazyInitializer<const iroha::protocol::GetRolePermissions &>
role_id_;
};

} // namespace proto
} // namespace shared_model

#endif // IROHA_PROTO_GET_ROLE_PERMISSIONS_H
45 changes: 45 additions & 0 deletions shared_model/backend/protobuf/queries/proto_get_roles.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved.
* http://soramitsu.co.jp
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef IROHA_PROTO_GET_ROLES_H
#define IROHA_PROTO_GET_ROLES_H

#include "interfaces/queries/get_roles.hpp"

#include "queries.pb.h"
#include "utils/lazy_initializer.hpp"
#include "utils/reference_holder.hpp"

namespace shared_model {
namespace proto {
class GetRoles final : public CopyableProto<interface::GetRoles,
iroha::protocol::Query,
GetRoles> {
public:
template <typename QueryType>
explicit GetRoles(QueryType &&query)
: CopyableProto(std::forward<QueryType>(query)) {}

GetRoles(const GetRoles &o) : GetRoles(o.proto_) {}

GetRoles(GetRoles &&o) noexcept : GetRoles(std::move(o.proto_)) {}
};

} // namespace proto
} // namespace shared_model

#endif // IROHA_PROTO_GET_ROLES_H
Loading

0 comments on commit 058aed7

Please sign in to comment.