Parameter.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include "Parameter.h"
  2. namespace mdd {
  3. Parameter::Parameter()
  4. : ModuleBase(R"JSON(
  5. [{
  6. "name":"appendix",
  7. "value":0
  8. }])JSON")
  9. {
  10. inputs.push_back(std::make_shared<Input>("Value", 0));
  11. outputs.push_back(std::make_shared<Output>("Value", 0));
  12. key = "Parameter";
  13. setName(key);
  14. }
  15. state Parameter::update() {
  16. return getOutput(0)->setValue(getInput(0)->getValue());
  17. }
  18. std::string Parameter::setName(const std::string& name) {
  19. //inputs[0]->setName(name);
  20. outputs[0]->setName(name);
  21. return name;
  22. }
  23. std::string Parameter::setAppendix(int appendix)
  24. {
  25. inputs[0]->setAppendix(appendix);
  26. outputs[0]->setAppendix(appendix);
  27. return ModuleBase::setAppendix(appendix);
  28. }
  29. bool Parameter::configureChild(const json& config)
  30. {
  31. auto jit = config.find("name");
  32. if (jit != config.end())
  33. {
  34. if (jit.value().get<std::string>() == "appendix")
  35. {
  36. setAppendix(jit.value()["value"].get<int>());
  37. _base_config["configure"]["appendix"]["value"] = getAppendix();
  38. }
  39. }
  40. return false;
  41. }
  42. }