#pragma once #include #include #include #include "IComplexCommandCreator.h" #include "ComplexCommandCreateMultidata.h" #include "TypesIndexSeparator.h" #include "VariadicTypesContainerSwapper.h" namespace Incart::Usb { template class ComplexMultidataCommandCreator final : public IComplexCommandCreator { private: using DataParts = Common::TwoPartsTypesSeparator; using DynamicTypesTuple = typename DataParts::firstPartType; using ConstTypesTuple = typename DataParts::secondPartType; using CommandDataType = typename Common::VariadicTypesContainerSwapper>::destType; ConstTypesTuple m_constantData; public: template ComplexMultidataCommandCreator(TConstantData... args_) : m_constantData(std::forward(args_)...) { } std::shared_ptr create(std::shared_ptr data_) override { std::shared_ptr commandData = std::dynamic_pointer_cast(data_); auto dynamicData = commandData->data; auto constantData = m_constantData; std::tuple catTuple = std::tuple_cat(dynamicData, std::move(constantData)); return createCommand(catTuple, std::index_sequence_for{}); } private: template std::shared_ptr createCommand(std::tuple data_, std::index_sequence) { return std::make_shared(std::get(data_)...); } }; } // namespace Incart::Usb