ModuleBase.h 1.9 KB

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