Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add forward declarations and move includes to cpp files #987

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 23 additions & 40 deletions include/ocpp/v201/charge_point.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,64 +8,47 @@
#include <set>

#include <ocpp/common/message_dispatcher.hpp>
#include <ocpp/v201/functional_blocks/authorization.hpp>
#include <ocpp/v201/functional_blocks/availability.hpp>
#include <ocpp/v201/functional_blocks/data_transfer.hpp>
#include <ocpp/v201/functional_blocks/diagnostics.hpp>
#include <ocpp/v201/functional_blocks/display_message.hpp>
#include <ocpp/v201/functional_blocks/firmware_update.hpp>
#include <ocpp/v201/functional_blocks/meter_values.hpp>
#include <ocpp/v201/functional_blocks/provisioning.hpp>
#include <ocpp/v201/functional_blocks/remote_transaction_control.hpp>
#include <ocpp/v201/functional_blocks/reservation.hpp>
#include <ocpp/v201/functional_blocks/security.hpp>
#include <ocpp/v201/functional_blocks/smart_charging.hpp>
#include <ocpp/v201/functional_blocks/tariff_and_cost.hpp>
#include <ocpp/v201/functional_blocks/transaction.hpp>

#include <ocpp/common/charging_station_base.hpp>

#include <ocpp/v201/average_meter_values.hpp>
#include <ocpp/v201/charge_point_callbacks.hpp>
#include <ocpp/v201/ctrlr_component_variables.hpp>
#include <ocpp/v201/database_handler.hpp>
#include <ocpp/v201/device_model.hpp>
#include <ocpp/v201/device_model_storage_interface.hpp>
#include <ocpp/v201/evse_manager.hpp>
#include <ocpp/v201/monitoring_updater.hpp>
#include <ocpp/v201/ocpp_enums.hpp>
#include <ocpp/v201/ocpp_types.hpp>
#include <ocpp/v201/ocsp_updater.hpp>
#include <ocpp/v201/types.hpp>
#include <ocpp/v201/utils.hpp>

#include <ocpp/v201/messages/Authorize.hpp>
#include <ocpp/v201/messages/BootNotification.hpp>
#include <ocpp/v201/messages/ClearVariableMonitoring.hpp>
#include <ocpp/v201/messages/CustomerInformation.hpp>
#include <ocpp/v201/messages/DataTransfer.hpp>
#include <ocpp/v201/messages/Get15118EVCertificate.hpp>
#include <ocpp/v201/messages/GetBaseReport.hpp>
#include <ocpp/v201/messages/GetLog.hpp>
#include <ocpp/v201/messages/GetMonitoringReport.hpp>
#include <ocpp/v201/messages/GetReport.hpp>
#include <ocpp/v201/messages/GetVariables.hpp>
#include <ocpp/v201/messages/NotifyCustomerInformation.hpp>
#include <ocpp/v201/messages/NotifyEvent.hpp>
#include <ocpp/v201/messages/NotifyMonitoringReport.hpp>
#include <ocpp/v201/messages/NotifyReport.hpp>
#include <ocpp/v201/messages/Reset.hpp>
#include <ocpp/v201/messages/SetMonitoringBase.hpp>
#include <ocpp/v201/messages/SetMonitoringLevel.hpp>
#include <ocpp/v201/messages/SetNetworkProfile.hpp>
#include <ocpp/v201/messages/SetVariableMonitoring.hpp>
#include <ocpp/v201/messages/SetVariables.hpp>
#include <ocpp/v201/messages/GetCompositeSchedule.hpp>

#include "component_state_manager.hpp"

