summaryrefslogtreecommitdiff
path: root/include/shared
diff options
context:
space:
mode:
authorchristian mueller <christian.ei.mueller@bmw.de>2012-03-05 22:49:12 +0100
committerchristian mueller <christian.ei.mueller@bmw.de>2012-03-05 22:49:12 +0100
commit8ced1dced5ae1fbc7356ec65c03e6e8201216155 (patch)
treeb4b19aac085948040d775e284455a0041b17e022 /include/shared
parent1b85f2410d1d644ff00284e78b1eeff6cfad2fc4 (diff)
downloadaudiomanager-8ced1dced5ae1fbc7356ec65c03e6e8201216155.tar.gz
* updated license headers
* updated documentation
Diffstat (limited to 'include/shared')
-rw-r--r--include/shared/CAmDbusWrapper.h39
-rw-r--r--include/shared/CAmDltWrapper.h98
-rw-r--r--include/shared/CAmSerializer.h60
-rw-r--r--include/shared/CAmSocketHandler.h135
4 files changed, 180 insertions, 152 deletions
diff --git a/include/shared/CAmDbusWrapper.h b/include/shared/CAmDbusWrapper.h
index 26131c2..c89220f 100644
--- a/include/shared/CAmDbusWrapper.h
+++ b/include/shared/CAmDbusWrapper.h
@@ -1,9 +1,9 @@
/** Copyright (c) 2012 GENIVI Alliance
* Copyright (c) 2012 BMW
*
- * \author Christian Mueller, BMW
+ * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
*
- * \section license
+ * \copyright
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
@@ -12,21 +12,24 @@
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
+ * \file CAmDbusWrapper.h
+ * For further information see http://www.genivi.org/.
*/
#ifndef DBUSWRAPPER_H_
#define DBUSWRAPPER_H_
-#include <config.h>
#include <dbus/dbus.h>
#include <string>
#include <list>
+#include "config.h"
#include "shared/CAmSocketHandler.h"
namespace am
{
+
/**
- * This wraps dbus and provides everything needed to anyone who wants to use dbus (including plugins)
+ * This wraps dbus and provides everything needed to anyone who wants to use dbus (including plugins). Works on the basis of CAmSocketHandler
*/
class CAmDbusWrapper
{
@@ -34,19 +37,7 @@ public:
CAmDbusWrapper(CAmSocketHandler* socketHandler);
virtual ~CAmDbusWrapper();
- /**
- * registers a callback that is entered as path below the main path.
- * The configuration of the mainpath is done via DBusConfiguration.h
- * @param vtable the vtable that holds a pointer to the callback that is called when the path is called from the dbus
- * @param path the name of the path
- * @param userdata pointer to the class that will handle the callback
- */
void registerCallback(const DBusObjectPathVTable* vtable, const std::string& path, void* userdata);
-
- /**
- * returns the dbus connection
- * @param connection pointer to the connection
- */
void getDBusConnection(DBusConnection*& connection) const;
static dbus_bool_t addWatch(DBusWatch *watch, void *userData);
@@ -70,7 +61,7 @@ public:
TAmShTimerCallBack<CAmDbusWrapper> pDbusTimerCallback;
private:
- static CAmDbusWrapper* mpReference;
+ static CAmDbusWrapper* mpReference; //!< reference to the dbus instance
static DBusHandlerResult cbRootIntrospection(DBusConnection *conn, DBusMessage *msg, void *reference);
dbus_bool_t addWatchDelegate(DBusWatch * watch, void* userData);
void removeWatchDelegate(DBusWatch *watch, void *userData);
@@ -78,13 +69,13 @@ private:
dbus_bool_t addTimeoutDelegate(DBusTimeout *timeout, void* userData);
void removeTimeoutDelegate(DBusTimeout *timeout, void* userData);
void toggleTimeoutDelegate(DBusTimeout *timeout, void* userData);
- DBusObjectPathVTable mObjectPathVTable;
- DBusConnection* mpDbusConnection;
- DBusError mDBusError;
- std::list<std::string> mListNodes;
- std::vector<sh_timerHandle_t*> mpListTimerhandles;
- CAmSocketHandler *mpSocketHandler;
- std::map<DBusWatch*, sh_pollHandle_t> mMapHandleWatch;
+ DBusObjectPathVTable mObjectPathVTable; //!< the vpathtable
+ DBusConnection* mpDbusConnection; //!< pointer to the dbus connection used
+ DBusError mDBusError; //!< dbuserror
+ std::list<std::string> mListNodes; //!< holds a list of all nodes of the dbus
+ std::vector<sh_timerHandle_t*> mpListTimerhandles; //!< pointer to the timer handles
+ CAmSocketHandler *mpSocketHandler; //!< pointer to the sockethandler
+ std::map<DBusWatch*, sh_pollHandle_t> mMapHandleWatch; //!< map to the handle watches
};
}
diff --git a/include/shared/CAmDltWrapper.h b/include/shared/CAmDltWrapper.h
index 0df9cde..f3d39cc 100644
--- a/include/shared/CAmDltWrapper.h
+++ b/include/shared/CAmDltWrapper.h
@@ -1,9 +1,9 @@
/** Copyright (c) 2012 GENIVI Alliance
* Copyright (c) 2012 BMW
*
- * \author Christian Mueller, BMW
+ * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
*
- * \section license
+ * \copyright
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
@@ -12,78 +12,78 @@
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
+ * \file CAmDltWrapper.h
+ * For further information see http://www.genivi.org/.
*/
#ifndef DLTWRAPPER_H_
#define DLTWRAPPER_H_
#include "config.h"
+#include <string>
#ifdef WITH_DLT
#include <dlt/dlt.h>
#else
-#include <stdint.h>
+#include <cstdint>
#include <sstream>
-namespace am {
-
-#define DLT_USER_BUF_MAX_SIZE 2048
-
-/**
- * This structure is used for every context used in an application.
- */
-typedef struct
+namespace am
{
- char contextID[4]; /**< context id */
- int32_t log_level_pos; /**< offset in user-application context field */
-} DltContext;
-/**
- * Definitions of DLT log level
- */
-typedef enum
-{
- DLT_LOG_DEFAULT = -1, /**< Default log level */
- DLT_LOG_OFF = 0x00, /**< Log level off */
- DLT_LOG_FATAL = 0x01, /**< fatal system error */
- DLT_LOG_ERROR = 0x02, /**< error with impact to correct functionality */
- DLT_LOG_WARN = 0x03, /**< warning, correct behaviour could not be ensured */
- DLT_LOG_INFO = 0x04, /**< informational */
- DLT_LOG_DEBUG = 0x05, /**< debug */
- DLT_LOG_VERBOSE = 0x06 /**< highest grade of information */
-} DltLogLevelType;
+#define DLT_USER_BUF_MAX_SIZE 2048
-/**
- * This structure is used for context data used in an application.
- */
-typedef struct
-{
- DltContext *handle; /**< pointer to DltContext */
- std::stringstream buffer; /**< buffer for building log message*/
- int32_t log_level; /**< log level */
- int32_t trace_status; /**< trace status */
- int32_t args_num; /**< number of arguments for extended header*/
- uint8_t mcnt; /**< message counter */
- char* context_description; /**< description of context */
-} DltContextData;
+ /**
+ * This structure is used for every context used in an application.
+ */
+ typedef struct
+ {
+ char contextID[4]; /**< context id */
+ int32_t log_level_pos; /**< offset in user-application context field */
+ }DltContext;
+
+ /**
+ * Definitions of DLT log level
+ */
+ typedef enum
+ {
+ DLT_LOG_DEFAULT = -1, /**< Default log level */
+ DLT_LOG_OFF = 0x00, /**< Log level off */
+ DLT_LOG_FATAL = 0x01, /**< fatal system error */
+ DLT_LOG_ERROR = 0x02, /**< error with impact to correct functionality */
+ DLT_LOG_WARN = 0x03, /**< warning, correct behaviour could not be ensured */
+ DLT_LOG_INFO = 0x04, /**< informational */
+ DLT_LOG_DEBUG = 0x05, /**< debug */
+ DLT_LOG_VERBOSE = 0x06 /**< highest grade of information */
+ }DltLogLevelType;
+
+ /**
+ * This structure is used for context data used in an application.
+ */
+ typedef struct
+ {
+ DltContext *handle; /**< pointer to DltContext */
+ std::stringstream buffer; /**< buffer for building log message*/
+ int32_t log_level; /**< log level */
+ int32_t trace_status; /**< trace status */
+ int32_t args_num; /**< number of arguments for extended header*/
+ uint8_t mcnt; /**< message counter */
+ char* context_description; /**< description of context */
+ }DltContextData;
#define DLT_DECLARE_CONTEXT(CONTEXT) \
DltContext CONTEXT;
-
#define DLT_IMPORT_CONTEXT(CONTEXT) \
extern DltContext CONTEXT;
#endif // WITH_DLT
-
-#include <string>
-
namespace am
{
/**
- * Wraps around the dlt wrapper. This class is instantiated as a singleton and offers a default
+ * Wraps around the dlt. This class is instantiated as a singleton and offers a default
* context (maincontext) that is registered to log to.
* Logging under the default context can simply be done with the logInfo/logError templates with up to 10 values at a time.
* For logging with a different context, you can use the log template. First register a context with registerContext.
@@ -114,8 +114,8 @@ public:
private:
CAmDltWrapper(const bool enableNoDLTDebug); //is private because of singleton pattern
#ifndef WITH_DLT
- template<class T> void appendNoDLT(T value);
- bool mEnableNoDLTDebug;
+ template<class T> void appendNoDLT(T value);
+ bool mEnableNoDLTDebug;
#endif
DltContext mDltContext; //!< the default context
DltContextData mDltContextData; //!< contextdata
@@ -129,7 +129,7 @@ private:
*/
inline CAmDltWrapper* getWrapper()
{
- return CAmDltWrapper::instance();
+ return (CAmDltWrapper::instance());
}
/**
diff --git a/include/shared/CAmSerializer.h b/include/shared/CAmSerializer.h
index 3cb8f5a..8a955df 100644
--- a/include/shared/CAmSerializer.h
+++ b/include/shared/CAmSerializer.h
@@ -1,9 +1,9 @@
/** Copyright (c) 2012 GENIVI Alliance
* Copyright (c) 2012 BMW
*
- * \author Christian Mueller, BMW
+ * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
*
- * \section license
+ * \copyright
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
@@ -12,6 +12,8 @@
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
+ * \file CAmSerializer.h
+ * For further information see http://www.genivi.org/.
*/
#ifndef CAMSERIALIZER_H_
@@ -74,7 +76,7 @@ private:
{
(void) pipe;
(*mInstance.*mFunction)();
- return true;
+ return (true);
};
};
@@ -99,7 +101,7 @@ private:
{
(void) pipe;
(*mInstance.*mFunction)(mArgument);
- return true;
+ return (true);
};
};
@@ -126,7 +128,7 @@ private:
{
(void) pipe;
(*mInstance.*mFunction)(mArgument, mArgument1);
- return true;
+ return (true);
};
};
@@ -157,7 +159,7 @@ private:
{
(void) pipe;
(*mInstance.*mFunction)(mArgument, mArgument1, mArgument2);
- return true;
+ return (true);
}
;
};
@@ -191,7 +193,7 @@ private:
{
(void) pipe;
(*mInstance.*mFunction)(mArgument, mArgument1, mArgument2, mArgument3);
- return true;
+ return (true);
}
;
};
@@ -220,13 +222,13 @@ private:
{
mRetval = (*mInstance.*mFunction)();
write(pipe[1], this, sizeof(this));
- return false;
+ return (false);
}
;
TretVal returnResults()
{
- return mRetval;
+ return (mRetval);
}
};
@@ -256,14 +258,14 @@ private:
{
mRetval = (*mInstance.*mFunction)(mArgument);
write(pipe[1], this, sizeof(this));
- return false;
+ return (false);
}
;
TretVal returnResults(Targ& argument)
{
argument = mArgument;
- return mRetval;
+ return (mRetval);
}
};
@@ -290,14 +292,14 @@ private:
{
mRetval = (*mInstance.*mFunction)(mArgument);
write(pipe[1], this, sizeof(this));
- return false;
+ return (false);
}
;
TretVal returnResults(Targ& argument)
{
argument = mArgument;
- return mRetval;
+ return (mRetval);
}
};
@@ -329,7 +331,7 @@ private:
{
mRetval = (*mInstance.*mFunction)(mArgument, mArgument1);
write(pipe[1], this, sizeof(this));
- return false;
+ return (false);
}
;
@@ -337,7 +339,7 @@ private:
{
argument = mArgument;
argument1 = mArgument1;
- return mRetval;
+ return (mRetval);
}
};
@@ -366,7 +368,7 @@ private:
{
mRetval = (*mInstance.*mFunction)(mArgument, mArgument1);
write(pipe[1], this, sizeof(this));
- return false;
+ return (false);
}
;
@@ -374,7 +376,7 @@ private:
{
argument = mArgument;
argument1 = mArgument1;
- return mRetval;
+ return (mRetval);
}
};
@@ -407,7 +409,7 @@ private:
{
mRetval = (*mInstance.*mFunction)(mArgument, mArgument1, mArgument2);
write(pipe[1], this, sizeof(this));
- return false;
+ return (false);
}
;
@@ -416,7 +418,7 @@ private:
argument = mArgument;
argument1 = mArgument1;
argument2 = mArgument2;
- return mRetval;
+ return (mRetval);
}
};
@@ -450,7 +452,7 @@ private:
{
mRetval = (*mInstance.*mFunction)(mArgument, mArgument1, mArgument2, mArgument3);
write(pipe[1], this, sizeof(this));
- return false;
+ return (false);
}
;
@@ -460,7 +462,7 @@ private:
argument1 = mArgument1;
argument2 = mArgument2;
argument3 = mArgument3;
- return mRetval;
+ return (mRetval);
}
};
@@ -494,7 +496,7 @@ private:
{
mRetval = (*mInstance.*mFunction)(mArgument, mArgument1, mArgument2, mArgument3, mArgument4);
write(pipe[1], this, sizeof(this));
- return false;
+ return (false);
}
;
@@ -505,7 +507,7 @@ private:
argument2 = mArgument2;
argument3 = mArgument3;
argument4 = mArgument4;
- return mRetval;
+ return (mRetval);
}
};
@@ -540,7 +542,7 @@ private:
{
mRetval = (*mInstance.*mFunction)(mArgument, mArgument1, mArgument2, mArgument3, mArgument4, mArgument5);
write(pipe[1], this, sizeof(this));
- return false;
+ return (false);
}
;
@@ -552,7 +554,7 @@ private:
argument3 = mArgument3;
argument4 = mArgument4;
argument5 = mArgument5;
- return mRetval;
+ return (mRetval);
}
};
@@ -913,8 +915,8 @@ public:
(void) handle;
(void) userData;
if (mListDelegatePoiters.empty())
- return false;
- return true;
+ return (false);
+ return (true);
}
bool dispatcherCallback(const sh_pollHandle_t handle, void* userData)
@@ -926,8 +928,8 @@ public:
if (delegatePoiter->call(mReturnPipe))
delete delegatePoiter;
if (mListDelegatePoiters.empty())
- return false;
- return true;
+ return (false);
+ return (true);
}
TAmShPollFired<CAmSerializer> receiverCallbackT;
diff --git a/include/shared/CAmSocketHandler.h b/include/shared/CAmSocketHandler.h
index e0ea797..8df6872 100644
--- a/include/shared/CAmSocketHandler.h
+++ b/include/shared/CAmSocketHandler.h
@@ -1,9 +1,9 @@
/** Copyright (c) 2012 GENIVI Alliance
* Copyright (c) 2012 BMW
*
- * \author Christian Mueller, BMW
+ * \author Christian Mueller, christian.ei.mueller@bmw.de BMW 2011,2012
*
- * \section license
+ * \copyright
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
@@ -12,6 +12,8 @@
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
* THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
+ * \file CAmSocketHandler.h
+ * For further information see http://www.genivi.org/.
*/
#ifndef SOCKETHANDLER_H_
@@ -34,22 +36,26 @@ static volatile sig_atomic_t gDispatchDone = 0; //this global is used to stop th
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 CAmShPollPrepare;
-class CAmShPollCheck;
-class CAmShPollFired;
-class CAmShPollDispatch;
-class CAmShTimerCallBack;
+class IAmShPollPrepare;
+class IAmShPollCheck;
+class IAmShPollFired;
+class IAmShPollDispatch;
+class IAmShTimerCallBack;
+/**
+ * The sockethandler implements a mainloop for the audiomanager. Plugins and different parts of the audiomanager add their filedescriptors to the handler to get called
+ * on communication of the filedescriptors.
+ */
class CAmSocketHandler
{
public:
CAmSocketHandler();
- virtual ~CAmSocketHandler();
+ ~CAmSocketHandler();
- am_Error_e addFDPoll(const int fd, const short event, CAmShPollPrepare *prepare, CAmShPollFired *fired, CAmShPollCheck *check, CAmShPollDispatch *dispatch, void* userData, sh_pollHandle_t& handle);
+ am_Error_e addFDPoll(const int fd, const short event, IAmShPollPrepare *prepare, IAmShPollFired *fired, IAmShPollCheck *check, IAmShPollDispatch *dispatch, void* userData, sh_pollHandle_t& handle);
am_Error_e removeFDPoll(const sh_pollHandle_t handle);
am_Error_e updateEventFlags(const sh_pollHandle_t handle, const short events);
- am_Error_e addTimer(const timespec timeouts, CAmShTimerCallBack*& callback, sh_timerHandle_t& handle, void* userData);
+ am_Error_e addTimer(const timespec timeouts, IAmShTimerCallBack*& callback, sh_timerHandle_t& handle, void* userData);
am_Error_e removeTimer(const sh_timerHandle_t handle);
am_Error_e restartTimer(const sh_timerHandle_t handle, const timespec timeouts);
am_Error_e stopTimer(const sh_timerHandle_t handle);
@@ -61,7 +67,7 @@ private:
sh_timerHandle_t handle; //!<the handle of the timer
timespec countdown; //!<the countdown, this value is decreased every time the timer is up
timespec timeout; //!<the original timer value
- CAmShTimerCallBack* callback; //!<the callbackfunction
+ IAmShTimerCallBack* callback; //!<the callbackfunction
void * userData; //!<saves a void pointer together with the rest.
};
@@ -71,17 +77,19 @@ private:
timespec param;
public:
CAmShSubstractTime(timespec param) :
- param(param){}
+ param(param)
+ {
+ }
void operator()(sh_timer_s& t) const;
};
struct sh_poll_s //!<struct that holds information about polls
{
sh_pollHandle_t handle; //!<handle to uniquely adress a filedesriptor
- CAmShPollPrepare *prepareCB;
- CAmShPollFired *firedCB;
- CAmShPollCheck *checkCB;
- CAmShPollDispatch *dispatchCB;
+ IAmShPollPrepare *prepareCB;
+ IAmShPollFired *firedCB;
+ IAmShPollCheck *checkCB;
+ IAmShPollDispatch *dispatchCB;
pollfd pollfdValue; //!<the array for polling the filedescriptors
void *userData; //!<userdata saved together with the callback.
};
@@ -95,7 +103,9 @@ private:
mListPollfd_t& mArray;
public:
CAmShCopyPollfd(mListPollfd_t& dest) :
- mArray(dest){}
+ mArray(dest)
+ {
+ }
void operator()(const sh_poll_s& row);
};
@@ -106,12 +116,12 @@ private:
timespec* insertTime(timespec& buffertime);
static bool compareCountdown(const sh_timer_s& a, const sh_timer_s& b)
{
- return (a.countdown.tv_sec == b.countdown.tv_sec) ? (a.countdown.tv_nsec < b.countdown.tv_nsec) : (a.countdown.tv_sec < b.countdown.tv_sec);
+ return ((a.countdown.tv_sec == b.countdown.tv_sec) ? (a.countdown.tv_nsec < b.countdown.tv_nsec) : (a.countdown.tv_sec < b.countdown.tv_sec));
}
static bool onlyFiredEvents(const pollfd& a)
{
- return a.revents == 0 ? false : true;
+ return (a.revents == 0 ? false : true);
}
//todo: maybe we could simplify mListActiveTimer to hold only the handle and the countdown ....
@@ -127,56 +137,68 @@ private:
};
/**
- * classic functor for the BasicTimerCallback
+ * prototype for the timer callback
*/
-class CAmShTimerCallBack
+class IAmShTimerCallBack
{
public:
virtual void Call(const sh_timerHandle_t handle, void* userData)=0;
- virtual ~CAmShTimerCallBack(){};
+ virtual ~IAmShTimerCallBack(){};
};
-class CAmShPollPrepare
+/**
+ * prototype for poll prepared callback
+ */
+class IAmShPollPrepare
{
public:
virtual void Call(const sh_pollHandle_t handle, void* userData)=0;
- virtual ~CAmShPollPrepare(){};
+ virtual ~IAmShPollPrepare(){};
};
-class CAmShPollFired
+/**
+ * prototype for poll fired callback
+ */
+class IAmShPollFired
{
public:
virtual void Call(const pollfd pollfd, const sh_pollHandle_t handle, void* userData)=0;
- virtual ~ CAmShPollFired(){};
+ virtual ~ IAmShPollFired(){};
};
-class CAmShPollCheck
+/**
+ * prototype for poll check callback
+ */
+class IAmShPollCheck
{
public:
virtual bool Call(const sh_pollHandle_t handle, void* userData)=0;
- virtual ~ CAmShPollCheck(){};
+ virtual ~ IAmShPollCheck(){};
};
-class CAmShPollDispatch
+/**
+ * prototype for dispatch callback
+ */
+class IAmShPollDispatch
{
public:
virtual bool Call(const sh_pollHandle_t handle, void* userData)=0;
- virtual ~ CAmShPollDispatch() {};
+ virtual ~ IAmShPollDispatch(){};
};
/**
* template to create the functor for a class
*/
-template<class TClass> class TAmShTimerCallBack: public CAmShTimerCallBack
+template<class TClass> class TAmShTimerCallBack: public IAmShTimerCallBack
{
private:
TClass* mInstance;
void (TClass::*mFunction)(sh_timerHandle_t handle, void* userData);
public:
- TAmShTimerCallBack(TClass* instance, void(TClass::*function)(sh_timerHandle_t handle, void* userData)) :
- mInstance(instance),//
- mFunction(function) {};
+ TAmShTimerCallBack(TClass* instance, void (TClass::*function)(sh_timerHandle_t handle, void* userData)) :
+ mInstance(instance), //
+ mFunction(function){};
virtual void Call(sh_timerHandle_t handle, void* userData)
{
@@ -185,74 +207,87 @@ public:
};
/**
- * template to create the functor for a class
+ * template for a callback
*/
-template<class TClass> class TAmShPollPrepare: public CAmShPollPrepare
+template<class TClass> class TAmShPollPrepare: public IAmShPollPrepare
{
private:
TClass* mInstance;
void (TClass::*mFunction)(const sh_timerHandle_t handle, void* userData);
public:
- TAmShPollPrepare(TClass* instance, void(TClass::*function)(const sh_timerHandle_t handle, void* userData)) :
+ TAmShPollPrepare(TClass* instance, void (TClass::*function)(const sh_timerHandle_t handle, void* userData)) :
mInstance(instance), //
mFunction(function){};
virtual void Call(const sh_timerHandle_t handle, void* userData)
{
(*mInstance.*mFunction)(handle, userData);
- };
+ }
+ ;
};
-template<class TClass> class TAmShPollFired: public CAmShPollFired
+/**
+ * template for a callback
+ */
+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)) :
+ 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 CAmShPollCheck
+/**
+ * template for a callback
+ */
+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)) :
+ 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);
- };
+ return ((*mInstance.*mFunction)(handle, userData));
+ }
+ ;
};
-template<class TClass> class TAmShPollDispatch: public CAmShPollDispatch
+/**
+ * template for a callback
+ */
+template<class TClass> class TAmShPollDispatch: public IAmShPollDispatch
{
private:
TClass* mInstance;
bool (TClass::*mFunction)(const sh_pollHandle_t handle, void* userData);
public:
- TAmShPollDispatch(TClass* instance, bool(TClass::*function)(const sh_pollHandle_t handle, void* userData)) :
+ TAmShPollDispatch(TClass* instance, bool (TClass::*function)(const sh_pollHandle_t handle, void* userData)) :
mInstance(instance), //
- mFunction(function) {};
+ mFunction(function){};
virtual bool Call(const sh_pollHandle_t handle, void* userData)
{
- return (*mInstance.*mFunction)(handle, userData);
- };
+ return ((*mInstance.*mFunction)(handle, userData));
+ }
+ ;
};
} /* namespace am */
#endif /* SOCKETHANDLER_H_ */