#ifndef SH_DATABASE_STRUCTS_H
#define SH_DATABASE_STRUCTS_H

#include <QDebug>
#include <QImage>
#include "SH_types.h"

#define ID(n) PIMETA(id=n)

const int currentDatabaseVersion = 1;


struct TableRow PIMETA(no-stream) {
	int id = 0;
	QString name;
	QString description;
};


struct BusType {
	ID( 1) int id = 0;
	ID( 2) QString name;
	ID( 3) QString description;
	ID( 4) QString plugin;

	ID( 5) PropertyStorage properties;
	ID( 6) QStringList io_classes;
	ID( 7) double width = 2.;
	ID( 8) int endpoints = 1;
	ID( 9) int devices = 0;
	ID(10) bool addresses = false;
	ID(11) QColor color = Qt::black;
	ID(12) QImage image_bus;
	ID(13) QImage image_end;
	ID(14) double image_bus_scale = 1.;
	ID(15) double image_endpoint_scale = 1.;
};


struct BlockType {
	ID( 1) int id = 0;
	ID( 2) QString name;
	ID( 3) QString description;
	ID( 4) int vendor_id = 0;
	ID( 5) QString vendor_name;
	ID( 6) QString vendor_description;
	ID( 7) int group_id = 0;
	ID( 8) QString group_name;
	ID( 9) QString group_description;

	ID(10) QString block_plugin;
	ID(11) QString script_plugin;
	ID(12) QString gateway_plugin;
	ID(13) QString packet_plugin;

	ID(14) PropertyStorage properties;
	ID(15) QMap<QString, PropertyStorage> pins_properties;
	ID(16) SHS::Object object;
	ID(17) uint flags = 0;

	ID(18) double width = 120;
	ID(19) double height = 160.;
	ID(20) double pins_spacing = 20.;
	ID(21) QColor color = Qt::lightGray;
	ID(22) QByteArray model;

	ID(-) QVariantMap display_data;

	void prepare();
};


struct DatabaseInfo {
	ID(1) int version = 0;
	bool isCurrent() const {return version == currentDatabaseVersion;}
};


#undef ID

#endif
