#pragma once

#include "AbstractVisualNode.h"

#include <unordered_map>

class QuantumCircuit;
class QuantumCircuitElement;
class AbstractQuantumWire;

class QuantumTerminalNode;
class QuantumGateNode;
class QuantumWireNode;
class QuantumCircuitElementNode;

class QuantumCircuitNode : public AbstractVisualNode
{
public:
	QuantumCircuitNode(const Transform& t = {});

	void setContent(QuantumCircuit* circuit);

	void update(SceneInfo* sceneInfo);
private:
	void createOrUpdateGeometry(SceneInfo* sceneInfo);

	void buildWireConnections();

	bool mContentDirty{ true };
	QuantumCircuit* mContent{ nullptr };

	std::vector<std::unique_ptr<QuantumTerminalNode> > mInputTerminalNodes;
	std::vector<std::unique_ptr<QuantumTerminalNode> > mOutputTerminalNodes;
	std::vector<std::unique_ptr<QuantumGateNode> > mGateNodes;
	std::vector<std::unique_ptr<QuantumWireNode> > mWireNodes;

	std::unordered_map<AbstractQuantumWire*, QuantumCircuitElement*> mWireInputConnections;
	std::unordered_map<AbstractQuantumWire*, QuantumCircuitElement*> mWireOutputConnections;

	std::unordered_map<QuantumCircuitElement*, QuantumCircuitElementNode*> mNodesForContent;
};