Files
scheincommander/lightproject.h
T

79 lines
1.6 KiB
C++
Raw Normal View History

2023-02-15 01:12:19 +01:00
#pragma once
#include <vector>
2023-02-15 21:54:26 +01:00
#include <algorithm>
2023-02-15 01:12:19 +01:00
#include <QString>
#include <QVector3D>
2023-02-15 21:54:26 +01:00
#include <QMetaEnum>
#include <QMetaType>
namespace hilfe {
Q_NAMESPACE
2023-02-15 22:45:18 +01:00
enum class DeviceTypeRegisterType
2023-02-15 21:54:26 +01:00
{
Dummy,
Dimmer,
Red,
Green,
Blue,
White,
Strobo,
Shutter
};
2023-02-15 22:45:18 +01:00
Q_ENUM_NS(DeviceTypeRegisterType)
2023-02-15 21:54:26 +01:00
} // namespace hilfe
2023-02-15 22:45:18 +01:00
Q_DECLARE_METATYPE(hilfe::DeviceTypeRegisterType)
2023-02-15 21:54:26 +01:00
2023-02-15 22:45:18 +01:00
using DeviceTypeRegisterType = hilfe::DeviceTypeRegisterType;
2023-02-15 21:54:26 +01:00
2023-02-15 22:45:18 +01:00
struct DeviceTypeRegisterConfig
2023-02-15 21:54:26 +01:00
{
2023-02-15 22:45:18 +01:00
DeviceTypeRegisterType type;
2023-02-15 21:54:26 +01:00
};
2023-02-15 01:12:19 +01:00
2023-02-15 22:45:18 +01:00
struct DeviceTypeConfig
2023-02-15 01:12:19 +01:00
{
int id;
QString name;
2023-02-15 22:45:18 +01:00
std::vector<DeviceTypeRegisterConfig> registers;
2023-02-15 21:54:26 +01:00
};
2023-02-15 22:45:18 +01:00
class DeviceTypesContainer : public std::vector<DeviceTypeConfig>
2023-02-15 21:54:26 +01:00
{
2023-02-15 22:45:18 +01:00
using base_t = std::vector<DeviceTypeConfig>;
2023-02-15 21:54:26 +01:00
public:
using base_t::base_t;
2023-02-15 22:45:18 +01:00
DeviceTypeConfig *findById(int id)
2023-02-15 21:54:26 +01:00
{
auto iter = std::find_if(std::begin(*this), std::end(*this),
2023-02-15 22:45:18 +01:00
[&id](const DeviceTypeConfig &deviceType){ return deviceType.id == id; });
2023-02-15 21:54:26 +01:00
return iter != std::end(*this) ? &*iter : nullptr;
}
2023-02-15 22:45:18 +01:00
const DeviceTypeConfig *findById(int id) const
2023-02-15 21:54:26 +01:00
{
auto iter = std::find_if(std::begin(*this), std::end(*this),
2023-02-15 22:45:18 +01:00
[&id](const DeviceTypeConfig &deviceType){ return deviceType.id == id; });
2023-02-15 21:54:26 +01:00
return iter != std::end(*this) ? &*iter : nullptr;
}
2023-02-15 01:12:19 +01:00
};
struct LightConfig
{
int id;
QString name;
2023-02-15 22:45:18 +01:00
int deviceTypeId;
2023-02-15 01:12:19 +01:00
int address;
QVector3D position;
};
struct LightProject
{
2023-02-15 22:45:18 +01:00
DeviceTypesContainer deviceTypes;
std::vector<LightConfig> devices;
2023-02-15 01:12:19 +01:00
};