Browse Source

GUI: configure

Willi Zschiebsch 4 years ago
parent
commit
0cd13acb7e

+ 2 - 1
lib/include/ModuleBase.h

@@ -12,9 +12,10 @@ namespace mdd {
         std::string _name = "";
         std::string _name = "";
         int _appendix = 0;
         int _appendix = 0;
 
 
-        std::string _base_config = "";
+        
 
 
     protected:
     protected:
+        std::string _base_config = "";
         ModuleBase(const std::string& base_config = "{}"); 
         ModuleBase(const std::string& base_config = "{}"); 
         std::string type = "module";
         std::string type = "module";
         std::string key;
         std::string key;

+ 38 - 22
lib/src/Connector.cpp

@@ -31,22 +31,7 @@ namespace mdd {
 		{
 		{
 
 
 		}
 		}
-		else if (sub["type"] == "connection")
-		{
-
-		}
-		else if (sub["type"] == "input")
-		{
 
 
-		}
-		else if (sub["type"] == "output")
-		{
-
-		}
-		else if (sub["type"] == "configuration")
-		{
-
-		}
 		else {
 		else {
 			json j;
 			json j;
 			return j;
 			return j;
@@ -76,7 +61,7 @@ namespace mdd {
 				for (size_t i = 0; i < module_in_ptr->getNumInputs(); i++)
 				for (size_t i = 0; i < module_in_ptr->getNumInputs(); i++)
 				{
 				{
 					auto in = module_in_ptr->getInput(i);
 					auto in = module_in_ptr->getInput(i);
-					auto id = obj["input"]["name"].get<std::string>() + std::to_string(obj["input"]["id"].get<int>());
+					auto id = obj["input"]["name"].get<std::string>() + std::to_string(obj["input"]["appendix"].get<int>());
 					if (in->getID() == id)
 					if (in->getID() == id)
 					{
 					{
 						in_ptr = in;
 						in_ptr = in;
@@ -88,7 +73,7 @@ namespace mdd {
 				for (size_t i = 0; i < module_in_ptr->getNumOutputs(); i++)
 				for (size_t i = 0; i < module_in_ptr->getNumOutputs(); i++)
 				{
 				{
 					auto out = module_out_ptr->getOutput(i);
 					auto out = module_out_ptr->getOutput(i);
-					auto id = obj["output"]["name"].get<std::string>() + std::to_string(obj["output"]["id"].get<int>());
+					auto id = obj["output"]["name"].get<std::string>() + std::to_string(obj["output"]["appendix"].get<int>());
 					if (out->getID() == id)
 					if (out->getID() == id)
 					{
 					{
 						out_ptr = out;
 						out_ptr = out;
@@ -156,34 +141,65 @@ namespace mdd {
 			}
 			}
 			else
 			else
 			{
 			{
-				IModule::Ptr module_ptr = _root->getModule(sub["name"].get<std::string>() + std::to_string(sub["id"].get<int>()));
+				IModule::Ptr module_ptr = _root->getModule(sub["name"].get<std::string>() + std::to_string(sub["appendix"].get<int>()));
 				if (module_ptr == nullptr) {
 				if (module_ptr == nullptr) {
 					std::cout << "[Connector]: change: Was not able to find module." << std::endl;
 					std::cout << "[Connector]: change: Was not able to find module." << std::endl;
 					return ret;
 					return ret;
 				}
 				}
 				jargs["subject"] = module_ptr->getIdentifier();
 				jargs["subject"] = module_ptr->getIdentifier();
-				if (module_ptr->configure(obj.dump()))
+				module_ptr->configure(obj.dump());
+				if (obj.contains("configure"))
 				{
 				{
+					jargs["object"]["configure"] = module_ptr->dump();
+				}
+				else {
 					jargs["object"] = obj;
 					jargs["object"] = obj;
 				}
 				}
+				
 			}
 			}
 		}
 		}
 		else if (sub["type"] == "module")
 		else if (sub["type"] == "module")
 		{
 		{
-			IModule::Ptr module_ptr = _root->getModule(sub["name"].get<std::string>() + std::to_string(sub["id"].get<int>()));
+			IModule::Ptr module_ptr = _root->getModule(sub["name"].get<std::string>() + std::to_string(sub["appendix"].get<int>()));
 			if (module_ptr == nullptr) {
 			if (module_ptr == nullptr) {
 				std::cout << "[Connector]: change: Was not able to find module." << std::endl;
 				std::cout << "[Connector]: change: Was not able to find module." << std::endl;
 				return ret;
 				return ret;
 			}
 			}
 			jargs["subject"] = module_ptr->getIdentifier();
 			jargs["subject"] = module_ptr->getIdentifier();
-			if (module_ptr->configure(obj.dump()))
+			module_ptr->configure(obj.dump());
+			if (obj.contains("configure"))
 			{
 			{
+				jargs["object"]["configure"] = module_ptr->dump();
+			}
+			else {
 				jargs["object"] = obj;
 				jargs["object"] = obj;
 			}
 			}
 		}
 		}
 		else if (sub["type"] == "input")
 		else if (sub["type"] == "input")
 		{
 		{
-
+			IModule::Ptr module_ptr = _root->getModule(sub["prefix"].back().get<std::string>());
+			if (module_ptr == nullptr) {
+				std::cout << "[Connector]: change: Was not able to find module." << std::endl;
+				return ret;
+			}
+			IInput::Ptr in_ptr = module_ptr->getInput(sub["name"].get<std::string>() + std::to_string(sub["appendix"].get<int>()));
+			if (in_ptr == nullptr) {
+				std::cout << "[Connector]: change: Was not able to find input." << std::endl;
+				return ret;
+			}
+			if (obj.contains("value"))
+			{
+				json jval = json::parse(obj["value"].get<std::string>());
+				if (!jval.is_array())
+				{
+					return ret;
+				}
+				jval.get<std::vector<double>>();
+				std::vector<double> new_val = jval.get<std::vector<double>>();
+				in_ptr->setValue(new_val);
+				jargs["subject"] = in_ptr->getIdentifier();
+				jargs["object"] = obj;
+			}
 		}
 		}
 		else if (sub["type"] == "output")
 		else if (sub["type"] == "output")
 		{
 		{

+ 4 - 5
lib/src/Input.cpp

@@ -158,11 +158,10 @@ namespace mdd{
     std::string Input::getConfiguration() 
     std::string Input::getConfiguration() 
     {
     {
         json jconfig;
         json jconfig;
-        jconfig["name"] = _name;
-        jconfig["appendix"] = _appendix;
         jconfig["value"] = _value;
         jconfig["value"] = _value;
-        jconfig["prefix"].push_back(_parent->getID());
         jconfig["optimizable"] = _optimizable;
         jconfig["optimizable"] = _optimizable;
+        jconfig["type"] = "input";
+        jconfig["key"] = "Input";
         return jconfig.dump();
         return jconfig.dump();
     }
     }
 
 
@@ -175,6 +174,7 @@ namespace mdd{
     json Input::dump() 
     json Input::dump() 
     {
     {
         json jdump = json::parse(getConfiguration());
         json jdump = json::parse(getConfiguration());
+        jdump["ID"] = getIdentifier();
         return jdump;
         return jdump;
     }
     }
 
 
@@ -182,8 +182,7 @@ namespace mdd{
         json jID;
         json jID;
         jID["name"] = _name;
         jID["name"] = _name;
         jID["appendix"] = _appendix;
         jID["appendix"] = _appendix;
-        jID["value"] = _value;
-        jID["key"] = "Input";
+        jID["type"] = "input";
         jID["prefix"].push_back(_parent->getID());
         jID["prefix"].push_back(_parent->getID());
         return jID;
         return jID;
     }
     }

+ 10 - 16
lib/src/ModuleBase.cpp

@@ -75,16 +75,17 @@ namespace mdd {
     ModuleBase::ModuleBase(const std::string& base_config)
     ModuleBase::ModuleBase(const std::string& base_config)
     {
     {
         json jparse = json::parse(base_config);
         json jparse = json::parse(base_config);
+        json jconfig;
         if (jparse.contains("configure"))
         if (jparse.contains("configure"))
         {
         {
-            _base_config = base_config;
+            jconfig = jparse;
         }
         }
         else {
         else {
-            json jconfig;
             jconfig["configure"] = jparse;
             jconfig["configure"] = jparse;
-            _base_config = jconfig.dump();
         }
         }
+
         
         
+        _base_config = jconfig.dump();
     }
     }
     bool ModuleBase::configure(const std::string& config) {
     bool ModuleBase::configure(const std::string& config) {
         json j = json::parse(config);
         json j = json::parse(config);
@@ -142,17 +143,11 @@ namespace mdd {
     }
     }
     json ModuleBase::dump()
     json ModuleBase::dump()
     {
     {
-        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"];
-        }
-
+        json ret = json::parse(_base_config);
+        ret["ID"] = getIdentifier(); 
+        ret["type"] = type;
+        ret["key"] = key;
+        
         for (auto& in : inputs)
         for (auto& in : inputs)
         {
         {
             ret["inputs"].push_back(in->dump());
             ret["inputs"].push_back(in->dump());
@@ -180,9 +175,8 @@ namespace mdd {
     json ModuleBase::getIdentifier() {
     json ModuleBase::getIdentifier() {
         json jID;
         json jID;
         jID["name"] = _name;
         jID["name"] = _name;
-        jID["id"] = getAppendix();
+        jID["appendix"] = getAppendix();
         jID["type"] = type;
         jID["type"] = type;
-        jID["key"] = key;
         jID["prefix"] = std::vector<std::string>(); 
         jID["prefix"] = std::vector<std::string>(); 
         return jID;
         return jID;
     }
     }

+ 40 - 37
lib/src/ModuleHTTP.cpp

@@ -136,16 +136,17 @@ namespace mdd{
 
 
     ModuleHTTP::ModuleHTTP()// std::string fname, std::string id, int port):
     ModuleHTTP::ModuleHTTP()// std::string fname, std::string id, int port):
         : ModuleBase(R"JSON(
         : ModuleBase(R"JSON(
-        [{
-            "name":"file",
-            "value": ""
-        },{
-            "name": "url",
-            "value": ""
-        },{
-            "name":"port",
-            "value": 0
-        }])JSON")
+        {
+            "file":{
+                "value": ""
+            },
+            "url":{
+                "value": ""
+            },
+            "port":{
+                "value": 0
+            }
+        })JSON")
         ,_port(0)
         ,_port(0)
     {
     {
         key = "ModuleHTTP";
         key = "ModuleHTTP";
@@ -156,39 +157,40 @@ namespace mdd{
         bool found = false;
         bool found = false;
         found = ModuleBase::configure(config);
         found = ModuleBase::configure(config);
         json config_parsed = json::parse(config);
         json config_parsed = json::parse(config);
-        if (!config_parsed.is_array())
+        json base_config = json::parse(ModuleBase::getConfiguration());
+
+        if (config_parsed.contains("configure"))
+        {
+            config_parsed = config_parsed["configure"];
+        }
+
+        if (config_parsed.contains("url"))
         {
         {
-            return found;
+            _id = config_parsed["url"]["value"].get<std::string>();
+            base_config["configure"]["url"]["value"] = _fname;
+            found = true;
         }
         }
-        for (size_t i = 0; i < config_parsed.size(); i++)
+        
+        if (config_parsed.contains("port"))
         {
         {
-            if (config_parsed[i].contains("name"))
+            json jval = config_parsed["port"]["value"];
+            if (jval.is_string())
             {
             {
-                if (config_parsed[i]["name"].get<std::string>() == "url")
-                {
-                    _id = config_parsed[i]["value"].get<std::string>();
-                    found = true;
-                }
-                else if (config_parsed[i]["name"].get<std::string>() == "port")
-                {
-                    _port = config_parsed[i]["value"].get<int>();
-                    found = true;
-                }
-                else if (config_parsed[i]["name"].get<std::string>() == "file")
-                {
-                    _fname = config_parsed[i]["value"].get<std::string>();
-                    found = true;
-                }
-                else {
-                    std::cout << "ERROR Configure option: " << config_parsed[i]["name"].dump() << " do not exist!" << std::endl;
-                    return false;
-                }
-            }
-            else {
-                std::cout << "ERROR Wrong configure format: " << config_parsed[i].dump() << std::endl;
-                return false;
+                jval = json::parse(jval.get<std::string>());
             }
             }
+            _port = jval.get<int>();
+            base_config["configure"]["port"]["value"] = jval;
+            found = true;
+        }
+        
+        if (config_parsed.contains("file"))
+        {
+            _fname = config_parsed["file"]["value"].get<std::string>();
+            base_config["configure"]["file"]["value"] = _fname;
+            found = true;
         }
         }
+        
+
         if (!_fname.empty()) {
         if (!_fname.empty()) {
             if (std::filesystem::exists(_fname))
             if (std::filesystem::exists(_fname))
             {
             {
@@ -204,6 +206,7 @@ namespace mdd{
         }
         }
         updateInputs();
         updateInputs();
         updateOutputs();
         updateOutputs();
+        _base_config = base_config.dump();
         return found;
         return found;
     }
     }
 
 

+ 15 - 19
lib/src/ModuleMath.cpp

@@ -33,8 +33,8 @@ namespace mdd {
 
 
     ModuleMath::ModuleMath()
     ModuleMath::ModuleMath()
         : ModuleBase(R"JSON(
         : ModuleBase(R"JSON(
-        [{
-            "name":"operation",
+        {
+            "operation":{
             "value":"add",
             "value":"add",
             "options":  [
             "options":  [
                             "add",
                             "add",
@@ -48,7 +48,8 @@ namespace mdd {
                             "lesser", 
                             "lesser", 
                             "greater"
                             "greater"
                         ]
                         ]
-        }])JSON")
+            }
+        })JSON")
     {
     {
         _ops.at("add");
         _ops.at("add");
         _operation = _ops.find("add")->second;
         _operation = _ops.find("add")->second;
@@ -65,28 +66,23 @@ namespace mdd {
         bool success = false;
         bool success = false;
         success = ModuleBase::configure(config);
         success = ModuleBase::configure(config);
         json config_parsed = json::parse(config);
         json config_parsed = json::parse(config);
-        if (!config_parsed.is_array())
+        json base_config = json::parse(ModuleBase::getConfiguration());
+        if (config_parsed.contains("configure"))
         {
         {
-            return success;
+            config_parsed = config_parsed["configure"];
         }
         }
-        for (size_t i = 0; i < config_parsed.size(); i++)
+        if (config_parsed.contains("operation"))
         {
         {
-            if (config_parsed[i].contains("name"))
+            const std::string op = config_parsed["operation"]["value"].get<std::string>();
+            auto it = _ops.find(op);
+            if (it != _ops.end())
             {
             {
-                if (config_parsed[i]["name"].get<std::string>() == "operation")
-                {
-                    const std::string op = config_parsed[i]["value"].get<std::string>();
-                    auto it = _ops.find(op);
-                    if (it != _ops.end())
-                    {
-                        _operation = it->second;
-                        return true;
-                    }
-                }
+                _operation = it->second;
+                base_config["configure"]["operation"]["value"] = op;
             }
             }
         }
         }
-        
-        return false;
+        _base_config = base_config.dump();
+        return true;
     }
     }
 
 
     std::string ModuleMath::getConfiguration() {
     std::string ModuleMath::getConfiguration() {

+ 23 - 45
lib/src/ModuleMerge.cpp

@@ -11,15 +11,15 @@ namespace mdd {
 		int removeModuleInput();
 		int removeModuleInput();
 		std::string setInputName(const std::string& input_id, const std::string& new_name);
 		std::string setInputName(const std::string& input_id, const std::string& new_name);
 		bool configure(const std::string& config) override;
 		bool configure(const std::string& config) override;
-		std::string getConfiguration() override;
 		state update() override;
 		state update() override;
 	};
 	};
 	ModuleMerge::ModuleMerge()
 	ModuleMerge::ModuleMerge()
 		:ModuleBase(R"JSON(
 		:ModuleBase(R"JSON(
-        [{
-            "name":"inputs",
-            "value":[2]
-        }])JSON")
+        {
+            "inputs":{
+				"value":2
+			}
+        })JSON")
 	{
 	{
 		std::vector<double> default_val = { 1 };
 		std::vector<double> default_val = { 1 };
 		inputs.push_back(std::make_shared<Input>(this, "Value", 0, default_val));
 		inputs.push_back(std::make_shared<Input>(this, "Value", 0, default_val));
@@ -54,56 +54,34 @@ namespace mdd {
 		bool success = false;
 		bool success = false;
 		success = ModuleBase::configure(config);
 		success = ModuleBase::configure(config);
 		json config_parsed = json::parse(config);
 		json config_parsed = json::parse(config);
-		if (!config_parsed.is_array())
+		json base_config = json::parse(ModuleBase::getConfiguration());
+		if (config_parsed.contains("configure"))
 		{
 		{
-			return success;
+			config_parsed = config_parsed["configure"];
 		}
 		}
-		for (size_t i = 0; i < config_parsed.size(); i++)
+		if (config_parsed.contains("inputs"))
 		{
 		{
-			if (config_parsed[i].contains("name"))
+			json jval = config_parsed["inputs"]["value"];
+			if (jval.is_string())
 			{
 			{
-				if (config_parsed[i]["name"].get<std::string>() == "inputs")
-				{
-					size_t new_length = config_parsed[i]["value"][0].get<int>();
-					size_t length = inputs.size();
-					if (length - new_length > 0)
-					{
-						inputs.erase(inputs.end() - (length - new_length), inputs.end());
-					}
-					else {
-						for (size_t j = length; j < new_length; j++)
-						{
-							inputs.push_back(std::make_shared<Input>(this, "Value", j, std::vector<double> {1}));
-						}
-					}
-				}
+				jval = json::parse(jval.get<std::string>());
 			}
 			}
-		}
-
-		return false;
-	}
-
-	std::string ModuleMerge::getConfiguration() {
-		json ret = json::parse(ModuleBase::getConfiguration());
-		for (size_t i = 0; i < ret.size(); i++)
-		{
-			if (ret[i].contains("name"))
+			size_t new_length = jval.get<size_t>();
+			size_t length = inputs.size();
+			if ((int)length - (int)new_length > 0)
 			{
 			{
-				if (ret[i]["name"].get<std::string>() == "inputs")
+				inputs.erase(inputs.end() - (length - new_length), inputs.end());
+			}
+			else {
+				for (size_t j = length; j < new_length; j++)
 				{
 				{
-					size_t length = inputs.size();
-
-					for (size_t j = 0; j < length; j++)
-					{
-						json in;
-						in["type"] = inputs[j]->getType();
-						in["value"] = inputs[j]->getValue();
-						ret[i]["value"].push_back(in);
-					}
+					inputs.push_back(std::make_shared<Input>(this, "Value", j, std::vector<double> {1}));
 				}
 				}
 			}
 			}
+			base_config["configure"]["inputs"]["value"] = jval;
 		}
 		}
-		return ret.dump();
+		_base_config =  base_config.dump();
+		return true;
 	}
 	}
 
 
 	state ModuleMerge::update() {
 	state ModuleMerge::update() {

+ 21 - 17
lib/src/ModuleSQL.cpp

@@ -39,10 +39,11 @@ namespace mdd {
 
 
 	ModuleSQL::ModuleSQL()
 	ModuleSQL::ModuleSQL()
 	: ModuleBase(R"JSON(
 	: ModuleBase(R"JSON(
-        [{
-            "name":"database",
-            "value":""
-        }])JSON")
+        {
+            "database":{
+				"value":""
+			}
+        })JSON")
 	{
 	{
 		key = "ModuleSQL";
 		key = "ModuleSQL";
 		setName("SQL");
 		setName("SQL");
@@ -95,20 +96,18 @@ namespace mdd {
 		bool success = false;
 		bool success = false;
 		success = ModuleBase::configure(config);
 		success = ModuleBase::configure(config);
 		json config_parsed = json::parse(config);
 		json config_parsed = json::parse(config);
-		if (!config_parsed.is_array())
+		json base_config = json::parse(ModuleBase::getConfiguration());
+		if (config_parsed.contains("configure"))
 		{
 		{
-			return success;
+			config_parsed = config_parsed["configure"];
 		}
 		}
-		
-		for (size_t i = 0; i < config_parsed.size(); i++)
+		if (config_parsed.contains("database"))
 		{
 		{
-			if (config_parsed[i].contains("name"))
-			{
-				if (config_parsed[i]["name"].get<std::string>() == "database")
-				{
-					_dbname = config_parsed[i]["value"].get<std::string>();
-				}
-			}
+			_dbname = config_parsed["database"]["value"].get<std::string>();
+		}
+		else
+		{
+			return false;
 		}
 		}
 		
 		
 		int rc = sqlite3_open(_dbname.c_str(), &_db);
 		int rc = sqlite3_open(_dbname.c_str(), &_db);
@@ -210,13 +209,18 @@ namespace mdd {
 
 
 		}
 		}
 		sqlite3_finalize(res);
 		sqlite3_finalize(res);
-
+		if (_content.empty())
+		{
+			return false;
+		}
 		inputs.push_back(std::make_shared<Input>(this, _content[0].key, inputs.size(), std::vector<double>{0}));
 		inputs.push_back(std::make_shared<Input>(this, _content[0].key, inputs.size(), std::vector<double>{0}));
 		for (auto& cont : _content)
 		for (auto& cont : _content)
 		{
 		{
 			outputs.push_back(std::make_shared<Output>(this, cont.key, outputs.size(), std::vector<double>{1}));
 			outputs.push_back(std::make_shared<Output>(this, cont.key, outputs.size(), std::vector<double>{1}));
 		}
 		}
-		
+
+		base_config["configure"]["database"]["value"] = _dbname;
+		_base_config = base_config.dump();
 		return true;
 		return true;
 	}
 	}
 
 

+ 35 - 34
lib/src/ModuleSwitch.cpp

@@ -11,10 +11,11 @@ namespace mdd{
     };
     };
     ModuleSwitch::ModuleSwitch()
     ModuleSwitch::ModuleSwitch()
         :ModuleBase(R"JSON(
         :ModuleBase(R"JSON(
-        [{
-            "name":"size",
-            "value": 1
-        }])JSON")
+        {
+            "size":{
+                "value": 1
+            }
+        })JSON")
     {    
     {    
         std::vector<double> default_val = { 1 };
         std::vector<double> default_val = { 1 };
         inputs.push_back(std::make_shared<Input>(this, "Switch", 0, default_val));
         inputs.push_back(std::make_shared<Input>(this, "Switch", 0, default_val));
@@ -27,44 +28,44 @@ namespace mdd{
         bool success = false;
         bool success = false;
         success = ModuleBase::configure(config);
         success = ModuleBase::configure(config);
         json config_parsed = json::parse(config);
         json config_parsed = json::parse(config);
-        if (!config_parsed.is_array())
+        json base_config = json::parse(ModuleBase::getConfiguration());
+        if (config_parsed.contains("configure"))
         {
         {
-            return success;
+            config_parsed = config_parsed["configure"];
         }
         }
-        for (size_t i = 0; i < config_parsed.size(); i++)
+        if (config_parsed.contains("size"))
         {
         {
-            if (config_parsed[i].contains("name"))
+            json jval = config_parsed["size"]["value"];
+            if (jval.is_string())
+            {
+                jval = json::parse(jval.get<std::string>());
+            }
+            size_t length = jval.get<size_t>();
+            if (length != inputs.size() - 1)
             {
             {
-                if (config_parsed[i]["name"].get<std::string>() == "size")
+                size_t length_before = inputs.size();
+                if (length_before != 1)
+                {
+                    inputs.back()->setName("Value");
+                }
+
+                for (size_t j = length_before - 1; j < length; j++)
+                {
+                    inputs.push_back(std::make_shared<Input>(this, "Value", inputs.size() - 1, std::vector<double>{1}));
+                }
+                for (size_t j = length; j < length_before - 1; j++)
                 {
                 {
-                    size_t length = config_parsed[i]["value"].get<size_t>();
-                    if (length != inputs.size() -1)
-                    {
-                        size_t length_before = inputs.size();
-                        if (length_before != 1)
-                        {
-                            inputs.back()->setName("Value");
-                        }
-                        
-                        for (size_t j = length_before - 1; j < length; j++)
-                        {
-                            inputs.push_back(std::make_shared<Input>(this, "Value", inputs.size() - 1, std::vector<double>{1}));
-                        }
-                        for (size_t j = length; j < length_before-1; j++)
-                        {
-                            inputs.pop_back();
-                        }
-                        if (length != 0)
-                        {
-                            inputs.back()->setName("Default");
-                        }
-                    }
-                    return true;
+                    inputs.pop_back();
+                }
+                if (length != 0)
+                {
+                    inputs.back()->setName("Default");
                 }
                 }
             }
             }
+            base_config["configure"]["size"]["value"] = jval;
         }
         }
-
-        return false;
+        _base_config = base_config.dump();
+        return true;
     }
     }
 
 
     std::string ModuleSwitch::getConfiguration() {
     std::string ModuleSwitch::getConfiguration() {

+ 6 - 3
lib/src/Output.cpp

@@ -151,8 +151,11 @@ namespace mdd {
 
 
     std::string Output::getConfiguration()
     std::string Output::getConfiguration()
     {
     {
-        json jconfig = getIdentifier();
+        json jconfig;
         jconfig["optimizable"] = _optimizable;
         jconfig["optimizable"] = _optimizable;
+        jconfig["value"] = _value;
+        jconfig["type"] = "output";
+        jconfig["key"] = "Output";
         return jconfig.dump();
         return jconfig.dump();
     }
     }
 
 
@@ -165,6 +168,7 @@ namespace mdd {
     json Output::dump()
     json Output::dump()
     {
     {
         json jdump = json::parse(getConfiguration());
         json jdump = json::parse(getConfiguration());
+        jdump["ID"] = getIdentifier();
         return jdump;
         return jdump;
     }
     }
 
 
@@ -172,8 +176,7 @@ namespace mdd {
         json jID;
         json jID;
         jID["name"] = _name;
         jID["name"] = _name;
         jID["appendix"] = _appendix;
         jID["appendix"] = _appendix;
-        jID["value"] = _value;
-        jID["key"] = "Output";
+        jID["type"] = "output";
         jID["prefix"].push_back(_parent->getID());
         jID["prefix"].push_back(_parent->getID());
         return jID;
         return jID;
     }
     }

+ 5 - 15
lib/src/ProcessorBase.cpp

@@ -246,19 +246,10 @@ namespace mdd{
     }
     }
 
 
     json ProcessorBase::dump() {
     json ProcessorBase::dump() {
-        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);
-        
+        json ret = json::parse(_base_config);
+        ret["ID"] = getIdentifier();
+        ret["type"] = type;
+        ret["key"] = key;
 
 
         for (auto& in : processor_inputs)
         for (auto& in : processor_inputs)
         {
         {
@@ -310,9 +301,8 @@ namespace mdd{
     json ProcessorBase::getIdentifier() {
     json ProcessorBase::getIdentifier() {
         json jID;
         json jID;
         jID["name"] = _name;
         jID["name"] = _name;
-        jID["id"] = getAppendix();
+        jID["appendix"] = getAppendix();
         jID["type"] = type;
         jID["type"] = type;
-        jID["key"] = key;
         jID["prefix"] = std::vector<std::string>();
         jID["prefix"] = std::vector<std::string>();
         return jID;
         return jID;
     }
     }

+ 37 - 37
lib/src/ProcessorStandard.cpp

@@ -3,8 +3,9 @@
 namespace mdd {
 namespace mdd {
     ProcessorStandard::ProcessorStandard()
     ProcessorStandard::ProcessorStandard()
         :ProcessorBase(R"JSON(
         :ProcessorBase(R"JSON(
-        [{
-            "name":"priority",
+        {
+            "priority":
+            {
             "value":"manual",
             "value":"manual",
             "options":  [
             "options":  [
                             "manual",
                             "manual",
@@ -12,11 +13,13 @@ namespace mdd {
                             "dynamic",
                             "dynamic",
                             "time"                     
                             "time"                     
                         ]
                         ]
-        },{
-            "name":"iterations",
-            "value": -1
+            },
+            "iterations":
+            {
+                "value": -1
+            }
         }
         }
-        ])JSON")
+        )JSON")
     {
     {
         _priorityEvaluation = MANUAL;
         _priorityEvaluation = MANUAL;
         _maxIterations = -1;
         _maxIterations = -1;
@@ -30,43 +33,40 @@ namespace mdd {
         bool found = false;
         bool found = false;
         found = ProcessorBase::configure(config);
         found = ProcessorBase::configure(config);
         json config_parsed = json::parse(config);
         json config_parsed = json::parse(config);
-        if (!config_parsed.is_array())
+        json base_config = json::parse(ProcessorBase::getConfiguration());
+        if (config_parsed.contains("configure"))
         {
         {
-            return found;
+            config_parsed = config_parsed["configure"];
         }
         }
-        for (size_t i = 0; i < config_parsed.size(); i++)
+        if (config_parsed.contains("priority"))
         {
         {
-            if (config_parsed[i].contains("name"))
+            std::string op = config_parsed["priority"]["value"].get<std::string>();
+            found = true;
+            if (op == "manual") {
+                _priorityEvaluation = MANUAL;
+            }
+            else if (op == "static") {
+                _priorityEvaluation = STATIC;
+            }
+            else if (op == "dynamic") {
+                _priorityEvaluation = DYNAMIC;
+            }
+            else if (op == "time") {
+                _priorityEvaluation = TIME;
+            }
+            else
             {
             {
-                if (config_parsed[i]["name"].get<std::string>() == "priority")
-                {
-                    std::string op = config_parsed[i]["value"].get<std::string>();
-                    found = true;
-                    if (op == "manual") {
-                        _priorityEvaluation = MANUAL;
-                        break;
-                    }
-                    else if (op == "static") {
-                        _priorityEvaluation = STATIC;
-                    }
-                    else if (op == "dynamic") {
-                        _priorityEvaluation = DYNAMIC;
-                    }
-                    else if (op == "time") {
-                        _priorityEvaluation = TIME;
-                    }
-                    else {
-                        found = false;
-                    }
-                }
-                if (config_parsed[i]["name"].get<std::string>() == "iterations")
-                {
-                    _maxIterations = config_parsed[i]["value"].get<int>();
-                    found = true;
-                }
+                found = false;
             }
             }
+            base_config["configure"]["priority"]["value"] = _priorityEvaluation;
         }
         }
-
+        if (config_parsed.contains("iterations"))
+        {
+            _maxIterations = config_parsed["iterations"]["value"].get<int>();
+            found = true;
+            base_config["configure"]["iterations"]["value"] = _maxIterations;
+        }
+        ProcessorBase::configure(base_config.dump());
         return found;
         return found;
     }
     }
 
 

+ 1 - 0
lib/test/db/Neues Textdokument.txt

@@ -0,0 +1 @@
+C:\Users\Willi\Documents\projects\mdd\lib\test\db\materials.db