Sfoglia il codice sorgente

before big infrastracture change

Willi Zschiebsch 4 anni fa
parent
commit
c6ae4c6e59
4 ha cambiato i file con 54 aggiunte e 30 eliminazioni
  1. 2 2
      lib/src/Connector.cpp
  2. 18 11
      lib/src/ModuleBase.cpp
  3. 2 2
      lib/src/Output.cpp
  4. 32 15
      lib/src/ProcessorBase.cpp

+ 2 - 2
lib/src/Connector.cpp

@@ -49,7 +49,7 @@ namespace mdd {
 			IModule::Ptr module_out_ptr = _root->getModule(*jobj_out);
 			if (module_in_ptr != nullptr && module_out_ptr != nullptr) {
 				IInput::Ptr in_ptr = nullptr;
-				std::string id = (*jobj_in)["name"].get<std::string>() + std::to_string((*jobj_in)["appendix"].get<int>());
+				std::string id = (*jobj_in)["key"].get<std::string>() + std::to_string((*jobj_in)["appendix"].get<int>());
 				for (size_t i = 0; i < module_in_ptr->getNumInputs(); i++)
 				{
 					auto in = module_in_ptr->getInput(i);
@@ -61,7 +61,7 @@ namespace mdd {
 				}
 
 				IOutput::Ptr out_ptr = nullptr;
-				id = (*jobj_out)["name"].get<std::string>() + std::to_string((*jobj_out)["appendix"].get<int>());
+				id = (*jobj_out)["key"].get<std::string>() + std::to_string((*jobj_out)["appendix"].get<int>());
 				for (size_t i = 0; i < module_out_ptr->getNumOutputs(); i++)
 				{
 					auto out = module_out_ptr->getOutput(i);

+ 18 - 11
lib/src/ModuleBase.cpp

@@ -103,7 +103,7 @@ namespace mdd {
         auto jit = jconfig.find("GUI");
         if (jit != jconfig.end())
         {
-            _base_config["GUI"] = jit.value();
+            _base_config["GUI"].merge_patch(jit.value());
         }
         jit = jconfig.find("configure");
         if (jit != jconfig.end()) {
@@ -118,6 +118,11 @@ namespace mdd {
 
     const json& ModuleBase::getConfiguration()
     {
+        auto jit = _base_config.find("GUI");
+        if (jit == _base_config.end())
+        {
+            _base_config["GUI"]["name"] = _name;
+        }
         return _base_config;
     }
 
@@ -161,7 +166,7 @@ namespace mdd {
     }
 
     std::string ModuleBase::getID() {
-        return _name + std::to_string(_appendix);
+        return key + std::to_string(_appendix);
     }
 
     void ModuleBase::load(const json& j)
@@ -205,26 +210,28 @@ namespace mdd {
     }
     json ModuleBase::dump()
     {
-        _base_config["ID"] = getIdentifier();
-        _base_config["type"] = type;
-        _base_config["key"] = key;
+        json jdump;
+        jdump = getConfiguration();
+        jdump["ID"] = getIdentifier();
+        jdump["type"] = type;
+        jdump["key"] = key;
 
-        _base_config["inputs"].clear();
-        _base_config["outputs"].clear();
+        jdump["inputs"].clear();
+        jdump["outputs"].clear();
         
         for (auto& in : inputs)
         {
             in->setParent(shared_from_this());
-            _base_config["inputs"].push_back(in->dump());
+            jdump["inputs"].push_back(in->dump());
         }
 
         for (auto& out : outputs)
         {
             out->setParent(shared_from_this());
-            _base_config["outputs"].push_back(out->dump());
+            jdump["outputs"].push_back(out->dump());
         }
 
-        return _base_config;
+        return jdump;
     }
 
     void ModuleBase::disconnect() {
@@ -246,7 +253,7 @@ namespace mdd {
 
     json ModuleBase::getIdentifier() {
         json jID;
-        jID["name"] = _name;
+        jID["key"] = key;
         jID["appendix"] = getAppendix();
         jID["type"] = type;
         jID["prefix"] = getParentID(); 

+ 2 - 2
lib/src/Output.cpp

@@ -92,7 +92,7 @@ namespace mdd {
     }
 
     std::string Output::getID() {
-        return _name + std::to_string(_appendix);
+        return key + std::to_string(_appendix);
     }
 
     void Output::setParent(IModule::Ptr parent) {
@@ -232,7 +232,7 @@ namespace mdd {
 
     json Output::getIdentifier() {
         json jID;
-        jID["name"] = _name;
+        jID["key"] = key;
         jID["appendix"] = _appendix;
         jID["type"] = "output";
         jID["prefix"]= getParentID();

+ 32 - 15
lib/src/ProcessorBase.cpp

@@ -19,7 +19,7 @@ namespace mdd{
         auto jit = jconfig.find("GUI");
         if (jit != jconfig.end())
         {
-            _base_config["GUI"] = jit.value();
+            _base_config["GUI"].merge_patch(jit.value());
         }
         jit = jconfig.find("params");
         if (jit != jconfig.end())
@@ -98,7 +98,12 @@ namespace mdd{
     }
 
     const json& ProcessorBase::getConfiguration() {
-        //update module apendix ?
+        //update module apendix ? 
+        auto jit = _base_config.find("GUI");
+        if (jit == _base_config.end())
+        {
+            _base_config["GUI"]["name"] = _name;
+        }
         return _base_config;
     }
 
@@ -143,7 +148,7 @@ namespace mdd{
     }
 
     std::string ProcessorBase::getID() {
-        return _name + std::to_string(_appendix);
+        return key + std::to_string(_appendix);
     }
 
 
@@ -380,7 +385,7 @@ namespace mdd{
     }
 
     json ProcessorBase::dump() {
-        json ret = _base_config;
+        json ret = getConfiguration();
         ret["ID"] = getIdentifier();
         ret["type"] = type;
         ret["key"] = key;
@@ -469,7 +474,7 @@ namespace mdd{
 
     json ProcessorBase::getIdentifier() {
         json jID;
-        jID["name"] = _name;
+        jID["key"] = key;
         jID["appendix"] = getAppendix();
         jID["type"] = type;
         jID["prefix"] = getParentID();
@@ -534,15 +539,27 @@ namespace mdd{
     }
    
     std::shared_ptr<IOutput> ProcessorBase::getOutput(const json& jid){
-        std::string sid = jid["name"].get<std::string>() + std::to_string(jid["appendix"].get<int>());
-        for (auto& output : processor_outputs) {
-            if(output->getID() == sid){
-                return output;
+        auto jid_pref = jid.find("prefix");
+        if (jid_pref != jid.end())
+        {
+            auto mod = getModule(jid);
+            if (mod == shared_from_this())
+            {
+                std::string sid = jid["key"].get<std::string>() + std::to_string(jid["appendix"].get<int>());
+                for (auto& output : processor_outputs) {
+                    if (output->getID() == sid) {
+                        return output;
+                    }
+                }
+                for (auto& output : outputs) {
+                    if (output->getOutput(0)->getID() == sid) {
+                        return output->getOutput(0);
+                    }
+                }
             }
-        }
-        for (auto& output : outputs) {
-            if(output->getOutput(0)->getID() == sid){
-                return output->getOutput(0);
+            else
+            {
+                return mod->getOutput(jid);
             }
         }
         return nullptr;
@@ -568,7 +585,7 @@ namespace mdd{
             auto mod = getModule(jid);
             if (mod == shared_from_this())
             {
-                std::string sid = jid["name"].get<std::string>() + std::to_string(jid["appendix"].get<int>());
+                std::string sid = jid["key"].get<std::string>() + std::to_string(jid["appendix"].get<int>());
                 for (auto& input : processor_inputs) {
                     if (input->getID() == sid) {
                         return input;
@@ -607,7 +624,7 @@ namespace mdd{
             }
             else
             {
-                sid = jid_copy["name"].get<std::string>() + std::to_string(jid_copy["appendix"].get<int>());
+                sid = jid_copy["key"].get<std::string>() + std::to_string(jid_copy["appendix"].get<int>());
             }
 
             IModule::Ptr module_ptr;