9#include <spdlog/spdlog.h>
28 : QObject(parent), m_file_serializer_manager(std::move(file_serializer_manager)) {
29 if (!m_file_serializer_manager) {
30 spdlog::error(
"SerializerController: Constructor received a null FileSerializerManager.");
31 throw std::invalid_argument(
"SerializerController: FileSerializerManager cannot be null.");
33 spdlog::debug(
"SerializerController: Constructed with FileSerializerManager.");
40 spdlog::debug(
"SerializerController: Destroyed.");
53 if (!m_file_serializer_manager)
55 spdlog::error(
"SerializerController::saveOperations: FileSerializerManager is null.");
60 if (image_path.isEmpty())
62 spdlog::error(
"SerializerController::saveOperations: Image path is empty.");
67 spdlog::debug(
"SerializerController::saveOperations: Attempting to save {} operations for image: {}", operations.size(), image_path.toStdString());
69 bool success = m_file_serializer_manager->
saveToFile(image_path.toStdString(), operations);
72 spdlog::info(
"SerializerController::saveOperations: Successfully saved operations for image: {}", image_path.toStdString());
75 spdlog::error(
"SerializerController::saveOperations: Failed to save operations for image: {}", image_path.toStdString());
90 if (!m_file_serializer_manager)
92 spdlog::error(
"SerializerController::loadOperations: FileSerializerManager is null.");
97 if (image_path.isEmpty())
99 spdlog::error(
"SerializerController::loadOperations: Image path is empty.");
104 spdlog::debug(
"SerializerController::loadOperations: Attempting to load operations for image: {}", image_path.toStdString());
105 std::vector<CaptureMoment::Core::Operations::OperationDescriptor> loaded_ops = m_file_serializer_manager->
loadFromFile(image_path.toStdString());
107 if (loaded_ops.empty())
109 spdlog::info(
"SerializerController::loadOperations: No operations loaded from file for image: {} (file might not exist or be empty)", image_path.toStdString());
114 spdlog::info(
"SerializerController::loadOperations: Successfully loaded {} operations from file for image: {}", loaded_ops.size(), image_path.toStdString());
std::vector< Operations::OperationDescriptor > loadFromFile(std::string_view source_image_path) const
Loads a list of operations from a file associated with the source image path.
bool saveToFile(std::string_view source_image_path, std::span< const Operations::OperationDescriptor > operations) const
Saves the provided list of operations to a file associated with the source image path.
~SerializerController() override
Destructor.
void saveOperations(const QString &image_path, const std::vector< CaptureMoment::Core::Operations::OperationDescriptor > &operations)
Saves the provided list of operations to a file associated with the given image path.
SerializerController(std::unique_ptr< CaptureMoment::Core::Serializer::FileSerializerManager > file_serializer_manager, QObject *parent=nullptr)
Constructs a UISerializerManager.
void operationsSaved()
Signal emitted when operations are successfully saved to a file.
void operationsSaveFailed(const QString &error_msg)
Signal emitted when the operation to save operations fails.
void operationsLoadFailed(const QString &error_msg)
Signal emitted when the operation to load operations fails.
void operationsNotFoundOnLoad()
Signal emitted when no operations were found in the file during load.
void operationsLoaded(const std::vector< CaptureMoment::Core::Operations::OperationDescriptor > &operations)
Signal emitted when operations are successfully loaded from a file.
void loadOperations(const QString &image_path)
Loads a list of operations from a file associated with the given image path.
UI manager for handling file-based serialization and deserialization of image operations.