Files
Jungfraujoch/frame_serialize/CBORStream2Deserializer.h
2025-07-16 20:19:48 +02:00

48 lines
1.5 KiB
C++

// SPDX-FileCopyrightText: 2024 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#ifndef JUNGFRAUJOCH_CBORSTREAM2DESERIALIZER_H
#define JUNGFRAUJOCH_CBORSTREAM2DESERIALIZER_H
#include <cstdint>
#include <vector>
#include <string>
#include <memory>
#include "../common/SpotToSave.h"
#include "tinycbor/cbor.h"
#include "../common/JFJochMessages.h"
#include <mutex>
struct CBORStream2DeserializerOutput {
CBORImageType msg_type = CBORImageType::NONE;
std::optional<DataMessage> data_message;
std::optional<StartMessage> start_message;
std::optional<EndMessage> end_message;
std::optional<CompressedImage> calibration;
std::optional<MetadataMessage> metadata;
CBORStream2DeserializerOutput() = default;
explicit CBORStream2DeserializerOutput(const StartMessage& msg) {
msg_type = CBORImageType::START;
start_message = msg;
}
explicit CBORStream2DeserializerOutput(const EndMessage& msg) {
msg_type = CBORImageType::END;
end_message = msg;
}
explicit CBORStream2DeserializerOutput(const DataMessage& msg) {
msg_type = CBORImageType::IMAGE;
data_message = msg;
}
};
std::shared_ptr<CBORStream2DeserializerOutput> CBORStream2Deserialize(const uint8_t *msg, size_t msg_size);
std::shared_ptr<CBORStream2DeserializerOutput> CBORStream2Deserialize(const std::vector<uint8_t>& msg);
std::shared_ptr<CBORStream2DeserializerOutput> CBORStream2Deserialize(const std::string& msg);
#endif //JUNGFRAUJOCH_CBORSTREAM2DESERIALIZER_H