ModuleBase.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #pragma once
  2. #include "Input.h"
  3. #include "Output.h"
  4. #include "IModule.h"
  5. namespace mdd {
  6. class ModuleBase : public IModule{
  7. private:
  8. int _appendix = 0;
  9. protected:
  10. std::weak_ptr<IModule> _parent;
  11. json _base_config;
  12. ModuleBase(const std::string& base_config = "{}");
  13. const std::string type = "module";
  14. std::string key;
  15. std::vector<std::shared_ptr<Input>> inputs;
  16. std::vector<std::shared_ptr<Output>> outputs;
  17. bool configureChild(const json& config) override { return true; };
  18. public:
  19. bool configure(const json& config) override;
  20. const json& getConfiguration() override;
  21. size_t getNumInputs() override;
  22. size_t getNumOutputs() override;
  23. std::shared_ptr<IInput> getInput(size_t index) override;
  24. std::shared_ptr<IInput> getInput(const json& jid) override;
  25. std::shared_ptr<IOutput> getOutput(size_t index) override;
  26. std::shared_ptr<IOutput> getOutput(const json& jid) override;
  27. std::vector<std::shared_ptr<IInput>> getOptimizableInputs() override;
  28. std::vector<std::shared_ptr<IOutput>> getOptimizableOutputs() override;
  29. void setParent(std::shared_ptr<IModule> parent) override;
  30. std::vector<std::string> getParentID() override;
  31. std::string getGeneratorKey() override;
  32. std::string getType() override;
  33. std::string setAppendix(int appendix) override;
  34. int getAppendix() override;
  35. std::string getID() override;
  36. void load(const json& j) override;
  37. json dump() override;
  38. json getIdentifier() override;
  39. void disconnect() override;
  40. };
  41. }