|
@@ -38,7 +38,7 @@ namespace mdd {
|
|
|
}
|
|
|
else if (*jobj_typ == "module")
|
|
|
{
|
|
|
- _root->addModule(Registration().generateModule((*jobj_typ)["key"].get<std::string>()));
|
|
|
+ _root->addModule(Registration().generateModule((*jobj)["key"].get<std::string>()));
|
|
|
jargs["object"] = _root->getModules().back()->dump();
|
|
|
}
|
|
|
else if(*jobj_typ == "connection")
|
|
@@ -194,7 +194,19 @@ namespace mdd {
|
|
|
}
|
|
|
else if (*jsub_typ == "output")
|
|
|
{
|
|
|
-
|
|
|
+ IModule::Ptr module_ptr = _root->getModule(*jsub);
|
|
|
+ if (module_ptr == nullptr) {
|
|
|
+ std::cout << "[Connector]: change: Was not able to find module." << std::endl;
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ IOutput::Ptr out_ptr = module_ptr->getOutput(*jsub);
|
|
|
+ if (out_ptr == nullptr) {
|
|
|
+ std::cout << "[Connector]: change: Was not able to find output." << std::endl;
|
|
|
+ return ret;
|
|
|
+ }
|
|
|
+ out_ptr->configure(*jobj);
|
|
|
+ jargs["subject"] = out_ptr->getIdentifier();
|
|
|
+ jargs["object"] = *jobj;
|
|
|
}
|
|
|
else {
|
|
|
json j;
|
|
@@ -250,25 +262,39 @@ namespace mdd {
|
|
|
if (jtype != args.end())
|
|
|
{
|
|
|
found = true;
|
|
|
- auto module_ptr = _root->getModule(args);
|
|
|
- if (*jtype == "processor")
|
|
|
+ if (*jtype == "optimizer")
|
|
|
{
|
|
|
- if (IProcessor* processor_ptr = dynamic_cast<IProcessor*>(&(*module_ptr)))
|
|
|
- {
|
|
|
- ret["info"] = processor_ptr->dump();
|
|
|
- }
|
|
|
- }
|
|
|
- else if (*jtype == "module")
|
|
|
- {
|
|
|
- ret["info"] = module_ptr->dump();
|
|
|
+ ret["info"] = _opt->getConfiguration();
|
|
|
+ //ret["info"]["ID"] = _opt->getIdentifier();
|
|
|
}
|
|
|
- else if (*jtype == "input")
|
|
|
- {
|
|
|
- ret["info"] = module_ptr->getInput(args)->dump();
|
|
|
- }
|
|
|
- else if (*jtype == "output")
|
|
|
+ else
|
|
|
{
|
|
|
- ret["info"] = module_ptr->getOutput(args)->dump();
|
|
|
+ auto module_ptr = _root->getModule(args);
|
|
|
+ if (*jtype == "processor")
|
|
|
+ {
|
|
|
+ if (IProcessor* processor_ptr = dynamic_cast<IProcessor*>(&(*module_ptr)))
|
|
|
+ {
|
|
|
+ ret["info"] = processor_ptr->getConfiguration();
|
|
|
+ //ret["info"]["ID"] = processor_ptr->getIdentifier();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (*jtype == "module")
|
|
|
+ {
|
|
|
+ ret["info"] = module_ptr->getConfiguration();
|
|
|
+ //ret["info"]["ID"] = module_ptr->getIdentifier();
|
|
|
+ }
|
|
|
+ else if (*jtype == "input")
|
|
|
+ {
|
|
|
+ auto ptr = module_ptr->getInput(args);
|
|
|
+ ret["info"] = ptr->getConfiguration();
|
|
|
+ //ret["info"]["ID"] = ptr->getIdentifier();
|
|
|
+ }
|
|
|
+ else if (*jtype == "output")
|
|
|
+ {
|
|
|
+ auto ptr = module_ptr->getOutput(args);
|
|
|
+ ret["info"] = ptr->getConfiguration();
|
|
|
+ //ret["info"]["ID"] = ptr->getIdentifier();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -287,7 +313,8 @@ namespace mdd {
|
|
|
json Connector::save(const json& args) {
|
|
|
std::ofstream out("save.json");
|
|
|
json jfile;
|
|
|
- jfile = _root->dump();
|
|
|
+ jfile["processor"] = _root->dump();
|
|
|
+ jfile["optimizer"] = _opt->dump();
|
|
|
out << std::setw(4) << jfile << std::endl;
|
|
|
json ret;
|
|
|
ret["operation"] = "save";
|
|
@@ -299,18 +326,32 @@ namespace mdd {
|
|
|
std::ifstream in("save.json");
|
|
|
json jfile;
|
|
|
in >> jfile;
|
|
|
- if (jfile.contains("key"))
|
|
|
+ auto jproc = jfile.find("processor");
|
|
|
+ if (jproc != jfile.end())
|
|
|
{
|
|
|
- _root = regi.generateProcessor(jfile["key"].get<std::string>());
|
|
|
- _root->load(jfile);
|
|
|
+ if (jproc->contains("key"))
|
|
|
+ {
|
|
|
+ _root = regi.generateProcessor((*jproc)["key"].get<std::string>());
|
|
|
+ _root->load((*jproc));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ auto jopt = jfile.find("optimizer");
|
|
|
+ if (jopt != jfile.end()) {
|
|
|
+ if (jopt->contains("key"))
|
|
|
+ {
|
|
|
+ _opt = regi.generateOptimizer((*jopt)["key"].get<std::string>());
|
|
|
+ _opt->load((*jopt));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
_root = regi.generateProcessor("ProcessorStandard");
|
|
|
_root->setName("root");
|
|
|
+
|
|
|
+ _opt = regi.generateOptimizer("OptimizerEvolutionary");
|
|
|
}
|
|
|
-
|
|
|
+ _opt->connect(_root);
|
|
|
|
|
|
json ret;
|
|
|
ret["operation"] = "state";
|