| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #ifndef MDD_BASEMODULE_H
- #define MDD_BASEMODULE_H
- #include <string>
- #include <functional>
- #include "IModule.h"
- #include "Output.h"
- #include <bits/shared_ptr.h>
- namespace mdd {
- struct Input {
- std::string type;
- json value;
- std::function<bool(const json&)> verification;
- std::shared_ptr<IOutput> output;
- Input(const std::string& type, const json& default_value,
- const std::function<bool(const json&)>& verification = [](
- const json&) { return true; });
- };
- class ModuleBase : public IModule{
- private:
- std::vector<Input> _inputs;
- std::vector<std::shared_ptr<Output>> _outputs;
- public:
- int addInput(const std::string& type, const json& value,
- const std::function<bool(const json&)>& verification = [](
- const json&) { return true; });
- json& setInputDefaultValue(int handle);
- const json& getInputValue(int handle);
- bool connectInput(int handle, std::shared_ptr<IOutput> output) override;
- std::vector<std::string> getInputs() override;
- std::vector<std::string> getOutputs() override;
- std::shared_ptr<IOutput> getOutput(int handle) override;
- int addOutput(const std::string& type, const json& initial);
- json &setOutputValue(int handle);
- };
- }
- #endif //MDD_BASEMODULE_H
|