ProcessorBase.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #pragma once
  2. #include <list>
  3. #include "Input.h"
  4. #include "Output.h"
  5. #include "IProcessor.h"
  6. #include "Registration.h"
  7. namespace mdd {
  8. class Registration;
  9. class ProcessorBase
  10. : public IProcessor
  11. {
  12. private:
  13. std::weak_ptr<IModule> _parent;
  14. int _appendix = 0;
  15. unsigned int module_counter = 0;
  16. protected:
  17. json _base_config;
  18. ProcessorBase(const std::string& base_config);
  19. const std::string type = "processor";
  20. std::string key;
  21. std::vector<std::shared_ptr<Input>>processor_inputs;
  22. std::vector<std::shared_ptr<Output>> processor_outputs;
  23. std::vector<std::shared_ptr<IModule>> modules;
  24. std::vector<std::shared_ptr<Parameter>> inputs;
  25. std::vector<std::shared_ptr<Parameter>> outputs;
  26. bool configureChild(const json& config) override;
  27. public:
  28. bool configure(const json& config) override;
  29. const json& getConfiguration() override;
  30. void setParent(std::shared_ptr<IModule> parent) override;
  31. std::vector<std::string> getParentID() override;
  32. std::string getGeneratorKey() override;
  33. std::string getType() override;
  34. std::string setAppendix(int appendix) override;
  35. int getAppendix() override;
  36. std::string getID() override;
  37. std::string addModule(std::shared_ptr<IModule> module) override ;
  38. void removeModule(std::shared_ptr<IModule> module) override;
  39. std::vector<std::shared_ptr<Parameter>>& getInputParams() override;
  40. std::vector<std::shared_ptr<Parameter>>& getOutputParams() override;
  41. size_t getNumInputs() override;
  42. size_t getNumOutputs() override;
  43. std::shared_ptr<IInput> getInput(const json& jid) override;
  44. std::shared_ptr<IInput> getInput(size_t index) override;
  45. std::shared_ptr<IOutput> getOutput(const json& jid) override;
  46. std::shared_ptr<IOutput> getOutput(size_t index) override;
  47. std::vector<std::shared_ptr<IInput>> getOptimizableInputs() override;
  48. std::vector<std::shared_ptr<IOutput>> getOptimizableOutputs() override;
  49. std::vector<std::shared_ptr<IModule >>& getModules();
  50. size_t getNumModuls() override;
  51. std::shared_ptr<IModule> getModule(size_t index) override;
  52. std::shared_ptr<IModule> getModule(const json& jid) override;
  53. bool connect(const std::string& output_id, const std::vector<std::string>& input_ids);
  54. void disconnect() override;
  55. void load(const json& j) override;
  56. json dump() override;
  57. json getIdentifier() override;
  58. state update() override { return state::UNCHANGED; };
  59. };
  60. }
  61. //*/