0

Hi,
in my code the class CFactory has a non-type template parameter TStaticMemberFct which is a static function of a different class that should get called when Wrapper() is called via a CInterruptDelegate object.
But it seems that Wrapper() gets already called when it is passed as the CInterruptDelegate constructor argument. Is there a way to avoid this?

CFactory:

template<void (*TStaticMemberFct)()>
class CFactory
{
  private:
    static void Wrapper(void* object)
    {
      TStaticMemberFct();
    }

  public:
    static CInterruptDelegate Bind()
    {
      return CInterruptDelegate(&CFactory::Wrapper, 0);
    }
};
class CInterruptDelegate 
{ 
  public:
    typedef void (*typeFctPtr)(void*);

    CInterruptDelegate(typeFctPtr f_tfnWrapper, void* f_pvSubscriber) 
      : m_tfnWrapper(f_tfnWrapper), m_pvSubscriber(f_pvSubscriber) 
    {
    }

    void operator () () const
    {
      (*m_tfnWrapper)(m_pvSubscriber);
    }

    void IsrCall(void)
    {
      (*m_tfnWrapper)(m_pvSubscriber);
    }

  private:
    typeFctPtr m_tfnWrapper;
    void* m_pvSubscriber;
};

Thanks in advance,
Mirco

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Narue
0

I don't have that problem at all using your classes. Can you post a complete program that exhibits the issue?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.