#define MAX_NS 1000000000L
-static volatile sig_atomic_t gDispatchDone = 1; //this global is used to stop the mainloop
-
typedef uint16_t sh_timerHandle_t; //!<this is a handle for a timer to be used with the SocketHandler
typedef uint16_t sh_pollHandle_t; //!<this is a handle for a filedescriptor to be used with the SocketHandler
class CAmSocketHandler
{
public:
+ template<class TClass> class TAmShPollFired: public IAmShPollFired
+ {
+ private:
+ TClass* mInstance;
+ void (TClass::*mFunction)(const pollfd pollfd, const sh_pollHandle_t handle, void* userData);
+
+ public:
+ TAmShPollFired(TClass* instance, void (TClass::*function)(const pollfd pollfd, const sh_pollHandle_t handle, void* userData)) :
+ mInstance(instance), //
+ mFunction(function) {};
+
+ virtual void Call(const pollfd pollfd, const sh_pollHandle_t handle, void* userData)
+ {
+ (*mInstance.*mFunction)(pollfd, handle, userData);
+ };
+ };
+
+ template<class TClass> class TAmShPollCheck: public IAmShPollCheck
+ {
+ private:
+ TClass* mInstance;
+ bool (TClass::*mFunction)(const sh_pollHandle_t handle, void* userData);
+
+ public:
+ TAmShPollCheck(TClass* instance, bool (TClass::*function)(const sh_pollHandle_t handle, void* userData)) :
+ mInstance(instance), //
+ mFunction(function) {};
+
+ virtual bool Call(const sh_pollHandle_t handle, void* userData)
+ {
+ return ((*mInstance.*mFunction)(handle, userData));
+ };
+ };
+
CAmSocketHandler();
~CAmSocketHandler();
am_Error_e stopTimer(const sh_timerHandle_t handle);
void start_listenting();
void stop_listening();
+ void exit_mainloop();
+ void receiverCallback(const pollfd pollfd, const sh_pollHandle_t handle, void* userData)
+ {
+ (void) pollfd;
+ (void) handle;
+ (void) userData;
+ };
+ bool checkerCallback(const sh_pollHandle_t handle, void* userData)
+ {
+ (void) handle;
+ (void) userData;
+ return (false);
+ };
+
+ TAmShPollFired<CAmSocketHandler> receiverCallbackT;
+ TAmShPollCheck<CAmSocketHandler> checkerCallbackT;
+
private:
+
+ static CAmSocketHandler* mInstance;
+ int mPipe[2];
+ int mDispatchDone; //this starts / stops the mainloop
struct sh_timer_s //!<struct that holds information of timers
{
sh_timerHandle_t handle; //!<the handle of the timer