ProcessorBase.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef MDD_PROCESSORBASE_H
  2. #define MDD_PROCESSORBASE_H
  3. #include <list>
  4. #include "Input.h"
  5. #include "Output.h"
  6. #include "IProcessor.h"
  7. namespace mdd {
  8. class ProcessorBase : public IProcessor{
  9. private:
  10. template<class T>
  11. class HandlerModule {
  12. public:
  13. std::shared_ptr<IModule> moduleHandler;
  14. std::shared_ptr<T> accessHandler;
  15. HandlerModule(std::shared_ptr<IModule> module, std::shared_ptr<T> access) {
  16. moduleHandler = module;
  17. accessHandler = access;
  18. }
  19. };
  20. std::string _prefix;
  21. std::string _type;
  22. int _appendix;
  23. std::vector<std::shared_ptr<Input>> _processor_inputs;
  24. std::vector<std::shared_ptr<Output>> _processor_outputs;
  25. std::vector<HandlerModule<IInput>> _module_inputs;
  26. std::vector<HandlerModule<IOutput>> _module_outputs;
  27. std::vector<std::shared_ptr<IModule>> _modules;
  28. protected:
  29. int addProcesorInput(const std::string& type, const std::vector<double>& value);
  30. int addProcessorOutput(const std::string& type, const std::vector<double>& initial);
  31. std::shared_ptr<IOutput> getProcessorOutput(int handle);
  32. std::shared_ptr<IInput> getProcessorInput(int handle);
  33. std::shared_ptr<IModule> getModule(int handle);
  34. public:
  35. std::string getID() override ;
  36. std::string setType(std:: string type) override;
  37. std::string getType() override;
  38. std::string setPrefix(std::string prefix) override;
  39. std::string setAppendix(int appendix) override;
  40. void updateID() override ;
  41. std::string addModule(std::shared_ptr<IModule> module) override ;
  42. void removeModule(std::shared_ptr<IModule> module) override;
  43. std::string addModuleInput(std::string module_ID, std::string input_ID);
  44. std::string addModuleInput(std::shared_ptr<IModule> module, std::shared_ptr<IInput> input);
  45. std::string addModuleOutput(std::string module_ID, std::string output_ID);
  46. std::string addModuleOutput(std::shared_ptr<IModule> module, std::shared_ptr<IOutput> output);
  47. std::vector<std::string> getInputs() override;
  48. std::vector<std::string> getOutputs() override;
  49. std::vector<std::string> getModules() override;
  50. std::vector<std::string> getInputIDs() override;
  51. std::vector<std::string> getOutputIDs() override;
  52. std::vector<std::string> getModuleIDs() override;
  53. std::vector<state> getInputStates() override;
  54. std::vector<state> getOutputStates() override;
  55. std::vector<std::shared_ptr<IOutput>> getInputConnections() override;
  56. std::vector <std::vector <std::shared_ptr<IInput>>> getOutputConnections() override;
  57. std::vector <std::shared_ptr<IInput>> getOptimizableInputs() override;
  58. std::vector <std::shared_ptr<IOutput>> getOptimizableOutputs() override;
  59. std::shared_ptr<IOutput> getOutput(std::string output_id) override;
  60. std::shared_ptr<IInput> getInput(std::string input_id) override;
  61. std::shared_ptr<IModule> getModule(std::string module_id) override;
  62. };
  63. }
  64. #endif