Scorum
version.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <fc/string.hpp>
4 #include <fc/time.hpp>
5 
6 namespace scorum {
7 namespace protocol {
8 
9 /*
10  * This class represents the basic versioning scheme of the Scorum blockchain.
11  * All versions are a triple consisting of a major version, hardfork version, and release version.
12  * It allows easy comparison between versions. A version is a read only object.
13  */
14 struct version
15 {
17  {
18  }
19  version(uint8_t m, uint8_t h, uint16_t r);
20  virtual ~version()
21  {
22  }
23 
24  bool operator==(const version& o) const
25  {
26  return v_num == o.v_num;
27  }
28  bool operator!=(const version& o) const
29  {
30  return v_num != o.v_num;
31  }
32  bool operator<(const version& o) const
33  {
34  return v_num < o.v_num;
35  }
36  bool operator<=(const version& o) const
37  {
38  return v_num <= o.v_num;
39  }
40  bool operator>(const version& o) const
41  {
42  return v_num > o.v_num;
43  }
44  bool operator>=(const version& o) const
45  {
46  return v_num >= o.v_num;
47  }
48 
49  operator fc::string() const;
50 
51  uint32_t v_num = 0;
52 };
53 
55 {
57  : version()
58  {
59  }
60  hardfork_version(uint8_t m, uint8_t h)
61  : version(m, h, 0)
62  {
63  }
65  {
66  v_num = v.v_num & 0xFFFF0000;
67  }
69  {
70  }
71 
72  void operator=(const version& o)
73  {
74  v_num = o.v_num & 0xFFFF0000;
75  }
76  void operator=(const hardfork_version& o)
77  {
78  v_num = o.v_num & 0xFFFF0000;
79  }
80 
81  bool operator==(const hardfork_version& o) const
82  {
83  return v_num == o.v_num;
84  }
85  bool operator!=(const hardfork_version& o) const
86  {
87  return v_num != o.v_num;
88  }
89  bool operator<(const hardfork_version& o) const
90  {
91  return v_num < o.v_num;
92  }
93  bool operator<=(const hardfork_version& o) const
94  {
95  return v_num <= o.v_num;
96  }
97  bool operator>(const hardfork_version& o) const
98  {
99  return v_num > o.v_num;
100  }
101  bool operator>=(const hardfork_version& o) const
102  {
103  return v_num >= o.v_num;
104  }
105 
106  bool operator==(const version& o) const
107  {
108  return v_num == (o.v_num & 0xFFFF0000);
109  }
110  bool operator!=(const version& o) const
111  {
112  return v_num != (o.v_num & 0xFFFF0000);
113  }
114  bool operator<(const version& o) const
115  {
116  return v_num < (o.v_num & 0xFFFF0000);
117  }
118  bool operator<=(const version& o) const
119  {
120  return v_num <= (o.v_num & 0xFFFF0000);
121  }
122  bool operator>(const version& o) const
123  {
124  return v_num > (o.v_num & 0xFFFF0000);
125  }
126  bool operator>=(const version& o) const
127  {
128  return v_num >= (o.v_num & 0xFFFF0000);
129  }
130 };
131 
133 {
135  {
136  }
137  hardfork_version_vote(hardfork_version v, fc::time_point_sec t)
138  : hf_version(v)
139  , hf_time(t)
140  {
141  }
142 
144  fc::time_point_sec hf_time;
145 };
146 }
147 } // scorum::protocol
148 
149 namespace fc {
150 class variant;
151 void to_variant(const scorum::protocol::version& v, variant& var);
152 void from_variant(const variant& var, scorum::protocol::version& v);
153 
154 void to_variant(const scorum::protocol::hardfork_version& hv, variant& var);
155 void from_variant(const variant& var, scorum::protocol::hardfork_version& hv);
156 } // fc
157 
158 #include <fc/reflect/reflect.hpp>
160 FC_REFLECT_DERIVED(scorum::protocol::hardfork_version, (scorum::protocol::version), BOOST_PP_SEQ_NIL)
161 
FC_REFLECT(appender_args,(appender)(stream)) FC_REFLECT_DERIVED(file_appender_args
Definition: game.cpp:4
void to_variant(const game_type &game, fc::variant &var)
Definition: game.cpp:8
void from_variant(const fc::variant &var, game_type &game)
Definition: game.cpp:12
Definition: asset.cpp:15
hardfork_version_vote(hardfork_version v, fc::time_point_sec t)
Definition: version.hpp:137
bool operator>=(const version &o) const
Definition: version.hpp:126
bool operator<(const version &o) const
Definition: version.hpp:114
void operator=(const version &o)
Definition: version.hpp:72
bool operator==(const version &o) const
Definition: version.hpp:106
hardfork_version(uint8_t m, uint8_t h)
Definition: version.hpp:60
bool operator<=(const hardfork_version &o) const
Definition: version.hpp:93
bool operator>(const version &o) const
Definition: version.hpp:122
bool operator>=(const hardfork_version &o) const
Definition: version.hpp:101
bool operator<(const hardfork_version &o) const
Definition: version.hpp:89
bool operator==(const hardfork_version &o) const
Definition: version.hpp:81
bool operator!=(const version &o) const
Definition: version.hpp:110
void operator=(const hardfork_version &o)
Definition: version.hpp:76
bool operator>(const hardfork_version &o) const
Definition: version.hpp:97
bool operator!=(const hardfork_version &o) const
Definition: version.hpp:85
bool operator<=(const version &o) const
Definition: version.hpp:118
bool operator<(const version &o) const
Definition: version.hpp:32
bool operator!=(const version &o) const
Definition: version.hpp:28
bool operator==(const version &o) const
Definition: version.hpp:24
bool operator<=(const version &o) const
Definition: version.hpp:36
bool operator>=(const version &o) const
Definition: version.hpp:44
bool operator>(const version &o) const
Definition: version.hpp:40