LCOV - code coverage report
Current view: top level - shared_model/interfaces/common_objects - account_asset.hpp (source / functions) Hit Total Coverage
Test: coverage_cleared.info Lines: 2 9 22.2 %
Date: 2018-12-05 17:11:35 Functions: 3 6 50.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_SHARED_MODEL_ACCOUNT_ASSET_HPP
      19             : #define IROHA_SHARED_MODEL_ACCOUNT_ASSET_HPP
      20             : 
      21             : #include "interfaces/base/model_primitive.hpp"
      22             : #include "interfaces/common_objects/amount.hpp"
      23             : #include "interfaces/common_objects/types.hpp"
      24             : #include "utils/string_builder.hpp"
      25             : 
      26             : namespace shared_model {
      27             :   namespace interface {
      28             : 
      29             :     /**
      30             :      * Representation of wallet in system
      31             :      */
      32             :     class AccountAsset : public ModelPrimitive<AccountAsset> {
      33             :      public:
      34             :       /**
      35             :        * @return Identity of user, for fetching data
      36             :        */
      37             :       virtual const types::AccountIdType &accountId() const = 0;
      38             : 
      39             :       /**
      40             :        * @return Identity of asset, for fetching data
      41             :        */
      42             :       virtual const types::AssetIdType &assetId() const = 0;
      43             : 
      44             :       /**
      45             :        * @return Current balance
      46             :        */
      47             :       virtual const Amount &balance() const = 0;
      48             : 
      49             :       /**
      50             :        * Stringify the data.
      51             :        * @return the content of account asset.
      52             :        */
      53             :       std::string toString() const override {
      54           0 :         return detail::PrettyStringBuilder()
      55           0 :             .init("AccountAsset")
      56           0 :             .append("accountId", accountId())
      57           0 :             .append("assetId", assetId())
      58           0 :             .append("balance", balance().toString())
      59           0 :             .finalize();
      60           0 :       }
      61             : 
      62             :       /**
      63             :        * Checks equality of objects inside
      64             :        * @param rhs - other wrapped value
      65             :        * @return true, if wrapped objects are same
      66             :        */
      67             :       bool operator==(const ModelType &rhs) const override {
      68          18 :         return accountId() == rhs.accountId() and assetId() == rhs.assetId()
      69          18 :             and balance() == rhs.balance();
      70             :       }
      71             :     };
      72             :   }  // namespace interface
      73             : }  // namespace shared_model
      74             : #endif  // IROHA_SHARED_MODEL_ACCOUNT_ASSET_HPP

Generated by: LCOV version 1.13