#pragma once #include "DeviceCommandInfo.h" struct LaunchedCommandInfo { std::string Name; QByteArray Data; bool IsValid(const DeviceCommandInfo& commandInfo) { if (commandInfo.Name.compare(Name) != 0) return false; switch (commandInfo.Data.SourceType) { case DeviceCommandTypes::ESourceType::FIXED: if (Data.size() > 0) { return false; } break; case DeviceCommandTypes::ESourceType::DYNAMIC: if ((commandInfo.Data.Width >= 0) && (Data.size() != commandInfo.Data.Width)) { return false; } if ((commandInfo.Data.Options.size() > 0) && !OptionsContains(commandInfo.Data.Options, Data)) { return false; } break; } return true; } private: bool OptionsContains(const QList& options, const QByteArray& data) { for (auto it = options.begin(); it != options.end(); it++) { if (IsEquals(*it, data)) { return true; } } return false; } bool IsEquals(const QByteArray& a, const QByteArray& b) { if (a.size() != b.size()) return false; for (int i = 0; i < a.size(); i++) { if (a[i] != b[i]) { return false; } } return true; } };