From 6ce6887212632532944687f65b7acc3fc91b19ee Mon Sep 17 00:00:00 2001 From: NicolasWinckler Date: Fri, 6 Nov 2015 11:07:16 +0100 Subject: [PATCH] formatting, change and clean generic_sampler and SimpleTreeReader --- fairmq/devices/GenericSampler.h | 10 +++++----- fairmq/devices/GenericSampler.tpl | 24 +++++------------------- fairmq/devices/README.md | 2 +- fairmq/tools/FairMQTools.h | 17 ++++++++++------- 4 files changed, 21 insertions(+), 32 deletions(-) diff --git a/fairmq/devices/GenericSampler.h b/fairmq/devices/GenericSampler.h index 9e6d5d63..57c9ec0e 100644 --- a/fairmq/devices/GenericSampler.h +++ b/fairmq/devices/GenericSampler.h @@ -41,7 +41,7 @@ * CONTAINER_TYPE source_type::GetOutData() // must be there to compile * source_type::SetFileProperties(Args&... args) // must be there to compile * - * void BindSendPart(std::function callback) // enabled if exists + * void BindSendHeader(std::function callback) // enabled if exists * void BindGetSocketNumber(std::function callback) // enabled if exists * void BindGetCurrentIndex(std::function callback) // enabled if exists * @@ -97,7 +97,7 @@ class base_GenericSampler : public FairMQDevice, public T, public U virtual void SetProperty(const int key, const std::string& value); virtual std::string GetProperty(const int key, const std::string& default_ = ""); - void SendPart(int socketIdx); + void SendHeader(int socketIdx=0); int GetSocketNumber() const; int GetCurrentIndex() const; void SetContinuous(bool flag); @@ -158,12 +158,12 @@ class base_GenericSampler : public FairMQDevice, public T, public U // automatically enable or disable the call of policy function members for binding of host functions. // this template functions use SFINAE to detect the existence of the policy function signature. - template = 0> + template = 0> void BindingSendPart() {} - template = 0> + template = 0> void BindingSendPart() { - source_type::BindSendPart(std::bind(&base_GenericSampler::SendPart,this,std::placeholders::_1) ); + source_type::BindSendHeader(std::bind(&base_GenericSampler::SendPart,this,std::placeholders::_1) ); } template = 0> diff --git a/fairmq/devices/GenericSampler.tpl b/fairmq/devices/GenericSampler.tpl index d324832b..b3d1e0f6 100644 --- a/fairmq/devices/GenericSampler.tpl +++ b/fairmq/devices/GenericSampler.tpl @@ -62,11 +62,6 @@ void base_GenericSampler::Run() p.Send(serialization_type::SerializeMsg(source_type::GetOutData())); sentMsgs++; - if (fChannels[fOutChanName].size() > 1) - { - fCurrentIdx++; - } - // Optional event rate limiting // --fEventCounter; // while (fEventCounter == 0) { @@ -78,11 +73,6 @@ void base_GenericSampler::Run() break; } } - // if more than one socket, remove the last incrementation - if (fChannels[fOutChanName].size() > 1) - { - fCurrentIdx--; - } if (!CheckCurrentState(RUNNING)) { @@ -99,16 +89,12 @@ void base_GenericSampler::Run() template -void base_GenericSampler::SendPart(int socketIdx) +void base_GenericSampler::SendHeader(int socketIdx) { - fCurrentIdx++; - if (fCurrentIdx < fNumEvents) - { - std::unique_ptr msg(fTransportFactory->CreateMessage()); - serialization_type::SetMessage(msg.get()); - source_type::SetIndex(fCurrentIdx); - fChannels[fOutChanName].at(socketIdx).Send(serialization_type::SerializeMsg(source_type::GetOutData()), "snd-more"); - } + + std::unique_ptr msg(fTransportFactory->CreateMessage()); + serialization_type::SetMessage(msg.get()); + fChannels.at(fOutChanName).at(socketIdx).Send(serialization_type::SerializeMsg(source_type::GetOutData()), "snd-more"); } diff --git a/fairmq/devices/README.md b/fairmq/devices/README.md index 66ba9983..d66d6756 100644 --- a/fairmq/devices/README.md +++ b/fairmq/devices/README.md @@ -64,7 +64,7 @@ CONTAINER_TYPE source_type::GetOutData(); // must be there to compile source_type::SetFileProperties(Args&... args); // if called by the host, then must be there to compile - void source_type::BindSendPart(std::function callback); // enabled if exists + void source_type::BindSendHeader(std::function callback); // enabled if exists void source_type::BindGetSocketNumber(std::function callback); // enabled if exists void source_type::BindGetCurrentIndex(std::function callback); // enabled if exists ``` diff --git a/fairmq/tools/FairMQTools.h b/fairmq/tools/FairMQTools.h index 248f06a1..bac18dc8 100644 --- a/fairmq/tools/FairMQTools.h +++ b/fairmq/tools/FairMQTools.h @@ -68,14 +68,14 @@ int getHostIPs(map& addressMap) // below are SFINAE template functions to check for function member signatures of class namespace details { -// test, at compile time, whether T has BindSendPart member function with returned type R and argument ...Args type +// test, at compile time, whether T has BindSendHeader member function with returned type R and argument ...Args type template -struct has_BindSendPart : false_type {}; +struct has_BindSendHeader : false_type {}; template -struct has_BindSendPart +struct has_BindSendHeader ().BindSendPart(declval()...)), R>::value || is_same::value>::type + is_convertible().BindSendHeader(declval()...)), R>::value || is_same::value>::type >:true_type {}; // test, at compile time, whether T has BindGetSocketNumber member function with returned type R and argument ...Args type @@ -97,11 +97,14 @@ struct has_BindGetCurrentIndex ().BindGetCurrentIndex(declval()...)), R>::value || is_same::value>::type >:true_type {}; + + + } // end namespace details // Alias template of the above structs template -using has_BindSendPart = integral_constant::value>; +using has_BindSendHeader = integral_constant::value>; template using has_BindGetSocketNumber = integral_constant::value>; @@ -111,9 +114,9 @@ using has_BindGetCurrentIndex = integral_constant -using enable_if_has_BindSendPart = typename enable_if::value, int>::type; +using enable_if_has_BindSendHeader = typename enable_if::value, int>::type; template -using enable_if_hasNot_BindSendPart = typename enable_if::value, int>::type; +using enable_if_hasNot_BindSendHeader = typename enable_if::value, int>::type; template using enable_if_has_BindGetSocketNumber = typename enable_if::value, int>::type;