<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Entwurfsidee?]]></title><description><![CDATA[<p>hi,</p>
<p>ich bin nicht glücklich mit dem Code hier ich will alle pairs von den maps in CWidget holen. Dachte ich setz immer was ich brauch mit ein enum Typ und hol mir die Werte. Um das noch zu vereinfachen wollte ich daraus noch ne Schleife basteln ,die nicht funktioniert, naja ein eher kläglicher Versuch.<br />
Aber vielleicht hat der Entwurf schon ein falschen Ansatz hab auch schon mal versucht das ganze mit templates zu realisieren aber irgendwie wird es dann für mich zu unübersichtlich.<br />
Wär nett wenn jemand wüsste wie man den Code vereinfachen könnte.</p>
<pre><code class="language-cpp">enum propertyType {Combo, Bool, File, Text, Digit};

class CWidget
{
public:
	CWidget();
	void setTypeProperty(propertyType);
	void firstProperty();
	void nextProperty();
	bool isLastProperty();

	void setComboProperty(std::string, std::string);
	void setBoolProperty(std::string, bool);
	void setFileProperty(std::string, std::string);
	void setTextProperty(std::string, std::string);
	void setDigitProperty(std::string, int);

	std::string getNameProperty();
	std::string getComboProperty(std::string);
	bool 	    getBoolProperty(std::string);
	std::string getFileProperty(std::string);
	std::string getTextProperty(std::string);
	int 	    getDigitProperty(std::string);

private:
	propertyType m_type;
	std::map&lt;std::string, std::string&gt; m_comboProperties;
	std::map&lt;std::string, bool&gt; 	   m_boolProperties;
	std::map&lt;std::string, std::string&gt; m_fileProperties;
	std::map&lt;std::string, std::string&gt; m_textProperties;
	std::map&lt;std::string, int&gt; 	   m_digitProperties;

	std::map&lt;std::string, std::string&gt;::iterator m_it_comboProperties;
	std::map&lt;std::string, bool&gt;::iterator 	     m_it_boolProperties;
	std::map&lt;std::string, std::string&gt;::iterator m_it_fileProperties;
	std::map&lt;std::string, std::string&gt;::iterator m_it_textProperties;
	std::map&lt;std::string, int&gt;::iterator 	     m_it_digitProperties;
};
</code></pre>
<pre><code class="language-cpp">bashWidgets::propertyType type;

 for(type=Bool; type&lt;Digit; type++)
  {
        bashWidget-&gt;firstProperty();
		while (!bashWidget-&gt;isLastProperty())
		{
		  string name = bashWidget-&gt;getNameProperty();

		      switch (type)
			{
			case Combo: //addComboItem(bashWidget-&gt;getNameProperty(), bashWidget-&gt;getComboProperty());
				break;
			case Bool: addCheckItem(name, bashWidget-&gt;getBoolProperty(name));
				break;
			case File: //
				break;
			case Text: addTextItem(name, bashWidget-&gt;getTextProperty(name));
				break;
			case Digit: addSpinItem(name, bashWidget-&gt;getDigitProperty(name));
				break;
			}
		   bashWidget-&gt;nextProperty();
		}
   bashWidget-&gt;setTypeProperty(type);
  }
</code></pre>
<p>MfG<br />
xmarvel</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/119741/entwurfsidee</link><generator>RSS for Node</generator><lastBuildDate>Sat, 22 Aug 2026 02:27:28 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/119741.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 05 Sep 2005 08:40:42 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Entwurfsidee? on Mon, 05 Sep 2005 08:40:42 GMT]]></title><description><![CDATA[<p>hi,</p>
<p>ich bin nicht glücklich mit dem Code hier ich will alle pairs von den maps in CWidget holen. Dachte ich setz immer was ich brauch mit ein enum Typ und hol mir die Werte. Um das noch zu vereinfachen wollte ich daraus noch ne Schleife basteln ,die nicht funktioniert, naja ein eher kläglicher Versuch.<br />
Aber vielleicht hat der Entwurf schon ein falschen Ansatz hab auch schon mal versucht das ganze mit templates zu realisieren aber irgendwie wird es dann für mich zu unübersichtlich.<br />
Wär nett wenn jemand wüsste wie man den Code vereinfachen könnte.</p>
<pre><code class="language-cpp">enum propertyType {Combo, Bool, File, Text, Digit};

class CWidget
{
public:
	CWidget();
	void setTypeProperty(propertyType);
	void firstProperty();
	void nextProperty();
	bool isLastProperty();

	void setComboProperty(std::string, std::string);
	void setBoolProperty(std::string, bool);
	void setFileProperty(std::string, std::string);
	void setTextProperty(std::string, std::string);
	void setDigitProperty(std::string, int);

	std::string getNameProperty();
	std::string getComboProperty(std::string);
	bool 	    getBoolProperty(std::string);
	std::string getFileProperty(std::string);
	std::string getTextProperty(std::string);
	int 	    getDigitProperty(std::string);

private:
	propertyType m_type;
	std::map&lt;std::string, std::string&gt; m_comboProperties;
	std::map&lt;std::string, bool&gt; 	   m_boolProperties;
	std::map&lt;std::string, std::string&gt; m_fileProperties;
	std::map&lt;std::string, std::string&gt; m_textProperties;
	std::map&lt;std::string, int&gt; 	   m_digitProperties;

	std::map&lt;std::string, std::string&gt;::iterator m_it_comboProperties;
	std::map&lt;std::string, bool&gt;::iterator 	     m_it_boolProperties;
	std::map&lt;std::string, std::string&gt;::iterator m_it_fileProperties;
	std::map&lt;std::string, std::string&gt;::iterator m_it_textProperties;
	std::map&lt;std::string, int&gt;::iterator 	     m_it_digitProperties;
};
</code></pre>
<pre><code class="language-cpp">bashWidgets::propertyType type;

 for(type=Bool; type&lt;Digit; type++)
  {
        bashWidget-&gt;firstProperty();
		while (!bashWidget-&gt;isLastProperty())
		{
		  string name = bashWidget-&gt;getNameProperty();

		      switch (type)
			{
			case Combo: //addComboItem(bashWidget-&gt;getNameProperty(), bashWidget-&gt;getComboProperty());
				break;
			case Bool: addCheckItem(name, bashWidget-&gt;getBoolProperty(name));
				break;
			case File: //
				break;
			case Text: addTextItem(name, bashWidget-&gt;getTextProperty(name));
				break;
			case Digit: addSpinItem(name, bashWidget-&gt;getDigitProperty(name));
				break;
			}
		   bashWidget-&gt;nextProperty();
		}
   bashWidget-&gt;setTypeProperty(type);
  }
</code></pre>
<p>MfG<br />
xmarvel</p>
]]></description><link>https://www.c-plusplus.net/forum/post/865178</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/865178</guid><dc:creator><![CDATA[xmarvel]]></dc:creator><pubDate>Mon, 05 Sep 2005 08:40:42 GMT</pubDate></item><item><title><![CDATA[Reply to Entwurfsidee? on Tue, 06 Sep 2005 05:57:15 GMT]]></title><description><![CDATA[<p>Mach eine Klasse Property leite davon TextProperty, BoolProperty, ... ab. Dann kannst du das Ganze in ein Set stecken und nicht in X Maps.</p>
<p>Außerdem kannst du dir noch Zusatzinfos halten wenn das mal notwendig sein sollte....</p>
]]></description><link>https://www.c-plusplus.net/forum/post/865858</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/865858</guid><dc:creator><![CDATA[Mathias]]></dc:creator><pubDate>Tue, 06 Sep 2005 05:57:15 GMT</pubDate></item><item><title><![CDATA[Reply to Entwurfsidee? on Tue, 06 Sep 2005 13:24:19 GMT]]></title><description><![CDATA[<p>vielleicht hab ich dich nicht richtig verstanden hab mal versucht das umsetzen und die Sachen markiert wo ich nicht weiss wie man das machen soll.</p>
<pre><code class="language-cpp">class CProperty
{
 public:
	virtual ~CProperty();
	virtual void setProperty(std::string, ???)=0; // da kann ich ja nicht den genauen Typ angeben
	virtual ??? getProperty(std::string)=0; //hier genau so
};

