|
@@ -2,13 +2,27 @@
|
|
|
|
|
|
namespace mdd{
|
|
|
ProcessorBase::ProcessorBase(const std::string& base_config)
|
|
|
- : _base_config(base_config)
|
|
|
{
|
|
|
-
|
|
|
+ json jparse = json::parse(base_config);
|
|
|
+ if (jparse.contains("configure"))
|
|
|
+ {
|
|
|
+ _base_config = base_config;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ json jconfig;
|
|
|
+ jconfig["configure"] = jparse;
|
|
|
+ _base_config = jconfig.dump();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
bool ProcessorBase::configure(const std::string& config) {
|
|
|
json j = json::parse(config);
|
|
|
+ json jbase = json::parse(_base_config);
|
|
|
+ if (j.contains("GUI"))
|
|
|
+ {
|
|
|
+ jbase["GUI"] = j["GUI"];
|
|
|
+ }
|
|
|
+ _base_config = jbase.dump();
|
|
|
for (size_t i = 0; i < j.size(); i++)
|
|
|
{
|
|
|
if (j.contains("params"))
|
|
@@ -77,31 +91,7 @@ namespace mdd{
|
|
|
sub_ret["params"]["outputs"].push_back(sub);
|
|
|
}
|
|
|
|
|
|
- sub_ret["modules"];
|
|
|
- sub_ret["connections"];
|
|
|
- for (size_t i = 0; i < modules.size(); i++)
|
|
|
- {
|
|
|
- json sub;
|
|
|
- sub["id"] = typeid((*modules[i])).name();
|
|
|
- sub["type"] = modules[i]->getType();
|
|
|
- sub["appendix"] = modules[i]->getAppendix();
|
|
|
- sub["configure"] = modules[i]->dump();
|
|
|
- sub_ret["modules"].push_back(sub);
|
|
|
- for (size_t j = 0; j < modules[i]->getNumOutputs(); j++)
|
|
|
- {
|
|
|
- auto connections = modules[i]->getOutput(j)->getConnections();
|
|
|
- if (!connections.empty())
|
|
|
- {
|
|
|
- json connect;
|
|
|
- connect["output"] = modules[i]->getOutput(j)->getParentID() + "/" + modules[i]->getOutput(j)->getID();
|
|
|
- for (size_t k = 0; k < connections.size(); k++)
|
|
|
- {
|
|
|
- connect["inputs"].push_back(connections[k]->getParentID() + "/" + connections[k]->getID());
|
|
|
- }
|
|
|
- sub_ret["connections"].push_back(connect);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
ret.push_back(sub_ret);
|
|
|
return ret.dump();
|
|
|
}
|
|
@@ -256,13 +246,18 @@ namespace mdd{
|
|
|
}
|
|
|
|
|
|
json ProcessorBase::dump() {
|
|
|
- json ret;
|
|
|
- ret["name"] = _name;
|
|
|
- ret["id"] = getAppendix();
|
|
|
- ret["type"] = type;
|
|
|
- ret["key"] = key;
|
|
|
- ret["prefix"] = std::vector<std::string>();
|
|
|
- ret["configure"] = json::parse(_base_config);
|
|
|
+ json ret = getIdentifier();
|
|
|
+ json jconfig = json::parse(_base_config);
|
|
|
+ if (jconfig.contains("configure"))
|
|
|
+ {
|
|
|
+ ret["configure"] = jconfig["configure"];
|
|
|
+ }
|
|
|
+ if (jconfig.contains("GUI"))
|
|
|
+ {
|
|
|
+ ret["GUI"] = jconfig["GUI"];
|
|
|
+ }
|
|
|
+
|
|
|
+ //ret["configure"] = json::parse(_base_config);
|
|
|
|
|
|
|
|
|
for (auto& in : processor_inputs)
|
|
@@ -284,11 +279,44 @@ namespace mdd{
|
|
|
}
|
|
|
for (auto& mod : modules)
|
|
|
{
|
|
|
- ret["modules"].push_back(mod->dump());
|
|
|
+ if (mod->getType()=="module")
|
|
|
+ {
|
|
|
+ ret["modules"].push_back(mod->dump());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ret["modules"].push_back(mod->dump());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for (size_t j = 0; j < mod->getNumOutputs(); j++)
|
|
|
+ {
|
|
|
+ auto input_connections = mod->getOutput(j)->getConnections();
|
|
|
+ if (!input_connections.empty())
|
|
|
+ {
|
|
|
+ json connect;
|
|
|
+ connect["output"] = mod->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;
|
|
|
}
|
|
|
|
|
|
+ json ProcessorBase::getIdentifier() {
|
|
|
+ json jID;
|
|
|
+ jID["name"] = _name;
|
|
|
+ jID["id"] = getAppendix();
|
|
|
+ jID["type"] = type;
|
|
|
+ jID["key"] = key;
|
|
|
+ jID["prefix"] = std::vector<std::string>();
|
|
|
+ return jID;
|
|
|
+ }
|
|
|
+
|
|
|
std::shared_ptr<IOutput> ProcessorBase::getOutput(size_t index) {
|
|
|
if (index < processor_outputs.size())
|
|
|
{
|