NanoTekSpice
DigitalElectronics
IComponent.hpp
1 /*
2 ** EPITECH PROJECT, 2019
3 ** OOP_NanoTekSpice
4 ** File description:
5 ** IComponent header
6 */
7 
8 #ifndef ICOMPONENT_HPP_
9  #define ICOMPONENT_HPP_
10 
11 #include "Type.hpp"
12 #include "Setting.hpp"
13 #include <cstddef>
14 #include <memory>
15 
16 namespace nts
17 {
18  class IComponent
19  {
20  public:
21  virtual ~IComponent() = default;
22 
23  public:
24  virtual void createAllComponents(const std::vector<Component::ComponentSetting> &settings) = 0;
25 
26  virtual nts::Tristate compute(std::size_t pin = 1) = 0;
27  virtual void setLink(std::size_t pin , nts::IComponent &other, std::size_t otherPin) = 0;
28  virtual void dump() const noexcept = 0;
29  virtual void displayState(std::size_t pin) const noexcept = 0;
30 
31  virtual void setInput(std::size_t pin, nts::IComponent &other, std::size_t otherPin) = 0;
32  virtual void setOutput(std::size_t pin, nts::IComponent &other, std::size_t otherPin) = 0;
33 
34  virtual void setState(const std::string &name, const std::string &state) = 0;
35  virtual void setState(const std::string &state) = 0;
36 
37  virtual void setName(const std::string &name) noexcept = 0;
38  virtual const std::string &getName() const noexcept = 0;
39 
40  virtual const Type &getType() const noexcept = 0;
41  }; // !IComponent
42 
43  using ptrIComponent_t = std::unique_ptr<nts::IComponent>;
44 
45  struct Pin {
46  size_t pin;
47  nts::Tristate state;
48  nts::IComponent *destinationName;
49  int destinationPin;
50  };
51 
52  struct Door {
53  nts::Pin input1;
54  nts::Pin input2;
55  nts::Pin output;
56  };
57 
58  struct FFDoor {
59  nts::Pin clock;
60  nts::Pin data;
61  nts::Pin set;
62  nts::Pin reset;
63  nts::Pin out;
64  nts::Pin nout;
65  };
66 } // !nts
67 
68 #endif /* !ICOMPONENT_HPP_ */
Definition: IComponent.hpp:45
Definition: IComponent.hpp:16
Definition: IComponent.hpp:18
Definition: IComponent.hpp:52
Definition: IComponent.hpp:58