From 704931753972c8fe3385fa0fae54bb9a6bf802e3 Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Tue, 17 Feb 2026 11:38:15 +0300 Subject: [PATCH] ... --- include/mcc/mcc_generic_mount.h | 75 ++++++++++++++++++++++++++++++--- 1 file changed, 69 insertions(+), 6 deletions(-) diff --git a/include/mcc/mcc_generic_mount.h b/include/mcc/mcc_generic_mount.h index a4db41e..3e5c922 100644 --- a/include/mcc/mcc_generic_mount.h +++ b/include/mcc/mcc_generic_mount.h @@ -14,6 +14,7 @@ #include +#include "mcc/mcc_spdlog.h" #include "mcc_error.h" namespace mcc::impl @@ -33,8 +34,6 @@ enum class MccGenericMountErrorCode : int { ERROR_TARGET_IN_ZONE }; -enum class MccGenericFsmMountErrorCode : int { ERROR_OK, ERROR_INVALID_OPERATION, ERROR_UNKNOWN_EVENT }; - } // namespace mcc::impl @@ -70,7 +69,7 @@ struct MccGenericMountCategory : public std::error_category { case MccGenericMountErrorCode::ERROR_OK: return "OK"; case MccGenericMountErrorCode::ERROR_HW_INIT: - return "an error occured while initializing mount"; + return "an error occured while initializing mount hardware"; case MccGenericMountErrorCode::ERROR_HW_STOP: return "an error occured while stopping mount"; case MccGenericMountErrorCode::ERROR_HW_GETSTATE: @@ -113,7 +112,7 @@ template + mcc_logger_c LOGGER_T = utils::MccSpdlogLogger> class MccGenericMount : protected HARDWARE_T, public TELEMETRY_T, public PZONE_CONT_T, @@ -160,9 +159,33 @@ public: MOVE_CNTRL_T(std::make_from_tuple(move_cntrl_ctor_ars)), LOGGER_T(std::make_from_tuple(logger_ctor_args)) { - logDebug(std::format("Create MccGenericMount class instance (thread: {})", std::this_thread::get_id())); + // logDebug(std::format("Create MccGenericMount class instance (thread: {})", std::this_thread::get_id())); + logDebug("Create MccGenericMount class instance (thread: {})", std::this_thread::get_id()); } + template + requires std::derived_from + MccGenericMount(std::tuple hw_ctor_args, + std::tuple telemetry_ctor_args, + std::tuple pzone_cont_ctor_ars, + std::tuple move_cntrl_ctor_ars, + LoggerCtorTs... logger_ctor_args) + : HARDWARE_T(std::make_from_tuple(std::move(hw_ctor_args))), + TELEMETRY_T(std::make_from_tuple(std::move(telemetry_ctor_args))), + PZONE_CONT_T(std::make_from_tuple(pzone_cont_ctor_ars)), + MOVE_CNTRL_T(std::make_from_tuple(move_cntrl_ctor_ars)), + mcc::utils::MccSpdlogLogger(logger_ctor_args...) + { + // logDebug(std::format("Create MccGenericMount class instance (thread: {})", std::this_thread::get_id())); + logDebug("Create MccGenericMount class instance (thread: {})", std::this_thread::get_id()); + } + + /* movable-only class */ + MccGenericMount(const MccGenericMount&) = delete; MccGenericMount(MccGenericMount&&) = default; @@ -171,7 +194,8 @@ public: virtual ~MccGenericMount() { - logDebug(std::format("Delete MccGenericMount class instance (thread: {})", std::this_thread::get_id())); + // logDebug(std::format("Delete MccGenericMount class instance (thread: {})", std::this_thread::get_id())); + logDebug("Delete MccGenericMount class instance (thread: {})", std::this_thread::get_id()); auto err = MOVE_CNTRL_T::stopMount(); if (err) { @@ -211,6 +235,45 @@ public: return _lastMountError->load(); } + + /* log-method wrappers for non-MccSpdlogger classes */ + + template ... ArgTs> + requires(!std::derived_from) + void logInfo(std::format_string fmt, ArgTs&&... args) + { + LOGGER_T::logInfo(std::format(fmt, std::forward(args)...)); + } + + template ... ArgTs> + requires(!std::derived_from) + void logDebug(std::format_string fmt, ArgTs&&... args) + { + LOGGER_T::logDebug(std::format(fmt, std::forward(args)...)); + } + + template ... ArgTs> + requires(!std::derived_from) + void logError(std::format_string fmt, ArgTs&&... args) + { + LOGGER_T::logError(std::format(fmt, std::forward(args)...)); + } + + template ... ArgTs> + requires(!std::derived_from) + void logWarn(std::format_string fmt, ArgTs&&... args) + { + LOGGER_T::logWarn(std::format(fmt, std::forward(args)...)); + } + + template ... ArgTs> + requires(!std::derived_from) + void logTrace(std::format_string fmt, ArgTs&&... args) + { + LOGGER_T::logTrace(std::format(fmt, std::forward(args)...)); + } + + protected: std::unique_ptr> _mountStatus{ new std::atomic{mount_status_t::MOUNT_STATUS_UNINITIALIZED}};