From 3fbec27ec4026b452d6bbb90d53821d46bb64b0b Mon Sep 17 00:00:00 2001
From: Carl Philipp Klemm <philipp@uvos.xyz>
Date: Mon, 6 May 2024 17:04:40 +0200
Subject: [PATCH] model: add method to get parameter uniquie names

---
 componant/componant.cpp |  5 -----
 eisgenerator/model.h    |  7 +++++++
 model.cpp               | 15 +++++++++++++++
 3 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/componant/componant.cpp b/componant/componant.cpp
index f7317a4..e517608 100644
--- a/componant/componant.cpp
+++ b/componant/componant.cpp
@@ -167,15 +167,10 @@ bool Componant::isValidComponantChar(char componantCh)
 	switch(componantCh)
 	{
 		case Cap::staticGetComponantChar():
-			return true;
 		case Resistor::staticGetComponantChar():
-			return true;
 		case Inductor::staticGetComponantChar():
-			return true;
 		case Cpe::staticGetComponantChar():
-			return true;
 		case Warburg::staticGetComponantChar():
-			return true;
 		case FiniteTransmitionline::staticGetComponantChar():
 			return true;
 		default:
diff --git a/eisgenerator/model.h b/eisgenerator/model.h
index ef2cef0..230a8a7 100644
--- a/eisgenerator/model.h
+++ b/eisgenerator/model.h
@@ -214,6 +214,13 @@ public:
 	*/
 	std::vector<Range> getDefaultParameters();
 
+	/**
+	* @brief Gets the names of all the parameters in this model
+	*
+	* @return The names of all the parameters in this model.
+	*/
+	std::vector<std::string> getParameterNames();
+
 	/**
 	* @brief Gets the total number of parameters used by all the circuit elements in this model.
 	*
diff --git a/model.cpp b/model.cpp
index 6dedc7d..6bb8de1 100644
--- a/model.cpp
+++ b/model.cpp
@@ -239,6 +239,21 @@ std::vector<Range> Model::getDefaultParameters()
 	return out;
 }
 
+std::vector<std::string> Model::getParameterNames()
+{
+	std::vector<Componant*> flatComponants = getFlatComponants();
+
+	std::vector<std::string> out;
+	out.reserve(getParameterCount());
+	for(Componant* componant : flatComponants)
+	{
+		for(size_t i = 0; i < componant->paramCount(); ++i)
+			out.push_back(componant->getUniqueName() + "_" + std::to_string(i));
+	}
+
+	return out;
+}
+
 DataPoint Model::execute(fvalue omega, size_t index)
 {
 	if(_model)
-- 
GitLab