Skip to content

Commit

Permalink
Improve const awareness
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Emmers <[email protected]>
  • Loading branch information
marcemmers committed Nov 21, 2024
1 parent 94123cd commit 915864c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
8 changes: 4 additions & 4 deletions include/ocpp/v201/charge_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,13 @@ class ChargePointInterface {
/// present. This returns the value from the cached network connection profiles. \param
/// network_configuration_priority \return
virtual std::optional<NetworkConnectionProfile>
get_network_connection_profile(const int32_t configuration_slot) = 0;
get_network_connection_profile(const int32_t configuration_slot) const = 0;

/// \brief Get the priority of the given configuration slot.
/// \param configuration_slot The configuration slot to get the priority from.
/// \return The priority if the configuration slot exists.
///
virtual std::optional<int> get_priority_from_configuration_slot(const int configuration_slot) = 0;
virtual std::optional<int> get_priority_from_configuration_slot(const int configuration_slot) const = 0;

/// @brief Get the network connection slots sorted by priority.
/// Each item in the vector contains the configured configuration slots, where the slot with index 0 has the highest
Expand Down Expand Up @@ -940,9 +940,9 @@ class ChargePoint : public ChargePointInterface, private ocpp::ChargingStationBa
std::vector<CompositeSchedule> get_all_composite_schedules(const int32_t duration,
const ChargingRateUnitEnum& unit) override;

std::optional<NetworkConnectionProfile> get_network_connection_profile(const int32_t configuration_slot) override;
std::optional<NetworkConnectionProfile> get_network_connection_profile(const int32_t configuration_slot) const override;

std::optional<int> get_priority_from_configuration_slot(const int configuration_slot) override;
std::optional<int> get_priority_from_configuration_slot(const int configuration_slot) const override;

const std::vector<int>& get_network_connection_slots() const override;

Expand Down
6 changes: 3 additions & 3 deletions include/ocpp/v201/connectivity_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ class ConnectivityManager {
/// \brief Gets the cached NetworkConnectionProfile based on the given \p configuration_slot.
/// This returns the value from the cached network connection profiles.
/// \return Returns a profile if the slot is found
std::optional<NetworkConnectionProfile> get_network_connection_profile(const int32_t configuration_slot);
std::optional<NetworkConnectionProfile> get_network_connection_profile(const int32_t configuration_slot) const;

/// \brief Get the priority of the given configuration slot.
/// \param configuration_slot The configuration slot to get the priority from.
/// \return The priority if the configuration slot exists.
///
std::optional<int32_t> get_priority_from_configuration_slot(const int configuration_slot);
std::optional<int32_t> get_priority_from_configuration_slot(const int configuration_slot) const;

/// @brief Get the network connection slots sorted by priority.
/// Each item in the vector contains the configured configuration slots, where the slot with index 0 has the highest
Expand Down Expand Up @@ -174,7 +174,7 @@ class ConnectivityManager {
/// \brief Get the active network configuration slot in use.
/// \return The active slot the network is connected to or the pending slot.
///
int get_active_network_configuration_slot();
int get_active_network_configuration_slot() const;

///
/// \brief Get the network configuration slot of the given priority.
Expand Down
4 changes: 2 additions & 2 deletions lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4453,11 +4453,11 @@ std::vector<CompositeSchedule> ChargePoint::get_all_composite_schedules(const in
return composite_schedules;
}

std::optional<NetworkConnectionProfile> ChargePoint::get_network_connection_profile(const int32_t configuration_slot) {
std::optional<NetworkConnectionProfile> ChargePoint::get_network_connection_profile(const int32_t configuration_slot) const {
return this->connectivity_manager->get_network_connection_profile(configuration_slot);
}

std::optional<int> ChargePoint::get_priority_from_configuration_slot(const int configuration_slot) {
std::optional<int> ChargePoint::get_priority_from_configuration_slot(const int configuration_slot) const {
return this->connectivity_manager->get_priority_from_configuration_slot(configuration_slot);
}

Expand Down
6 changes: 3 additions & 3 deletions lib/ocpp/v201/connectivity_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void ConnectivityManager::set_configure_network_connection_profile_callback(
}

std::optional<NetworkConnectionProfile>
ConnectivityManager::get_network_connection_profile(const int32_t configuration_slot) {
ConnectivityManager::get_network_connection_profile(const int32_t configuration_slot) const {

for (const auto& network_profile : this->cached_network_connection_profiles) {
if (network_profile.configurationSlot == configuration_slot) {
Expand All @@ -88,7 +88,7 @@ ConnectivityManager::get_network_connection_profile(const int32_t configuration_
return std::nullopt;
}

std::optional<int32_t> ConnectivityManager::get_priority_from_configuration_slot(const int configuration_slot) {
std::optional<int32_t> ConnectivityManager::get_priority_from_configuration_slot(const int configuration_slot) const {
auto it =
std::find(this->network_connection_slots.begin(), this->network_connection_slots.end(), configuration_slot);
if (it != this->network_connection_slots.end()) {
Expand All @@ -98,7 +98,7 @@ std::optional<int32_t> ConnectivityManager::get_priority_from_configuration_slot
return std::nullopt;
}

int ConnectivityManager::get_active_network_configuration_slot() {
int ConnectivityManager::get_active_network_configuration_slot() const {
return this->network_connection_slots.at(this->active_network_configuration_priority);
}

Expand Down

0 comments on commit 915864c

Please sign in to comment.