ProcessorBase.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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. #include "HandlerModule.h"
  8. namespace mdd {
  9. class ProcessorBase : public IProcessor{
  10. private:
  11. std::string _prefix;
  12. std::string _type;
  13. int _appendix;
  14. std::vector<std::shared_ptr<Input>> _processor_inputs;
  15. std::vector<std::shared_ptr<Output>> _processor_outputs;
  16. std::vector<HandlerModule<IInput>> _module_inputs;
  17. std::vector<HandlerModule<IOutput>> _module_outputs;
  18. std::vector<std::shared_ptr<IModule>> _modules;
  19. protected:
  20. int addProcesorInput(const std::string& type, const json& value,
  21. const std::function<bool(const json&)>& verification = [](
  22. const json&) { return true; });
  23. int addProcessorOutput(const std::string& type, const json& initial);
  24. std::shared_ptr<IOutput> getProcessorOutput(int handle);
  25. std::shared_ptr<IInput> getProcessorInput(int handle);
  26. std::shared_ptr<IModule> getModule(int handle);
  27. public:
  28. std::string getID() override ;
  29. std::string setType(std:: string type) override;
  30. std::string getType() override;
  31. std::string setPrefix(std::string prefix) override;
  32. std::string setAppendix(int appendix) override;
  33. void updateID() override ;
  34. std::string addModule(std::shared_ptr<IModule> module) override ;
  35. std::string addModuleInput(std::string module_ID, std::string input_ID);
  36. std::string addModuleInput(std::shared_ptr<IModule> module, std::shared_ptr<IInput> input);
  37. std::string addModuleOutput(std::string module_ID, std::string output_ID);
  38. std::string addModuleOutput(std::shared_ptr<IModule> module, std::shared_ptr<IOutput> output);
  39. std::vector<std::string> getInputs() override;
  40. std::vector<std::string> getOutputs() override;
  41. std::vector<std::string> getModules() override;
  42. std::vector<std::string> getInputIDs();
  43. std::vector<std::string> getOutputIDs();
  44. std::vector<std::string> getModuleIDs();
  45. std::shared_ptr<IOutput> getOutput(std::string output_id) override;
  46. std::shared_ptr<IInput> getInput(std::string input_id) override;
  47. std::shared_ptr<IModule> getModule(std::string module_id) override;
  48. };
  49. }
  50. #endif