namespace ocpp {
namespace v201 {

class AuthorizationInterface;
class AvailabilityInterface;
class DataTransferInterface;
class DiagnosticsInterface;
class DisplayMessageInterface;
class FirmwareUpdateInterface;
class MeterValuesInterface;
class ProvisioningInterface;
class RemoteTransactionControlInterface;
class ReservationInterface;
class SecurityInterface;
class SmartChargingInterface;
class TariffAndCostInterface;
class TransactionInterface;

class DatabaseHandler;
class DeviceModel;
class DeviceModelStorageInterface;
class EvseManager;

class UnexpectedMessageTypeFromCSMS : public std::runtime_error {
using std::runtime_error::runtime_error;
};
Expand Down Expand Up @@ -358,11 +341,11 @@ class ChargePoint : public ChargePointInterface, private ocpp::ChargingStationBa
std::unique_ptr<DisplayMessageInterface> display_message;
std::unique_ptr<FirmwareUpdateInterface> firmware_update;
std::unique_ptr<MeterValuesInterface> meter_values;
std::unique_ptr<SmartCharging> smart_charging;
std::unique_ptr<SmartChargingInterface> smart_charging;
std::unique_ptr<TariffAndCostInterface> tariff_and_cost;
std::unique_ptr<TransactionInterface> transaction;
std::unique_ptr<ProvisioningInterface> provisioning;
std::unique_ptr<RemoteTransactionControl> remote_transaction_control;
std::unique_ptr<RemoteTransactionControlInterface> remote_transaction_control;

// utility
std::shared_ptr<MessageQueue<v201::MessageType>> message_queue;
Expand Down
13 changes: 7 additions & 6 deletions include/ocpp/v201/functional_blocks/authorization.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@

#pragma once

#include <ocpp/v201/messages/Authorize.hpp>
#include <ocpp/v201/messages/ClearCache.hpp>
#include <ocpp/v201/messages/GetLocalListVersion.hpp>
#include <ocpp/v201/messages/SendLocalList.hpp>

#include <ocpp/v201/database_handler.hpp>
#include <ocpp/v201/message_dispatcher.hpp>
#include <ocpp/v201/message_handler.hpp>

namespace ocpp::v201 {
struct AuthorizationCacheEntry;
struct AuthorizeResponse;
struct ClearCacheRequest;
struct SendLocalListRequest;
struct GetLocalListVersionRequest;

class AuthorizationInterface : public MessageHandlerInterface {
public:
virtual ~AuthorizationInterface() {
Expand Down Expand Up @@ -45,7 +46,7 @@ class Authorization : public AuthorizationInterface {
MessageDispatcherInterface<MessageType>& message_dispatcher;
DeviceModel& device_model;
ConnectivityManagerInterface& connectivity_manager;
ocpp::v201::DatabaseHandlerInterface& database_handler;
DatabaseHandlerInterface& database_handler;
EvseSecurity& evse_security;

// threads and synchronization
Expand Down
4 changes: 2 additions & 2 deletions include/ocpp/v201/functional_blocks/availability.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
#include <ocpp/v201/message_handler.hpp>

#include <ocpp/v201/messages/ChangeAvailability.hpp>
#include <ocpp/v201/messages/Heartbeat.hpp>

namespace ocpp::v201 {

class DeviceModel;
class EvseManagerInterface;
class ComponentStateManagerInterface;

struct HeartbeatResponse;

/// \brief Combines ChangeAvailabilityRequest with persist flag for scheduled Availability changes
struct AvailabilityChange {
ChangeAvailabilityRequest request;
Expand Down
3 changes: 2 additions & 1 deletion include/ocpp/v201/functional_blocks/data_transfer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

#include <ocpp/v201/message_dispatcher.hpp>
#include <ocpp/v201/message_handler.hpp>
#include <ocpp/v201/messages/DataTransfer.hpp>

namespace ocpp {
namespace v201 {
struct DataTransferRequest;
struct DataTransferResponse;

class DataTransferInterface : public MessageHandlerInterface {

Expand Down
10 changes: 6 additions & 4 deletions include/ocpp/v201/functional_blocks/display_message.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@

#pragma once

#include <ocpp/v201/evse_manager.hpp>
#include <ocpp/v201/message_dispatcher.hpp>
#include <ocpp/v201/message_handler.hpp>
#include <ocpp/v201/messages/ClearDisplayMessage.hpp>
#include <ocpp/v201/messages/GetDisplayMessages.hpp>

#include <ocpp/v201/messages/SetDisplayMessage.hpp>

namespace ocpp::v201 {
class EvseManagerInterface;
struct GetDisplayMessagesRequest;
struct ClearDisplayMessageResponse;
struct ClearDisplayMessageRequest;

///
/// \brief Convert message content from OCPP spec to DisplayMessageContent.
Expand Down Expand Up @@ -66,4 +68,4 @@ class DisplayMessageBlock : public DisplayMessageInterface {
void handle_clear_display_message(Call<ClearDisplayMessageRequest> call);
};

} // namespace ocpp::v201
} // namespace ocpp::v201
8 changes: 4 additions & 4 deletions include/ocpp/v201/functional_blocks/firmware_update.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@

#include <ocpp/common/message_dispatcher.hpp>
#include <ocpp/v201/message_handler.hpp>
#include <ocpp/v201/messages/UpdateFirmware.hpp>

namespace ocpp {

// Forward declarations.
class EvseSecurity;

Expand All @@ -20,14 +18,16 @@ class EvseManagerInterface;
class AvailabilityInterface;
class SecurityInterface;

struct UpdateFirmwareRequest;
struct UpdateFirmwareResponse;

// Typedef
typedef std::function<UpdateFirmwareResponse(const UpdateFirmwareRequest& request)> UpdateFirmwareRequestCallback;
typedef std::function<void()> AllConnectorsUnavailableCallback;

class FirmwareUpdateInterface : public MessageHandlerInterface {
public:
virtual ~FirmwareUpdateInterface() {
}
virtual ~FirmwareUpdateInterface() = default;

virtual void on_firmware_update_status_notification(int32_t request_id,
const FirmwareStatusEnum& firmware_update_status) = 0;
Expand Down
7 changes: 3 additions & 4 deletions include/ocpp/v201/functional_blocks/reservation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@

#include <ocpp/v201/message_dispatcher.hpp>
#include <ocpp/v201/message_handler.hpp>
#include <ocpp/v201/messages/CancelReservation.hpp>
#include <ocpp/v201/messages/ReservationStatusUpdate.hpp>
#include <ocpp/v201/messages/ReserveNow.hpp>

#pragma once

namespace ocpp::v201 {

class EvseInterface;
class EvseManagerInterface;

struct ReserveNowRequest;
struct CancelReservationRequest;

typedef std::function<ReserveNowStatusEnum(const ReserveNowRequest& request)> ReserveNowCallback;
typedef std::function<bool(const int32_t reservationId)> CancelReservationCallback;
typedef std::function<ocpp::ReservationCheckStatus(const int32_t evse_id, const CiString<36> idToken,
Expand Down
16 changes: 9 additions & 7 deletions include/ocpp/v201/functional_blocks/security.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@
#include <ocpp/v201/message_handler.hpp>
#include <ocpp/v201/ocsp_updater.hpp>

#include <ocpp/v201/messages/CertificateSigned.hpp>
#include <ocpp/v201/messages/DeleteCertificate.hpp>
#include <ocpp/v201/messages/Get15118EVCertificate.hpp>
#include <ocpp/v201/messages/GetInstalledCertificateIds.hpp>
#include <ocpp/v201/messages/InstallCertificate.hpp>
#include <ocpp/v201/messages/SignCertificate.hpp>

namespace ocpp::v201 {
struct CertificateSignedRequest;
struct CertificateSignedResponse;
struct GetInstalledCertificateIdsRequest;
struct Get15118EVCertificateRequest;
struct Get15118EVCertificateResponse;
struct InstallCertificateRequest;
struct DeleteCertificateRequest;
struct SignCertificateResponse;

typedef std::function<void(const CiString<50>& event_type, const std::optional<CiString<255>>& tech_info)>
SecurityEventCallback;

Expand Down
16 changes: 9 additions & 7 deletions include/ocpp/v201/functional_blocks/smart_charging.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@
#include <ocpp/v201/evse.hpp>
#include <ocpp/v201/message_dispatcher.hpp>

#include <ocpp/v201/messages/ClearChargingProfile.hpp>
#include <ocpp/v201/messages/GetChargingProfiles.hpp>
#include <ocpp/v201/messages/GetCompositeSchedule.hpp>
#include <ocpp/v201/messages/ReportChargingProfiles.hpp>
#include <ocpp/v201/messages/SetChargingProfile.hpp>

namespace ocpp::v201 {

class DeviceModel;
class EvseManagerInterface;
class ConnectivityManagerInterface;
class SmartChargingHandlerInterface;
class EvseInterface;

struct GetChargingProfilesRequest;
struct SetChargingProfileRequest;
struct SetChargingProfileResponse;
struct GetCompositeScheduleResponse;
struct GetCompositeScheduleRequest;
struct ClearChargingProfileResponse;
struct ClearChargingProfileRequest;
struct ReportChargingProfilesRequest;

enum class ProfileValidationResultEnum {
Valid,
EvseDoesNotExist,
Expand Down
4 changes: 2 additions & 2 deletions include/ocpp/v201/functional_blocks/tariff_and_cost.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
#include <ocpp/common/message_dispatcher.hpp>
#include <ocpp/v201/functional_blocks/display_message.hpp>

#include <ocpp/v201/messages/CostUpdated.hpp>

namespace ocpp::v201 {
class DeviceModel;
class EvseManagerInterface;
class MeterValuesInterface;

struct CostUpdatedRequest;

typedef std::function<void(const RunningCost& running_cost, const uint32_t number_of_decimals,
std::optional<std::string> currency_code)>
SetRunningCostCallback;
Expand Down
24 changes: 22 additions & 2 deletions lib/ocpp/v201/charge_point.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Pionix GmbH and Contributors to EVerest

#include <ocpp/v201/charge_point.hpp>

#include <ocpp/common/constants.hpp>
#include <ocpp/common/types.hpp>
#include <ocpp/v201/charge_point.hpp>
#include <ocpp/v201/ctrlr_component_variables.hpp>
#include <ocpp/v201/database_handler.hpp>
#include <ocpp/v201/device_model.hpp>
#include <ocpp/v201/device_model_storage_interface.hpp>
#include <ocpp/v201/device_model_storage_sqlite.hpp>
#include <ocpp/v201/evse_manager.hpp>
#include <ocpp/v201/message_dispatcher.hpp>
#include <ocpp/v201/messages/LogStatusNotification.hpp>
#include <ocpp/v201/notify_report_requests_splitter.hpp>

#include <ocpp/v201/functional_blocks/authorization.hpp>
#include <ocpp/v201/functional_blocks/availability.hpp>
#include <ocpp/v201/functional_blocks/data_transfer.hpp>
#include <ocpp/v201/functional_blocks/diagnostics.hpp>
#include <ocpp/v201/functional_blocks/display_message.hpp>
#include <ocpp/v201/functional_blocks/firmware_update.hpp>
#include <ocpp/v201/functional_blocks/meter_values.hpp>
#include <ocpp/v201/functional_blocks/provisioning.hpp>
#include <ocpp/v201/functional_blocks/remote_transaction_control.hpp>
#include <ocpp/v201/functional_blocks/reservation.hpp>
#include <ocpp/v201/functional_blocks/security.hpp>
#include <ocpp/v201/functional_blocks/smart_charging.hpp>
#include <ocpp/v201/functional_blocks/tariff_and_cost.hpp>
#include <ocpp/v201/functional_blocks/transaction.hpp>

#include <ocpp/v201/messages/LogStatusNotification.hpp>
#include <ocpp/v201/messages/RequestStopTransaction.hpp>
#include <ocpp/v201/messages/TriggerMessage.hpp>

Expand Down
6 changes: 6 additions & 0 deletions lib/ocpp/v201/functional_blocks/authorization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@

#include <ocpp/common/constants.hpp>
#include <ocpp/v201/ctrlr_component_variables.hpp>
#include <ocpp/v201/database_handler.hpp>
#include <ocpp/v201/functional_blocks/authorization.hpp>
#include <ocpp/v201/utils.hpp>

#include <ocpp/v201/messages/Authorize.hpp>
#include <ocpp/v201/messages/ClearCache.hpp>
#include <ocpp/v201/messages/GetLocalListVersion.hpp>
#include <ocpp/v201/messages/SendLocalList.hpp>

///
/// \brief Check if vector of authorization data has a duplicate id token.
/// \param list List to check.
Expand Down
1 change: 1 addition & 0 deletions lib/ocpp/v201/functional_blocks/availability.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <ocpp/v201/device_model.hpp>
#include <ocpp/v201/evse_manager.hpp>

#include <ocpp/v201/messages/Heartbeat.hpp>
#include <ocpp/v201/messages/StatusNotification.hpp>

namespace ocpp::v201 {
Expand Down
5 changes: 3 additions & 2 deletions lib/ocpp/v201/functional_blocks/data_transfer.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright Pionix GmbH and Contributors to EVerest

#include <ocpp/common/constants.hpp>
#include <ocpp/v201/functional_blocks/data_transfer.hpp>

#include <ocpp/common/constants.hpp>
#include <ocpp/v201/messages/DataTransfer.hpp>

namespace ocpp {
namespace v201 {

void DataTransfer::handle_message(const EnhancedMessage<MessageType>& message) {

if (message.messageType != MessageType::DataTransfer) {
throw MessageTypeNotImplementedException(message.messageType);
}
Expand Down
Loading