ocpp 0.24.1
A C++ implementation of the Open Charge Point Protocol
comparators.hpp
1// SPDX-License-Identifier: Apache-2.0
2// Copyright 2020 - 2024 Pionix GmbH and Contributors to EVerest
3
4#pragma once
5
6#include <ocpp/v2/ocpp_types.hpp>
7
8namespace ocpp {
9namespace v2 {
10
11inline bool operator==(const EVSE& lhs, const EVSE& rhs) {
12 return lhs.id == rhs.id and lhs.connectorId == rhs.connectorId;
13};
14
15inline bool operator<(const EVSE& lhs, const EVSE& rhs) {
16 if (lhs.id != rhs.id) {
17 return lhs.id < rhs.id;
18 }
19 return lhs.connectorId < rhs.connectorId;
20}
21
22inline bool operator==(const Component& lhs, const Component& rhs) {
23 return lhs.name.get() == rhs.name.get() and lhs.instance == rhs.instance and lhs.evse == rhs.evse;
24};
25
26inline bool operator<(const Component& lhs, const Component& rhs) {
27 if (lhs.name != rhs.name) {
28 return lhs.name < rhs.name;
29 }
30 if (lhs.instance != rhs.instance) {
31 return lhs.instance < rhs.instance;
32 }
33 return lhs.evse < rhs.evse;
34};
35
36inline bool operator==(const Variable& lhs, const Variable& rhs) {
37 return lhs.name.get() == rhs.name.get() and lhs.instance == rhs.instance;
38};
39
40inline bool operator<(const Variable& lhs, const Variable& rhs) {
41 if (lhs.name != rhs.name) {
42 return lhs.name < rhs.name;
43 }
44 return lhs.instance < rhs.instance;
45};
46
47inline bool operator==(const ComponentVariable& lhs, const ComponentVariable& rhs) {
48 return lhs.component == rhs.component and lhs.variable == rhs.variable;
49}
50
51inline bool operator<(const ComponentVariable& lhs, const ComponentVariable& rhs) {
52 if (lhs.component == rhs.component) {
53 return lhs.variable < rhs.variable;
54 }
55 return lhs.component < rhs.component;
56}
57
58inline bool operator==(const SetVariableData& lhs, const SetVariableData& rhs) {
59 return lhs.component == rhs.component and lhs.variable == rhs.variable and
60 lhs.attributeValue.get() == rhs.attributeValue.get() and lhs.attributeType == rhs.attributeType;
61}
62
63inline bool operator<(const SetVariableData& lhs, const SetVariableData& rhs) {
64 if (lhs.component == rhs.component) {
65 return lhs.variable < rhs.variable;
66 }
67 return lhs.component < rhs.component;
68}
69
70} // namespace v2
71} // namespace ocpp