<?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[Funktionspointer in Array von Klassenfunktionen]]></title><description><![CDATA[<p>Hallo miteinander</p>
<p>Ich habe ein kleines Problem: Ich möchte von einer C-Datei aus bestimmte Funktionen aufrufen können. Diese Funktionen sind variabel und sollen &quot;registriert&quot; werden. Aber leider stehe ich momentan auf dem Schlauch:</p>
<p>irq.h</p>
<pre><code>class CIRQHandling
{  
	typedef void (*m_pu32FunctionPtr)(sf_uint32 eIRQSource);

    private:  
		m_pu32FunctionPtr m__au32IRQHandler[35];

    /// Functions
    public:
		CIRQHandling();
		~CIRQHandling();

		sf_bool bAddIRQHandler(m_pu32FunctionPtr pIRQH, sf_uint32 eIRQSource);
		sf_bool bRemoveIRQHandler(sf_uint32 eIRQSource);
		static void IRQHandler(sf_uint32 eIRQSource);

};
</code></pre>
<p>irq.cpp<br />
Hier sollen sich die anderen Klassen für die entsprechenden Interrupts registrieren können. IRQHandler soll dann von der c-Funktion aus aufgerufen werden.</p>
<pre><code>sf_bool CIRQHandling::bAddIRQHandler(m_pu32FunctionPtr pIRQH, sf_uint32 eIRQSource)
{
	if (m__au32IRQHandler[eIRQSource] == NULL)
	{
		m__au32IRQHandler[eIRQSource] = pIRQH;
		return 1;
	}
	else
	{
		return 0;
	}
}
sf_bool CIRQHandling::bRemoveIRQHandler(sf_uint32 eIRQSource)
{
	m__au32IRQHandler[eIRQSource] = NULL;
	return 1;
}

void CIRQHandling::IRQHandler(sf_uint32 eIRQSource)
{
	CIRQHandling* CirqHandler;
	CirqHandler-&gt;m__au32IRQHandler[eIRQSource](eIRQSource);
}
</code></pre>
<p>interrupt.c</p>
<pre><code>void SysTick_Handler(void)
{
	CIRQHandling::IRQHandler(2);
}
</code></pre>
<p>main.cpp<br />
Zum Testen irgend eine Klasse mit einer Funktion die bei der irq-Klasse registert und dann durchgeschlauft auch aufgerufen werden soll, sobald die Funktion SysTick_Handler in der obigen Datei ausgeführt wird.</p>
<pre><code>class testclass
{
	public:
		void hallo(void)
		{
			//...
		}
};

int main(void)
{
	(void) irqTest.bAddIRQHandler(&amp;tester::hallo, eetUSART1);
	while(1)
	{
	}
	return 0;
}
</code></pre>
<p>Momentan bekomme ich das Registrieren irgenwie nicht so hin. Oder habt ihr noch konkrete Vorschläge?<br />
Besten Dank für die Hilfe<br />
MFG<br />
P51D</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/315488/funktionspointer-in-array-von-klassenfunktionen</link><generator>RSS for Node</generator><lastBuildDate>Thu, 30 Jul 2026 19:12:05 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/315488.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 04 Apr 2013 07:09:43 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Funktionspointer in Array von Klassenfunktionen on Thu, 04 Apr 2013 07:09:43 GMT]]></title><description><![CDATA[<p>Hallo miteinander</p>
<p>Ich habe ein kleines Problem: Ich möchte von einer C-Datei aus bestimmte Funktionen aufrufen können. Diese Funktionen sind variabel und sollen &quot;registriert&quot; werden. Aber leider stehe ich momentan auf dem Schlauch:</p>
<p>irq.h</p>
<pre><code>class CIRQHandling
{  
	typedef void (*m_pu32FunctionPtr)(sf_uint32 eIRQSource);

    private:  
		m_pu32FunctionPtr m__au32IRQHandler[35];

    /// Functions
    public:
		CIRQHandling();
		~CIRQHandling();

		sf_bool bAddIRQHandler(m_pu32FunctionPtr pIRQH, sf_uint32 eIRQSource);
		sf_bool bRemoveIRQHandler(sf_uint32 eIRQSource);
		static void IRQHandler(sf_uint32 eIRQSource);

};
</code></pre>
<p>irq.cpp<br />
Hier sollen sich die anderen Klassen für die entsprechenden Interrupts registrieren können. IRQHandler soll dann von der c-Funktion aus aufgerufen werden.</p>
<pre><code>sf_bool CIRQHandling::bAddIRQHandler(m_pu32FunctionPtr pIRQH, sf_uint32 eIRQSource)
{
	if (m__au32IRQHandler[eIRQSource] == NULL)
	{
		m__au32IRQHandler[eIRQSource] = pIRQH;
		return 1;
	}
	else
	{
		return 0;
	}
}
sf_bool CIRQHandling::bRemoveIRQHandler(sf_uint32 eIRQSource)
{
	m__au32IRQHandler[eIRQSource] = NULL;
	return 1;
}

void CIRQHandling::IRQHandler(sf_uint32 eIRQSource)
{
	CIRQHandling* CirqHandler;
	CirqHandler-&gt;m__au32IRQHandler[eIRQSource](eIRQSource);
}
</code></pre>
<p>interrupt.c</p>
<pre><code>void SysTick_Handler(void)
{
	CIRQHandling::IRQHandler(2);
}
</code></pre>
<p>main.cpp<br />
Zum Testen irgend eine Klasse mit einer Funktion die bei der irq-Klasse registert und dann durchgeschlauft auch aufgerufen werden soll, sobald die Funktion SysTick_Handler in der obigen Datei ausgeführt wird.</p>
<pre><code>class testclass
{
	public:
		void hallo(void)
		{
			//...
		}
};

int main(void)
{
	(void) irqTest.bAddIRQHandler(&amp;tester::hallo, eetUSART1);
	while(1)
	{
	}
	return 0;
}
</code></pre>
<p>Momentan bekomme ich das Registrieren irgenwie nicht so hin. Oder habt ihr noch konkrete Vorschläge?<br />
Besten Dank für die Hilfe<br />
MFG<br />
P51D</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2312281</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2312281</guid><dc:creator><![CDATA[P51D]]></dc:creator><pubDate>Thu, 04 Apr 2013 07:09:43 GMT</pubDate></item><item><title><![CDATA[Reply to Funktionspointer in Array von Klassenfunktionen on Thu, 04 Apr 2013 07:20:08 GMT]]></title><description><![CDATA[<p>Nicht statische Memberfunktionen brauchen einen this Pointer, den du so nicht liefern kannst. Wenn du std::function und std::bind benutzt (oder boost für nicht c++11 Compiler) wird es funktionieren.</p>
<p>Deine IRQHandler Funktion wird allerdings auch nur abstürzen, wenn du sie wirklich so wie hier gepostet implementiert hast.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2312285</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2312285</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Thu, 04 Apr 2013 07:20:08 GMT</pubDate></item><item><title><![CDATA[Reply to Funktionspointer in Array von Klassenfunktionen on Thu, 04 Apr 2013 07:30:42 GMT]]></title><description><![CDATA[<p>manni66 schrieb:</p>
<blockquote>
<p>Deine IRQHandler Funktion wird allerdings auch nur abstürzen, wenn du sie wirklich so wie hier gepostet implementiert hast.</p>
</blockquote>
<p>Wie sollte es dann aussehen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2312293</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2312293</guid><dc:creator><![CDATA[P51D]]></dc:creator><pubDate>Thu, 04 Apr 2013 07:30:42 GMT</pubDate></item><item><title><![CDATA[Reply to Funktionspointer in Array von Klassenfunktionen on Thu, 04 Apr 2013 09:27:51 GMT]]></title><description><![CDATA[<p>P51D schrieb:</p>
<blockquote>
<p>manni66 schrieb:</p>
<blockquote>
<p>Deine IRQHandler Funktion wird allerdings auch nur abstürzen, wenn du sie wirklich so wie hier gepostet implementiert hast.</p>
</blockquote>
<p>Wie sollte es dann aussehen?</p>
</blockquote>
<p>Hast du überhaupt verstanden was daran falsch ist?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2312335</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2312335</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Thu, 04 Apr 2013 09:27:51 GMT</pubDate></item></channel></rss>