summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchristian mueller <christian.ei.mueller@bmw.de>2012-09-10 17:41:30 +0200
committerchristian mueller <christian.ei.mueller@bmw.de>2012-09-12 09:19:41 +0200
commit174df12c9b14cbce0bdad7c197f80ce7efd55cb6 (patch)
tree39f847ed308f0e08b8ed6bf23fa97a3e61ea880f
parenta9771fa406089c5c8b032e558afb84108d078c51 (diff)
downloadaudiomanager-174df12c9b14cbce0bdad7c197f80ce7efd55cb6.tar.gz
* [GAM-91] make CAmSerializer calls with references safer3.0
Signed-off-by: christian mueller <christian.ei.mueller@bmw.de>
-rw-r--r--AudioManagerDaemon/src/CAmDatabaseObserver.cpp10
-rw-r--r--include/shared/CAmSerializer.h154
2 files changed, 158 insertions, 6 deletions
diff --git a/AudioManagerDaemon/src/CAmDatabaseObserver.cpp b/AudioManagerDaemon/src/CAmDatabaseObserver.cpp
index 0b8b481..426f5d2 100644
--- a/AudioManagerDaemon/src/CAmDatabaseObserver.cpp
+++ b/AudioManagerDaemon/src/CAmDatabaseObserver.cpp
@@ -165,22 +165,22 @@ void CAmDatabaseObserver::mainConnectionStateChanged(const am_mainConnectionID_t
void CAmDatabaseObserver::mainSinkSoundPropertyChanged(const am_sinkID_t sinkID, const am_MainSoundProperty_s& SoundProperty)
{
- mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_MainSoundProperty_s&>(mCommandSender, &CAmCommandSender::cbMainSinkSoundPropertyChanged, sinkID, SoundProperty);
+ mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_MainSoundProperty_s>(mCommandSender, &CAmCommandSender::cbMainSinkSoundPropertyChanged, sinkID, SoundProperty);
}
void CAmDatabaseObserver::mainSourceSoundPropertyChanged(const am_sourceID_t sourceID, const am_MainSoundProperty_s & SoundProperty)
{
- mSerializer.asyncCall<CAmCommandSender, const am_sourceID_t, const am_MainSoundProperty_s&>(mCommandSender, &CAmCommandSender::cbMainSourceSoundPropertyChanged, sourceID, SoundProperty);
+ mSerializer.asyncCall<CAmCommandSender, const am_sourceID_t, const am_MainSoundProperty_s>(mCommandSender, &CAmCommandSender::cbMainSourceSoundPropertyChanged, sourceID, SoundProperty);
}
void CAmDatabaseObserver::sinkAvailabilityChanged(const am_sinkID_t sinkID, const am_Availability_s & availability)
{
- mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_Availability_s&>(mCommandSender, &CAmCommandSender::cbSinkAvailabilityChanged, sinkID, availability);
+ mSerializer.asyncCall<CAmCommandSender, const am_sinkID_t, const am_Availability_s>(mCommandSender, &CAmCommandSender::cbSinkAvailabilityChanged, sinkID, availability);
}
void CAmDatabaseObserver::sourceAvailabilityChanged(const am_sourceID_t sourceID, const am_Availability_s & availability)
{
- mSerializer.asyncCall<CAmCommandSender, const am_sourceID_t, const am_Availability_s&>(mCommandSender, &CAmCommandSender::cbSourceAvailabilityChanged, sourceID, availability);
+ mSerializer.asyncCall<CAmCommandSender, const am_sourceID_t, const am_Availability_s>(mCommandSender, &CAmCommandSender::cbSourceAvailabilityChanged, sourceID, availability);
}
void CAmDatabaseObserver::volumeChanged(const am_sinkID_t sinkID, const am_mainVolume_t volume)
@@ -195,7 +195,7 @@ void CAmDatabaseObserver::sinkMuteStateChanged(const am_sinkID_t sinkID, const a
void CAmDatabaseObserver::systemPropertyChanged(const am_SystemProperty_s& SystemProperty)
{
- mSerializer.asyncCall<CAmCommandSender, const am_SystemProperty_s&>(mCommandSender, &CAmCommandSender::cbSystemPropertyChanged, SystemProperty);
+ mSerializer.asyncCall<CAmCommandSender, const am_SystemProperty_s>(mCommandSender, &CAmCommandSender::cbSystemPropertyChanged, SystemProperty);
}
void CAmDatabaseObserver::timingInformationChanged(const am_mainConnectionID_t mainConnection, const am_timeSync_t time)
diff --git a/include/shared/CAmSerializer.h b/include/shared/CAmSerializer.h
index 39b6c90..5a1cde5 100644
--- a/include/shared/CAmSerializer.h
+++ b/include/shared/CAmSerializer.h
@@ -140,6 +140,7 @@ private:
};
};
+
/**
* delegate template for three arguments
*/
@@ -647,6 +648,33 @@ public:
}
/**
+ * calls a function with one argument called by reference asynchronously threadsafe
+ * @param instance the instance of the class that shall be called
+ * @param function the function that shall be called as memberfunction pointer.
+ * @param argument the argument
+ * @tparam TClass1 the type of the Class to be called
+ * @tparam Targ the type of the argument to be called
+ * \section ex Example:
+ * @code
+ * class myClass
+ * {
+ * public:
+ * void myfunction(int k);
+ * }
+ * CAmSerializer serial(&Sockethandler);
+ * myClass instanceMyClass;
+ * serial<CommandSender,int>(&instanceMyClass,&myClass::myfunction,k);
+ * @endcode
+ *
+ */
+ template<class TClass1, class Targ>
+ void asyncCall(TClass1* instance, void (TClass1::*function)(Targ&), Targ& argument)
+ {
+ CAmDelegagePtr p(new CAmOneArgDelegate<TClass1, Targ&>(instance, function, argument));
+ send(p);
+ }
+
+ /**
* calls a function with two arguments asynchronously threadsafe. for more see asyncCall with one argument
* @param instance pointer to the instance of the class
* @param function memberfunction poitner
@@ -659,11 +687,64 @@ public:
template<class TClass1, class Targ, class Targ1>
void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1 argument1), Targ argument, Targ1 argument1)
{
+ logInfo("took without ref");
CAmDelegagePtr p(new CAmTwoArgDelegate<TClass1, Targ, Targ1>(instance, function, argument, argument1));
send(p);
}
/**
+ * calls a function with two arguments asynchronously threadsafe, first argument is a reference. for more see asyncCall with one argument
+ * @param instance pointer to the instance of the class
+ * @param function memberfunction poitner
+ * @param argument the first argument
+ * @param argument1 the second argument
+ * @tparam TClass1 the type of the Class to be called
+ * @tparam Targ the type of the argument to be called
+ * @tparam Targ1 the type of the first argument to be called
+ */
+ template<class TClass1, class Targ, class Targ1>
+ void asyncCall(TClass1* instance, void (TClass1::*function)(Targ& argument, Targ1 argument1), Targ& argument, Targ1 argument1)
+ {
+ CAmDelegagePtr p(new CAmTwoArgDelegate<TClass1, Targ&, Targ1>(instance, function, argument, argument1));
+ send(p);
+ }
+
+ /**
+ * calls a function with two arguments asynchronously threadsafe, second argument is a reference. for more see asyncCall with one argument
+ * @param instance pointer to the instance of the class
+ * @param function memberfunction poitner
+ * @param argument the first argument
+ * @param argument1 the second argument
+ * @tparam TClass1 the type of the Class to be called
+ * @tparam Targ the type of the argument to be called
+ * @tparam Targ1 the type of the first argument to be called
+ */
+ template<class TClass1, class Targ, class Targ1>
+ void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1& argument1), Targ argument, Targ1& argument1)
+ {
+ logInfo("took ref");
+ CAmDelegagePtr p(new CAmTwoArgDelegate<TClass1, Targ, Targ1&>(instance, function, argument, argument1));
+ send(p);
+ }
+
+ /**
+ * calls a function with two arguments asynchronously threadsafe, both arguments are references. for more see asyncCall with one argument
+ * @param instance pointer to the instance of the class
+ * @param function memberfunction poitner
+ * @param argument the first argument
+ * @param argument1 the second argument
+ * @tparam TClass1 the type of the Class to be called
+ * @tparam Targ the type of the argument to be called
+ * @tparam Targ1 the type of the first argument to be called
+ */
+ template<class TClass1, class Targ, class Targ1>
+ void asyncCall(TClass1* instance, void (TClass1::*function)(Targ& argument, Targ1& argument1), Targ& argument, Targ1& argument1)
+ {
+ CAmDelegagePtr p(new CAmTwoArgDelegate<TClass1, Targ&, Targ1&>(instance, function, argument, argument1));
+ send(p);
+ }
+
+ /**
* calls a function with three arguments asynchronously threadsafe. for more see other asycCall
*/
template<class TClass1, class Targ, class Targ1, class Targ2>
@@ -674,6 +755,77 @@ public:
}
/**
+ * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
+ */
+ template<class TClass1, class Targ, class Targ1, class Targ2>
+ void asyncCall(TClass1* instance, void (TClass1::*function)(Targ& argument, Targ1 argument1, Targ2 argument2), Targ& argument, Targ1 argument1, Targ2 argument2)
+ {
+ CAmDelegagePtr p(new CAmThreeArgDelegate<TClass1, Targ&, Targ1, Targ2>(instance, function, argument, argument1, argument2));
+ send(p);
+ }
+
+
+ /**
+ * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
+ */
+ template<class TClass1, class Targ, class Targ1, class Targ2>
+ void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1& argument1, Targ2 argument2), Targ argument, Targ1& argument1, Targ2 argument2)
+ {
+ CAmDelegagePtr p(new CAmThreeArgDelegate<TClass1, Targ, Targ1&, Targ2>(instance, function, argument, argument1, argument2));
+ send(p);
+ }
+
+ /**
+ * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
+ */
+ template<class TClass1, class Targ, class Targ1, class Targ2>
+ void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1 argument1, Targ2& argument2), Targ argument, Targ1 argument1, Targ2& argument2)
+ {
+ CAmDelegagePtr p(new CAmThreeArgDelegate<TClass1, Targ, Targ1, Targ2&>(instance, function, argument, argument1, argument2));
+ send(p);
+ }
+
+ /**
+ * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
+ */
+ template<class TClass1, class Targ, class Targ1, class Targ2>
+ void asyncCall(TClass1* instance, void (TClass1::*function)(Targ argument, Targ1& argument1, Targ2& argument2), Targ argument, Targ1& argument1, Targ2& argument2)
+ {
+ CAmDelegagePtr p(new CAmThreeArgDelegate<TClass1, Targ, Targ1&, Targ2&>(instance, function, argument, argument1, argument2));
+ send(p);
+ }
+
+ /**
+ * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
+ */
+ template<class TClass1, class Targ, class Targ1, class Targ2>
+ void asyncCall(TClass1* instance, void (TClass1::*function)(Targ& argument, Targ1& argument1, Targ2& argument2), Targ& argument, Targ1& argument1, Targ2& argument2)
+ {
+ CAmDelegagePtr p(new CAmThreeArgDelegate<TClass1, Targ&, Targ1&, Targ2&>(instance, function, argument, argument1, argument2));
+ send(p);
+ }
+
+ /**
+ * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
+ */
+ template<class TClass1, class Targ, class Targ1, class Targ2>
+ void asyncCall(TClass1* instance, void (TClass1::*function)(Targ& argument, Targ1& argument1, Targ2 argument2), Targ& argument, Targ1& argument1, Targ2 argument2)
+ {
+ CAmDelegagePtr p(new CAmThreeArgDelegate<TClass1, Targ&, Targ1&, Targ2>(instance, function, argument, argument1, argument2));
+ send(p);
+ }
+
+ /**
+ * calls a function with three arguments asynchronously threadsafe. for more see other asycCall
+ */
+ template<class TClass1, class Targ, class Targ1, class Targ2>
+ void asyncCall(TClass1* instance, void (TClass1::*function)(Targ& argument, Targ1 argument1, Targ2& argument2), Targ& argument, Targ1 argument1, Targ2& argument2)
+ {
+ CAmDelegagePtr p(new CAmThreeArgDelegate<TClass1, Targ&, Targ1, Targ2&>(instance, function, argument, argument1, argument2));
+ send(p);
+ }
+
+ /**
* calls a function with four arguments asynchronously threadsafe. for more see other asycCall
*/
template<class TClass1, class Targ, class Targ1, class Targ2, class Targ3>
@@ -837,7 +989,7 @@ public:
logError("CAmSerializer::receiverCallback could not read pipe!");
throw std::runtime_error("CAmSerializer Could not read pipe!");
}
- //working with friend class here is not the finest of all programming stiles but it works...
+ //working with friend class here is not the finest of all programming stiles but it worCAmTwoArgDelegateks...
retVal = p->returnResults(argument, argument1, argument2);
delete p;
}