mirror of
https://github.com/resiprocate/resiprocate.git
synced 2026-01-12 00:05:02 +08:00
41 lines
958 B
C++
41 lines
958 B
C++
#if !defined BindPointerAction_hxx
|
|
#define BindPointerAction_hxx
|
|
|
|
#include "rutil/Data.hxx"
|
|
#include <functional>
|
|
#include "tfm/ActionBase.hxx"
|
|
#include <XsLib/h/CXsRefPtr.h>
|
|
|
|
class TestEndPoint;
|
|
|
|
template<class T, class E>
|
|
class BindPointerAction : public ActionBase
|
|
{
|
|
public:
|
|
explicit BindPointerAction(TestEndPoint* tua, resip::Data action, T& ptr) :
|
|
mTestEndPoint(tua),
|
|
mActionName(action),
|
|
mPtr(ptr)
|
|
{}
|
|
virtual ~BindPointerAction() {}
|
|
|
|
virtual void operator()(std::shared_ptr<Event> event)
|
|
{
|
|
auto e = std::dynamic_pointer_cast<E, Event>(event);
|
|
|
|
resip_assert(e.get());
|
|
|
|
mPtr->bind(e);
|
|
}
|
|
|
|
virtual void operator()() { resip_assert(0); }
|
|
|
|
virtual resip::Data toString() const { return mActionName; }
|
|
|
|
protected:
|
|
TestEndPoint* mTestEndPoint;
|
|
resip:: Data mActionName;
|
|
T& mPtr;
|
|
};
|
|
#endif
|