Skip to content

Commit 2e4e3dd

Browse files
committed
cm: cloudprotocol: update state messages
Signed-off-by: Oleksandr Grytsov <[email protected]>
1 parent 801cfde commit 2e4e3dd

File tree

1 file changed

+26
-29
lines changed

1 file changed

+26
-29
lines changed

src/core/cm/cloudprotocol/state.hpp

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,28 @@ namespace aos::cloudprotocol {
1919
static constexpr auto cStateReason = cErrorMessageLen;
2020

2121
/**
22-
* State acceptance.
22+
* New state.
2323
*/
24-
struct StateAcceptance {
25-
InstanceIdent mInstanceIdent;
24+
struct NewState : public InstanceIdent {
2625
StaticString<crypto::cSHA2DigestSize> mChecksum;
27-
StateResult mResult;
28-
StaticString<cStateReason> mReason;
26+
StaticString<cStateLen> mState;
2927

3028
/**
31-
* Compares state acceptance.
29+
* Compares new state.
3230
*
33-
* @param acceptance state acceptance to compare with.
31+
* @param state new state to compare with.
3432
* @return bool.
3533
*/
36-
bool operator==(const StateAcceptance& acceptance) const
34+
bool operator==(const NewState& state) const
3735
{
38-
return mInstanceIdent == acceptance.mInstanceIdent && mChecksum == acceptance.mChecksum
39-
&& mResult == acceptance.mResult && mReason == acceptance.mReason;
36+
return InstanceIdent::operator==(state) && mChecksum == state.mChecksum && mState == state.mState;
4037
}
41-
42-
/**
43-
* Compares state acceptance.
44-
*
45-
* @param acceptance state acceptance to compare with.
46-
* @return bool.
47-
*/
48-
bool operator!=(const StateAcceptance& acceptance) const { return !operator==(acceptance); }
4938
};
5039

5140
/**
5241
* Update state.
5342
*/
54-
struct UpdateState {
55-
InstanceIdent mInstanceIdent;
43+
struct UpdateState : public InstanceIdent {
5644
StaticString<crypto::cSHA2DigestSize> mChecksum;
5745
StaticString<cStateLen> mState;
5846

@@ -64,7 +52,7 @@ struct UpdateState {
6452
*/
6553
bool operator==(const UpdateState& state) const
6654
{
67-
return mInstanceIdent == state.mInstanceIdent && mChecksum == state.mChecksum && mState == state.mState;
55+
return InstanceIdent::operator==(state) && mChecksum == state.mChecksum && mState == state.mState;
6856
}
6957

7058
/**
@@ -77,23 +65,32 @@ struct UpdateState {
7765
};
7866

7967
/**
80-
* New state.
68+
* State acceptance.
8169
*/
82-
struct NewState {
83-
InstanceIdent mInstanceIdent;
70+
struct StateAcceptance : public InstanceIdent {
8471
StaticString<crypto::cSHA2DigestSize> mChecksum;
85-
StaticString<cStateLen> mState;
72+
StateResult mResult;
73+
StaticString<cStateReason> mReason;
8674

8775
/**
88-
* Compares new state.
76+
* Compares state acceptance.
8977
*
90-
* @param state new state to compare with.
78+
* @param acceptance state acceptance to compare with.
9179
* @return bool.
9280
*/
93-
bool operator==(const NewState& state) const
81+
bool operator==(const StateAcceptance& acceptance) const
9482
{
95-
return mInstanceIdent == state.mInstanceIdent && mChecksum == state.mChecksum && mState == state.mState;
83+
return InstanceIdent::operator==(acceptance) && mChecksum == acceptance.mChecksum
84+
&& mResult == acceptance.mResult && mReason == acceptance.mReason;
9685
}
86+
87+
/**
88+
* Compares state acceptance.
89+
*
90+
* @param acceptance state acceptance to compare with.
91+
* @return bool.
92+
*/
93+
bool operator!=(const StateAcceptance& acceptance) const { return !operator==(acceptance); }
9794
};
9895

9996
/**

0 commit comments

Comments
 (0)