12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- #include "Input.h"
- namespace mdd{
- Input::Input(const std::string& type, int appendix, const json& default_value,
- const std::function<bool(const json&)>& verification) {
- _type = type;
- _value = default_value;
- _verification = std::move(verification);
- _prefix = "";
- _appendix = appendix;
- }
- std::string Input::setType(std::string type){
- _type = type;
- return getID();
- }
- std::string Input::getType(){
- return _type;
- }
- std::string Input::getID(){
- return _prefix + "/" + _type + std::to_string(_appendix);
- }
- std::string Input::setPrefix(std::string prefix){
- _prefix = prefix;
- return getID();
- }
- std::string Input::setAppendix(int appendix){
- _appendix = appendix;
- return getID();
- }
- const json& Input::getValue() {
- return _value;
- }
- json& Input::setDefaultValue(){
- return _value;
- }
- bool Input::verify(const json & data){
- return _verification(data);
- }
- bool Input::connect(std::shared_ptr<IOutput> output){
- if (verify(output->getValue())) {
- _output = output;
- return true;
- }
- }
- }
|