#pragma once

#include "data/node.h"

namespace Xybrid::Gadgets {
    class IOPort : public Data::Node {
        bool portSet = false;
        Data::Port::Type type;
        Data::Port::DataType dataType;
        uint8_t index;

        void remove();
        void add();
    public:
        IOPort();
        ~IOPort() override = default;

        void setPort(Data::Port::Type type, Data::Port::DataType dataType, uint8_t index);

        void onRename() override;

        void saveData(QCborMap&) override;
        void loadData(QCborMap&) override;

        void onUnparent(std::shared_ptr<Data::Graph>) override;
        void onParent(std::shared_ptr<Data::Graph>) override;

        void onGadgetCreated() override;

        void drawCustomChrome(QPainter*, const QStyleOptionGraphicsItem*) override;
    };
}
