LCOV - code coverage report
Current view: top level - shared_model/interfaces/iroha_internal - batch_meta.hpp (source / functions) Hit Total Coverage
Test: coverage_cleared.info Lines: 8 9 88.9 %
Date: 2018-12-05 17:11:35 Functions: 5 7 71.4 %

          Line data    Source code
       1             : /**
       2             :  * Copyright Soramitsu Co., Ltd. All Rights Reserved.
       3             :  * SPDX-License-Identifier: Apache-2.0
       4             :  */
       5             : 
       6             : #ifndef IROHA_SHARED_MODEL_BATCH_META_HPP
       7             : #define IROHA_SHARED_MODEL_BATCH_META_HPP
       8             : 
       9             : #include "interfaces/base/model_primitive.hpp"
      10             : #include "interfaces/common_objects/types.hpp"
      11             : 
      12             : namespace shared_model {
      13             :   namespace interface {
      14             : 
      15             :     /**
      16             :      * Representation of fixed point number
      17             :      */
      18             :     class BatchMeta : public ModelPrimitive<BatchMeta> {
      19             :      public:
      20             :       virtual types::BatchType type() const = 0;
      21             : 
      22             :       std::string toString() const override {
      23         118 :         return detail::PrettyStringBuilder()
      24         118 :             .init("BatchMeta")
      25         118 :             .append("Type",
      26         118 :                     type() == types::BatchType::ATOMIC ? "ATOMIC" : "ORDERED")
      27         118 :             .appendAll(reducedHashes(),
      28             :                        [](auto &hash) { return hash.toString(); })
      29         118 :             .finalize();
      30           0 :       }
      31             :       /// type of hashes collection
      32             :       using ReducedHashesType = std::vector<interface::types::HashType>;
      33             : 
      34             :       /**
      35             :        * @return Hashes of transactions to fetch
      36             :        */
      37             :       virtual const ReducedHashesType &reducedHashes() const = 0;
      38             :       /**
      39             :        * Checks equality of objects inside
      40             :        * @param rhs - other wrapped value
      41             :        * @return true, if wrapped objects are same
      42             :        */
      43             :       bool operator==(const ModelType &rhs) const override {
      44          19 :         return boost::equal(reducedHashes(), rhs.reducedHashes())
      45          19 :             and type() == rhs.type();
      46             :       }
      47             :     };
      48             :   }  // namespace interface
      49             : }  // namespace shared_model
      50             : #endif  // IROHA_SHARED_MODEL_BATCH_META_HPP

Generated by: LCOV version 1.13