Output.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #ifndef MDD_OUTPUT_H
  2. #define MDD_OUTPUT_H
  3. #include "IOutput.h"
  4. #include "IModule.h"
  5. namespace mdd {
  6. class Output
  7. : public IOutput
  8. , public std::enable_shared_from_this<Output>
  9. {
  10. private:
  11. state _state;
  12. std::vector<double> _value;
  13. std::string _name;
  14. int _appendix;
  15. std::vector<std::weak_ptr<IInput>> _connections;
  16. bool _optimizable;
  17. std::weak_ptr<IModule> _parent;
  18. protected:
  19. json _base_config;
  20. std::string type;
  21. std::string key;
  22. bool configureChild(const json& config) override { return true; };
  23. public:
  24. Output(const std::string& name, int appendix, const std::vector<double>& initial = std::vector<double>({ 1 }));
  25. const std::vector<double>& getValue() override;
  26. std::vector<double>& setValue() override;
  27. state setValue(const std::vector<double>& val) override;
  28. bool isOptimizable();
  29. void setOptimizability(bool state);
  30. state getState() override;
  31. void resetState() override;
  32. std::string getType() override;
  33. std::string getGeneratorKey() override;
  34. std::string setName(const std::string& name) override;
  35. std::string getName() override;
  36. std::string setAppendix(int appendix) override;
  37. int getAppendix() override;
  38. std::string getID() override;
  39. void setParent(IModule::Ptr parent) override;
  40. std::vector<std::string> getParentID() override;
  41. int addConnection(std::shared_ptr<IInput> input) override;
  42. int removeConnection(std::shared_ptr<IInput> input) override;
  43. bool connect(std::shared_ptr<IInput> input) override;
  44. std::vector<std::shared_ptr<IInput>> getConnections() override;
  45. void disconnect() override;
  46. bool configure(const json& config) override;
  47. const json& getConfiguration() override;
  48. void load(const json& j) override;
  49. json dump() override;
  50. json getIdentifier() override;
  51. };
  52. }
  53. #endif