class CTextProperty : public CProperty
{
 public:
 	void setProperty(std::string, std::string);
	std::string getProperty(std::string);
};

class CDigitProperty : public CProperty
{
 public:
	void setProperty(std::string, int);
	int getProperty(std::string);
};
// ... usw

class CWidget
{
 public:
	void firstProperty();
	void nextProperty();
	bool isLastProperty();

	void setProperty(std::string, CProperty);
	CProperty getProperty();
 private:
	std::vector&lt;CProperty&gt; m_storage;
};
</code></pre>
<p>MfG<br />
xmarvel</p>
]]></description><link>https://www.c-plusplus.net/forum/post/866256</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/866256</guid><dc:creator><![CDATA[xmarvel]]></dc:creator><pubDate>Tue, 06 Sep 2005 13:24:19 GMT</pubDate></item><item><title><![CDATA[Reply to Entwurfsidee? on Tue, 06 Sep 2005 13:41:55 GMT]]></title><description><![CDATA[<p>Ja in der Art. <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>(Naja... da alle Properties einen Namen haben würde ich den über die Basisklasse mit Get und Set-Funktionen zugreifbar machen und den Wert durch separate Funktionen in den abgeleiteten Klassen. (Vielleicht in der oberklasse generell in einen String für ne Text-Ausgabe?)<br />
Außerdem würde ich den Typ des Property durch eine virtuelle Funktion,<br />
die von den abgeleiteten Klassen immer brav überschrieben wird abfragbar machen.</p>
<p>Das hier wäre auch besser:</p>
<pre><code class="language-cpp">CProperty * firstProperty();
   CProperty * nextProperty();
</code></pre>
<p>Geben entweder das Property zurück oder falls das Ende erreicht ist NULL.)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/866294</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/866294</guid><dc:creator><![CDATA[Mathias]]></dc:creator><pubDate>Tue, 06 Sep 2005 13:41:55 GMT</pubDate></item></channel></rss>