
#include "signals.hpp"
#include "parts.hpp"

Signal::Signal(std::string name) : SystemElementContainer<Pin>(name), prnt(nullptr) {};

void Signal::add(Pin *pin)
{
    string pname = pin->prnt->name + "." + pin->name;
    SystemElementContainer<Pin>::add(pname, pin);
}

Signals::Signals(void): SystemElementContainer<Signal>("signals") {}

Signals::Signals(std::vector<Signal *> signals): SystemElementContainer<Signal>("signals", signals) {}

Signals::~Signals() {
    for (const auto& [key, value] : content) {
        delete value;
    }
}

void Signals::add(Signal *signal)
{
    SystemElementContainer<Signal>::add(signal);
    signal->prnt = this;
}