LCOV - code coverage report
Current view: top level - shared_model/backend/protobuf/common_objects - account_asset.hpp (source / functions) Hit Total Coverage
Test: coverage_cleared.info Lines: 5 5 100.0 %
Date: 2018-12-05 17:11:35 Functions: 14 14 100.0 %

          Line data    Source code
       1             : /**
       2             :  * Copyright Soramitsu Co., Ltd. 2017 All Rights Reserved.
       3             :  * http://soramitsu.co.jp
       4             :  *
       5             :  * Licensed under the Apache License, Version 2.0 (the "License");
       6             :  * you may not use this file except in compliance with the License.
       7             :  * You may obtain a copy of the License at
       8             :  *
       9             :  *        http://www.apache.org/licenses/LICENSE-2.0
      10             :  *
      11             :  * Unless required by applicable law or agreed to in writing, software
      12             :  * distributed under the License is distributed on an "AS IS" BASIS,
      13             :  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      14             :  * See the License for the specific language governing permissions and
      15             :  * limitations under the License.
      16             :  */
      17             : 
      18             : #ifndef IROHA_PROTO_ACCOUNT_ASSET_HPP
      19             : #define IROHA_PROTO_ACCOUNT_ASSET_HPP
      20             : 
      21             : #include "backend/protobuf/common_objects/trivial_proto.hpp"
      22             : #include "backend/protobuf/util.hpp"
      23             : #include "interfaces/common_objects/account_asset.hpp"
      24             : #include "qry_responses.pb.h"
      25             : #include "utils/lazy_initializer.hpp"
      26             : 
      27             : namespace shared_model {
      28             :   namespace proto {
      29             :     class AccountAsset final
      30             :         : public CopyableProto<interface::AccountAsset,
      31             :                                iroha::protocol::AccountAsset,
      32             :                                AccountAsset> {
      33             :      public:
      34             :       template <typename AccountAssetType>
      35             :       explicit AccountAsset(AccountAssetType &&accountAssetType)
      36         122 :           : CopyableProto(std::forward<AccountAssetType>(accountAssetType)) {}
      37             : 
      38             :       AccountAsset(const AccountAsset &o) : AccountAsset(o.proto_) {}
      39             : 
      40             :       AccountAsset(AccountAsset &&o) noexcept
      41             :           : AccountAsset(std::move(o.proto_)) {}
      42             : 
      43             :       const interface::types::AccountIdType &accountId() const override {
      44         102 :         return proto_->account_id();
      45             :       }
      46             : 
      47             :       const interface::types::AssetIdType &assetId() const override {
      48         152 :         return proto_->asset_id();
      49             :       }
      50             : 
      51             :       const interface::Amount &balance() const override {
      52         123 :         return *balance_;
      53             :       }
      54             : 
      55             :      private:
      56             :       template <typename T>
      57             :       using Lazy = detail::LazyInitializer<T>;
      58             : 
      59         122 :       const Lazy<interface::Amount> balance_{
      60             :           [this] { return interface::Amount(proto_->balance()); }};
      61             :     };
      62             :   }  // namespace proto
      63             : }  // namespace shared_model
      64             : 
      65             : #endif  // IROHA_PROTO_ACCOUNT_ASSET_HPP

Generated by: LCOV version 1.13