epitech-mirroring / NanoTekSpice

Simulate electronic circuits and components
0 stars 1 forks source link

♻️ Refactor the creation of the components #41

Closed Thomaltarix closed 8 months ago

Thomaltarix commented 8 months ago

👮‍♂️ What's needed

To respect the subject, we need to refactor the creation of the components. At the moment, we are using this function:

IComponent *ComponentFactory::createComponent(const std::string &name)
{
    return _components[name]->clone();
}

For the exemple of the Input component, that's it:

InputComponent *InputComponent::clone() const {
    return new InputComponent();
}

But in the subject, it's said that we have to use unique pointers:

image

So we might swap to unique pointers.

🧪 Given test cases

We need to handle this lines. image