#ifndef _PANE_EVENT
#define _PANE_EVENT
#include <vector>
namespace Pane
{
/*
** EventHandler class (4 parameters)
*/
template<typename Return, typename Param1 = void, typename Param2 = void, typename Param3 = void, typename Param4 = void>
class EventHandler
{
public:
class EventClass
{
public:
virtual ~EventClass ()
{
}
virtual Return operator () (Param1, Param2, Param3, Param4) = 0;
};
template<typename Sender = void>
class Event : public EventClass
{
public:
typedef Return (Sender::*Method) (Param1, Param2, Param3, Param4);
/**/ Event (Sender* sender, Method method) :
method (method),
sender (sender)
{
}
virtual Return operator () (Param1 param1, Param2 param2, Param3 param3, Param4 param4)
{
return (this->sender->*method) (param1, param2, param3, param4);
}
private:
Method method;
Sender* sender;
};
/**/ ~EventHandler ();
void operator += (EventClass*);
bool operator () (Param1, Param2, Param3, Param4);
private:
typedef std::vector<EventClass*> Events;
Events events;
};
/*
** EventHandler class (3 parameters)
*/
template<typename Return, typename Param1, typename Param2, typename Param3>
class EventHandler<Return, Param1, Param2, Param3>
{
public:
class EventClass
{
public:
virtual ~EventClass ()
{
}
virtual Return operator () (Param1, Param2, Param3) = 0;
};
template<typename Sender = void>
class Event : public EventClass
{
public:
typedef Return (Sender::*Method) (Param1, Param2, Param3);
/**/ Event (Sender* sender, Method method) :
method (method),
sender (sender)
{
}
virtual Return operator () (Param1 param1, Param2 param2, Param3 param3)
{
return (this->sender->*method) (param1, param2, param3);
}
private:
Method method;
Sender* sender;
};
/**/ ~EventHandler ();
void operator += (EventClass*);
bool operator () (Param1, Param2, Param3);
private:
typedef std::vector<EventClass*> Events;
Events events;
};
/*
** EventHandler class (2 parameters)
*/
template<typename Return, typename Param1, typename Param2>
class EventHandler<Return, Param1, Param2>
{
public:
class EventClass
{
public:
virtual ~EventClass ()
{
}
virtual Return operator () (Param1, Param2) = 0;
};
template<typename Sender = void>
class Event : public EventClass
{
public:
typedef Return (Sender::*Method) (Param1, Param2);
/**/ Event (Sender* sender, Method method) :
method (method),
sender (sender)
{
}
virtual Return operator () (Param1 param1, Param2 param2)
{
return (this->sender->*method) (param1, param2);
}
private:
Method method;
Sender* sender;
};
/**/ ~EventHandler ();
void operator += (EventClass*);
bool operator () (Param1, Param2);
private:
typedef std::vector<EventClass*> Events;
Events events;
};
/*
** EventHandler class (1 parameter)
*/
template<typename Return, typename Param1>
class EventHandler<Return, Param1>
{
public:
class EventClass
{
public:
virtual ~EventClass ()
{
}
virtual Return operator () (Param1) = 0;
};
template<typename Sender = void>
class Event : public EventClass
{
public:
typedef Return (Sender::*Method) (Param1);
/**/ Event (Sender* sender, Method method) :
method (method),
sender (sender)
{
}
virtual Return operator () (Param1 param1)
{
return (this->sender->*method) (param1);
}
private:
Method method;
Sender* sender;
};
/**/ ~EventHandler ();
void operator += (EventClass*);
bool operator () (Param1);
private:
typedef std::vector<EventClass*> Events;
Events events;
};
/*
** EventHandler class (0 parameter)
*/
template<typename Return>
class EventHandler<Return>
{
public:
class EventClass
{
public:
virtual ~EventClass ()
{
}
virtual Return operator () () = 0;
};
template<typename Sender = void>
class Event : public EventClass
{
public:
typedef Return (Sender::*Method) ();
/**/ Event (Sender* sender, Method method) :
method (method),
sender (sender)
{
}
virtual Return operator () ()
{
return (this->sender->*method) ();
}
private:
Method method;
Sender* sender;
};
/**/ ~EventHandler ();
void operator += (EventClass*);
bool operator () ();
private:
typedef std::vector<EventClass*> Events;
Events events;
};
}
#include "eventHandler.hxx"
#endif // _PANE_EVENT