initial commit

This commit is contained in:
Blue 2018-08-05 00:46:25 +03:00 committed by Юрий Губич
commit 4b60ece582
327 changed files with 28286 additions and 0 deletions

56
lib/wDispatcher/handler.h Normal file
View file

@ -0,0 +1,56 @@
#ifndef HANDLER_H
#define HANDLER_H
#include "wType/address.h"
#include "wType/event.h"
namespace W
{
template<typename InstanceType, typename MethodType>
class ImplHandle;
class Handler
{
public:
Handler(const Address& p_rel_addr);
virtual ~Handler();
template<typename InstanceType, typename MethodType>
static Handler* create(const Address& addr, InstanceType* inst, MethodType mth)
{
return new ImplHandle<InstanceType, MethodType>(addr, inst, mth);
}
const W::Address& getAddress() const;
virtual void pass(const W::Event& ev) const = 0;
private:
W::Address address;
};
template<typename InstanceType, typename MethodType>
class ImplHandle: public Handler
{
public:
ImplHandle(const Address& p_rel_addr, InstanceType *p_inst, MethodType p_mth):
Handler(p_rel_addr),
inst(p_inst),
mth(p_mth)
{}
~ImplHandle() {}
void pass(const W::Event& ev) const
{
( ( *inst ).*mth )(ev);
}
private:
InstanceType* inst;
MethodType mth;
};
}
#endif // HANDLER_H