Newer
Older
Import / projects / Gameloft / bne_lib / code / Utils / CallbackHolder.h
@John John on 29 Dec 2020 547 bytes bulk import from macbookpro checkouts
#ifndef __CALLBACK_DELAYINVOKEHOLDER__
#define __CALLBACK_DELAYINVOKEHOLDER__

#include <functional>
#include "Callback.h"

template <class S, class T, class A>
class CallbackHolder : public Callback
{
public:
  CallbackHolder(T *host, A argument, S(T::*memberFunction)(A))
    : m_host(host)
    , m_argument(argument)
    , m_f(std::mem_fun(memberFunction))
  {}

  ~CallbackHolder(){} // not to be subclassed for now

  void Invoke(){ m_f(m_host, m_argument); }

private:
  T* m_host;
  A m_argument;
  std::mem_fun1_t<S, T, A> m_f;
};

#endif