#ifndef SHDesignerAPI_h
#define SHDesignerAPI_h

#include <QObject>
#include "database_structs.h"

class SHDesignerCore;


class SHDesignerAPI: public QObject {
	friend class SHDesignerCore;
	Q_OBJECT
public:
	explicit SHDesignerAPI();
	virtual ~SHDesignerAPI();

	const PIMap<int, BlockType> & blockTypes() const {return block_types;};
	const PIMap<int, BlockItem * > & sourceBlocks() const {return src_blocks;};
	const PIMap<int, BusType> & busTypes() const {return bus_types;};

	const QList<BlockItem * > sceneBlocks();

	BlockItem * addBlock(int id, QPoint pos);
	BlockBusItem * connectPins(int id, BlockItemPin * p0, BlockItemPin * p1);

	void prepareBlock(BlockItem * block);

private:
	PIMap<int, BusType> bus_types;
	PIMap<int, BlockType> block_types;
	PIMap<int, BlockItem * > src_blocks;
	PIMap<int, TableRow> table_vendors, table_groups;

signals:
	void newBlockRequest(int block_id, QPoint pos, BlockItem ** ret);
	void prepareBlockRequest(BlockItem * block);
	void connectBlocksRequest(int bus_id, QPoint p0, QPoint p1, BlockBusItem ** ret);
	void sceneBlocksRequest(QList<BlockItem *> * ret);

};


#endif
