Input.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #ifndef MDD_INPUT_H
  2. #define MDD_INPUT_H
  3. #include <string>
  4. #include <functional>
  5. #include "IInput.h"
  6. #include "IModule.h"
  7. #include <memory>
  8. #include "IUnique.h"
  9. namespace mdd {
  10. class Input
  11. : public IInput
  12. , public std::enable_shared_from_this<Input>
  13. {
  14. private:
  15. std::string _name;
  16. int _appendix;
  17. std::weak_ptr<IModule> _parent;
  18. std::vector<double> _value;
  19. //std::function<bool(const json &)> _verification;
  20. std::shared_ptr<IOutput> _output;
  21. bool _optimizable;
  22. std::shared_ptr<limits> _limit;
  23. protected:
  24. json _base_config;
  25. std::string type;
  26. std::string key;
  27. bool configureChild(const json& config) override { return true; };
  28. public:
  29. Input(const std::string& name, int appendix, const std::vector<double>& default_value = std::vector<double>({ 1 }));
  30. //const std::function<bool(const json &)> &verification = [](const json&) { return true; }
  31. std::string getType() override;
  32. std::string getGeneratorKey() override;
  33. std::string setName(const std::string& name) override;
  34. std::string getName() override;
  35. std::string setAppendix(int appendix) override;
  36. int getAppendix() override;
  37. std::string getID() override;
  38. void setParent(std::shared_ptr<IModule> parent) override;
  39. std::vector<std::string> getParentID() override;
  40. state getState() override;
  41. void resetState() override;
  42. const std::vector<double>& getValue() override;
  43. std::vector<double>& setValue() override;
  44. state setValue(const std::vector<double>& val) override;
  45. bool isOptimizable() override;
  46. void setOptimizability(bool state) override;
  47. const std::shared_ptr<limits> getLimits() override;
  48. std::shared_ptr<limits>& setLimits() override;
  49. std::shared_ptr<IOutput> getConnection() override;
  50. //bool verify(const json & data) override;
  51. int addConnection(std::shared_ptr<IOutput> output) override;
  52. int removeConnection(std::shared_ptr<IOutput> output = nullptr) override;
  53. bool connect(std::shared_ptr<IOutput> output) override;
  54. void disconnect() override;
  55. bool configure(const json& config) override;
  56. const json& getConfiguration() override;
  57. void load(const json& j) override;
  58. json dump() override;
  59. json getIdentifier() override;
  60. };
  61. }
  62. #endif //MDD_INPUT_H