|
@@ -160,6 +160,47 @@ namespace mdd{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ json ProcessorBase::addInput(std::shared_ptr<IInput> input) {
|
|
|
+ auto param_ptr = std::make_shared<Parameter>();
|
|
|
+ param_ptr->setName(input->getName());
|
|
|
+ param_ptr->getOutput(0)->connect(input);
|
|
|
+ getInputParams().push_back(param_ptr);
|
|
|
+ param_ptr->setKey("Parameter/Input");
|
|
|
+ param_ptr->setAppendix(input_counter++);
|
|
|
+ param_ptr->setParent(shared_from_this());
|
|
|
+ json ret;
|
|
|
+ ret["operation"] = "change";
|
|
|
+ json jargs;
|
|
|
+ jargs["subject"] = getIdentifier();
|
|
|
+ jargs["object"] = dump();
|
|
|
+ ret["args"] = jargs;
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ json ProcessorBase::removeInput(std::shared_ptr<IInput> input) {
|
|
|
+ json ret;
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ json ProcessorBase::addOutput(std::shared_ptr<IOutput> output) {
|
|
|
+ auto param_ptr = std::make_shared<Parameter>();
|
|
|
+ param_ptr->setName(output->getName());
|
|
|
+ param_ptr->getInput(0)->connect(output);
|
|
|
+ getOutputParams().push_back(param_ptr);
|
|
|
+ param_ptr->setKey("Parameter/Output");
|
|
|
+ param_ptr->setAppendix(output_counter++);
|
|
|
+ param_ptr->setParent(shared_from_this());
|
|
|
+ json ret;
|
|
|
+ ret["operation"] = "change";
|
|
|
+ json jargs;
|
|
|
+ jargs["subject"] = getIdentifier();
|
|
|
+ jargs["object"] = dump();
|
|
|
+ ret["args"] = jargs;
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ json ProcessorBase::removeOutput(std::shared_ptr<IOutput> output) {
|
|
|
+ json ret;
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+
|
|
|
std::vector<std::shared_ptr<Parameter>>& ProcessorBase::getInputParams() {
|
|
|
return inputs;
|
|
|
}
|
|
@@ -264,29 +305,33 @@ namespace mdd{
|
|
|
}
|
|
|
|
|
|
void ProcessorBase::load(const json& j) {
|
|
|
- if (j.contains("ID"))
|
|
|
+ auto jit = j.find("ID");
|
|
|
+ if (jit != j.end())
|
|
|
{
|
|
|
- setAppendix(j["ID"]["appendix"].get<int>());
|
|
|
+ setAppendix((*jit)["appendix"].get<int>());
|
|
|
j["ID"]["type"];
|
|
|
|
|
|
}
|
|
|
- if (j.contains("key"))
|
|
|
+ jit = j.find("key");
|
|
|
+ if (jit != j.end())
|
|
|
{
|
|
|
|
|
|
}
|
|
|
- if (j.contains("type"))
|
|
|
+ jit = j.find("type");
|
|
|
+ if (jit != j.end())
|
|
|
{
|
|
|
|
|
|
}
|
|
|
- if (j.contains("configure"))
|
|
|
+ jit = j.find("configure");
|
|
|
+ if (jit != j.end())
|
|
|
{
|
|
|
|
|
|
}
|
|
|
-
|
|
|
- if (j.contains("modules"))
|
|
|
+ jit = j.find("modules");
|
|
|
+ if (jit != j.end())
|
|
|
{
|
|
|
Registration regi = Registration();
|
|
|
- for (json jmodule : j["modules"])
|
|
|
+ for (json jmodule : *jit)
|
|
|
{
|
|
|
if (jmodule["type"].get<std::string>() == "module")
|
|
|
{
|
|
@@ -304,27 +349,37 @@ namespace mdd{
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (j.contains("inputs"))
|
|
|
+ jit = j.find("params");
|
|
|
+ if (jit != j.end())
|
|
|
{
|
|
|
- const size_t start_counter = processor_inputs.size();
|
|
|
- for (size_t i = start_counter; i < j["inputs"].size(); i++)
|
|
|
+ auto jit_params = jit->find("inputs");
|
|
|
+ if (jit_params != jit->end())
|
|
|
{
|
|
|
-
|
|
|
+ const size_t start_counter = processor_outputs.size();
|
|
|
+ for (size_t i = start_counter; i < (*jit_params).size(); i++)
|
|
|
+ {
|
|
|
+ inputs.push_back(std::make_shared<Parameter>());
|
|
|
+ inputs.back()->load((*jit_params)[i]);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- if (j.contains("outputs"))
|
|
|
- {
|
|
|
- const size_t start_counter = processor_outputs.size();
|
|
|
- for (size_t i = start_counter; i < j["outputs"].size(); i++)
|
|
|
+ jit_params = jit->find("outputs");
|
|
|
+ if (jit_params != jit->end())
|
|
|
{
|
|
|
-
|
|
|
+ const size_t start_counter = processor_inputs.size();
|
|
|
+ for (size_t i = start_counter; i < (*jit_params).size(); i++)
|
|
|
+ {
|
|
|
+ outputs.push_back(std::make_shared<Parameter>());
|
|
|
+ outputs.back()->load((*jit_params)[i]);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
|
|
|
- if (j.contains("connections"))
|
|
|
+ jit = j.find("connections");
|
|
|
+ if (jit != j.end())
|
|
|
{
|
|
|
- for(json jcon : j["connections"])
|
|
|
+ for(json jcon : *jit)
|
|
|
{
|
|
|
json jout = jcon["output"];
|
|
|
IModule::Ptr module_out_ptr = getModule(jout);
|
|
@@ -366,6 +421,16 @@ namespace mdd{
|
|
|
{
|
|
|
modules[i]->setAppendix(i);
|
|
|
}
|
|
|
+ for (int i = 0; i < inputs.size(); ++i)
|
|
|
+ {
|
|
|
+ inputs[i]->setAppendix(i);
|
|
|
+ }
|
|
|
+ input_counter = inputs.size();
|
|
|
+ for (int i = 0; i < outputs.size(); ++i)
|
|
|
+ {
|
|
|
+ outputs[i]->setAppendix(i);
|
|
|
+ }
|
|
|
+ output_counter = outputs.size();
|
|
|
}
|
|
|
|
|
|
json ProcessorBase::dump() {
|
|
@@ -376,48 +441,55 @@ namespace mdd{
|
|
|
|
|
|
ret["params"];
|
|
|
ret["params"]["inputs"];
|
|
|
+ for (auto& out : processor_outputs)
|
|
|
+ {
|
|
|
+ out->setParent(shared_from_this());
|
|
|
+ ret["outputs"].push_back(out->dump());
|
|
|
+
|
|
|
+ json param;
|
|
|
+ param["GUI"] = getConfiguration()["GUI"];
|
|
|
+ param["ID"] = out->getIdentifier();
|
|
|
+ param["ID"]["type"] = "module";
|
|
|
+ param["type"] = "module";
|
|
|
+ param["key"] = "Input";
|
|
|
+ param["GUI"]["name"]["value"] = param["GUI"]["name"]["value"].get<std::string>() + "/" + out->getName();
|
|
|
+ param["outputs"].push_back(out->dump());
|
|
|
+ ret["params"]["inputs"].push_back(param);
|
|
|
+ }
|
|
|
for (size_t i = 0; i < inputs.size(); i++)
|
|
|
{
|
|
|
if (auto in_ptr = inputs[i])
|
|
|
{
|
|
|
- json sub;
|
|
|
- sub["type"] = in_ptr->getType();
|
|
|
- sub["appendix"] = in_ptr->getAppendix();
|
|
|
- ret["params"]["inputs"].push_back(sub);
|
|
|
+ ret["inputs"].push_back(in_ptr->getInput(0)->dump());
|
|
|
+ ret["params"]["inputs"].push_back(in_ptr->dump());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
ret["params"]["outputs"];
|
|
|
- for (size_t i = 0; i < outputs.size(); i++)
|
|
|
- {
|
|
|
- if (auto out_ptr = outputs[i])
|
|
|
- {
|
|
|
- json sub;
|
|
|
- sub["type"] = out_ptr->getType();
|
|
|
- sub["appendix"] = out_ptr->getAppendix();
|
|
|
- ret["params"]["outputs"].push_back(sub);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
for (auto& in : processor_inputs)
|
|
|
{
|
|
|
in->setParent(shared_from_this());
|
|
|
ret["inputs"].push_back(in->dump());
|
|
|
- }
|
|
|
- for (auto& in : inputs)
|
|
|
- {
|
|
|
- ret["inputs"].push_back(in->getInput(0)->dump());
|
|
|
- }
|
|
|
|
|
|
- for (auto& out : processor_outputs)
|
|
|
- {
|
|
|
- out->setParent(shared_from_this());
|
|
|
- ret["outputs"].push_back(out->dump());
|
|
|
+ json param;
|
|
|
+ param["GUI"] = getConfiguration()["GUI"];
|
|
|
+ param["ID"] = in->getIdentifier();
|
|
|
+ param["ID"]["type"] = "module";
|
|
|
+ param["type"] = "module";
|
|
|
+ param["key"] = "Output";
|
|
|
+ param["GUI"]["name"]["value"] = param["GUI"]["name"]["value"].get<std::string>() + "/" + in->getName();
|
|
|
+ param["inputs"].push_back(in->dump());
|
|
|
+ ret["params"]["outputs"].push_back(param);
|
|
|
}
|
|
|
- for (auto& out : outputs)
|
|
|
+ for (size_t i = 0; i < outputs.size(); i++)
|
|
|
{
|
|
|
- ret["outputs"].push_back(out->getInput(0)->dump());
|
|
|
+ if (auto out_ptr = outputs[i])
|
|
|
+ {
|
|
|
+ ret["outputs"].push_back(out_ptr->getOutput(0)->dump());
|
|
|
+ ret["params"]["outputs"].push_back(out_ptr->dump());
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
for (auto& mod : modules)
|
|
|
{
|
|
|
if (auto module_ptr = mod)
|
|
@@ -453,6 +525,26 @@ namespace mdd{
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ for (auto& mod : inputs)
|
|
|
+ {
|
|
|
+ if (auto module_ptr = mod)
|
|
|
+ {
|
|
|
+ for (size_t j = 0; j < module_ptr->getNumOutputs(); j++)
|
|
|
+ {
|
|
|
+ auto input_connections = module_ptr->getOutput(j)->getConnections();
|
|
|
+ if (!input_connections.empty())
|
|
|
+ {
|
|
|
+ json connect;
|
|
|
+ connect["output"] = module_ptr->getOutput(j)->getIdentifier();
|
|
|
+ for (size_t k = 0; k < input_connections.size(); k++)
|
|
|
+ {
|
|
|
+ connect["inputs"].push_back(input_connections[k]->getIdentifier());
|
|
|
+ }
|
|
|
+ ret["connections"].push_back(connect);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return ret;
|
|
|
}
|
|
|
|
|
@@ -628,7 +720,7 @@ namespace mdd{
|
|
|
}
|
|
|
std::string sid;
|
|
|
++same_counter;
|
|
|
- if (same_counter + final_size == jid_pref->size())
|
|
|
+ if (same_counter == jid_pref->size() && final_size == 0)
|
|
|
{
|
|
|
sid = jid["key"].get<std::string>() + std::to_string(jid["appendix"].get<int>());
|
|
|
}
|