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_MODEL_PRIMITIVE_HPP
7 : #define IROHA_MODEL_PRIMITIVE_HPP
8 :
9 : #include <ciso646>
10 :
11 : #include "utils/string_builder.hpp"
12 : #include "common/cloneable.hpp"
13 :
14 : namespace shared_model {
15 : namespace interface {
16 : /**
17 : * ModelPrimitive is a base class of whole domain objects in system.
18 : * This class required for guarantee consistent interface on all shared
19 : * model objects.
20 : * @tparam Model - your new style model
21 : */
22 : template <typename Model>
23 : class ModelPrimitive : public Cloneable<ModelPrimitive<Model>> {
24 : public:
25 : /**
26 : * Reference for model type.
27 : */
28 : using ModelType = Model;
29 :
30 : /**
31 : * Make string developer representation of object
32 : * @return string with internal state of object
33 : */
34 : virtual std::string toString() const {
35 0 : return detail::PrettyStringBuilder()
36 0 : .init("Primitive")
37 0 : .append("address", std::to_string(reinterpret_cast<uint64_t>(this)))
38 0 : .finalize();
39 0 : }
40 :
41 : virtual bool operator==(const ModelType &rhs) const = 0;
42 :
43 : virtual bool operator!=(const ModelType &rhs) const {
44 55 : return not(*this == rhs);
45 : }
46 :
47 : virtual ~ModelPrimitive() = default;
48 : };
49 : } // namespace interface
50 : } // namespace shared_model
51 : #endif // IROHA_MODEL_PRIMITIVE_HPP
|