mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 00:31:14 +00:00
formatting, change and clean generic_sampler and SimpleTreeReader
This commit is contained in:
parent
d0c20d3729
commit
6ce6887212
|
@ -41,7 +41,7 @@
|
||||||
* CONTAINER_TYPE source_type::GetOutData() // must be there to compile
|
* CONTAINER_TYPE source_type::GetOutData() // must be there to compile
|
||||||
* source_type::SetFileProperties(Args&... args) // must be there to compile
|
* source_type::SetFileProperties(Args&... args) // must be there to compile
|
||||||
*
|
*
|
||||||
* void BindSendPart(std::function<void(int)> callback) // enabled if exists
|
* void BindSendHeader(std::function<void(int)> callback) // enabled if exists
|
||||||
* void BindGetSocketNumber(std::function<int()> callback) // enabled if exists
|
* void BindGetSocketNumber(std::function<int()> callback) // enabled if exists
|
||||||
* void BindGetCurrentIndex(std::function<int()> callback) // enabled if exists
|
* void BindGetCurrentIndex(std::function<int()> 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 void SetProperty(const int key, const std::string& value);
|
||||||
virtual std::string GetProperty(const int key, const std::string& default_ = "");
|
virtual std::string GetProperty(const int key, const std::string& default_ = "");
|
||||||
|
|
||||||
void SendPart(int socketIdx);
|
void SendHeader(int socketIdx=0);
|
||||||
int GetSocketNumber() const;
|
int GetSocketNumber() const;
|
||||||
int GetCurrentIndex() const;
|
int GetCurrentIndex() const;
|
||||||
void SetContinuous(bool flag);
|
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.
|
// 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.
|
// this template functions use SFINAE to detect the existence of the policy function signature.
|
||||||
template<typename S = source_type,FairMQ::tools::enable_if_hasNot_BindSendPart<S> = 0>
|
template<typename S = source_type,FairMQ::tools::enable_if_hasNot_BindSendHeader<S> = 0>
|
||||||
void BindingSendPart() {}
|
void BindingSendPart() {}
|
||||||
template<typename S = source_type,FairMQ::tools::enable_if_has_BindSendPart<S> = 0>
|
template<typename S = source_type,FairMQ::tools::enable_if_has_BindSendHeader<S> = 0>
|
||||||
void BindingSendPart()
|
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<typename S = source_type,FairMQ::tools::enable_if_hasNot_BindGetSocketNumber<S> = 0>
|
template<typename S = source_type,FairMQ::tools::enable_if_hasNot_BindGetSocketNumber<S> = 0>
|
||||||
|
|
|
@ -62,11 +62,6 @@ void base_GenericSampler<T,U,K,L>::Run()
|
||||||
p.Send(serialization_type::SerializeMsg(source_type::GetOutData()));
|
p.Send(serialization_type::SerializeMsg(source_type::GetOutData()));
|
||||||
sentMsgs++;
|
sentMsgs++;
|
||||||
|
|
||||||
if (fChannels[fOutChanName].size() > 1)
|
|
||||||
{
|
|
||||||
fCurrentIdx++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Optional event rate limiting
|
// Optional event rate limiting
|
||||||
// --fEventCounter;
|
// --fEventCounter;
|
||||||
// while (fEventCounter == 0) {
|
// while (fEventCounter == 0) {
|
||||||
|
@ -78,11 +73,6 @@ void base_GenericSampler<T,U,K,L>::Run()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if more than one socket, remove the last incrementation
|
|
||||||
if (fChannels[fOutChanName].size() > 1)
|
|
||||||
{
|
|
||||||
fCurrentIdx--;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!CheckCurrentState(RUNNING))
|
if (!CheckCurrentState(RUNNING))
|
||||||
{
|
{
|
||||||
|
@ -99,16 +89,12 @@ void base_GenericSampler<T,U,K,L>::Run()
|
||||||
|
|
||||||
|
|
||||||
template <typename T, typename U, typename K, typename L>
|
template <typename T, typename U, typename K, typename L>
|
||||||
void base_GenericSampler<T,U,K,L>::SendPart(int socketIdx)
|
void base_GenericSampler<T,U,K,L>::SendHeader(int socketIdx)
|
||||||
{
|
{
|
||||||
fCurrentIdx++;
|
|
||||||
if (fCurrentIdx < fNumEvents)
|
std::unique_ptr<FairMQMessage> msg(fTransportFactory->CreateMessage());
|
||||||
{
|
serialization_type::SetMessage(msg.get());
|
||||||
std::unique_ptr<FairMQMessage> msg(fTransportFactory->CreateMessage());
|
fChannels.at(fOutChanName).at(socketIdx).Send(serialization_type::SerializeMsg(source_type::GetOutData()), "snd-more");
|
||||||
serialization_type::SetMessage(msg.get());
|
|
||||||
source_type::SetIndex(fCurrentIdx);
|
|
||||||
fChannels[fOutChanName].at(socketIdx).Send(serialization_type::SerializeMsg(source_type::GetOutData()), "snd-more");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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
|
source_type::SetFileProperties(Args&... args); // if called by the host, then must be there to compile
|
||||||
|
|
||||||
void source_type::BindSendPart(std::function<void(int)> callback); // enabled if exists
|
void source_type::BindSendHeader(std::function<void(int)> callback); // enabled if exists
|
||||||
void source_type::BindGetSocketNumber(std::function<int()> callback); // enabled if exists
|
void source_type::BindGetSocketNumber(std::function<int()> callback); // enabled if exists
|
||||||
void source_type::BindGetCurrentIndex(std::function<int()> callback); // enabled if exists
|
void source_type::BindGetCurrentIndex(std::function<int()> callback); // enabled if exists
|
||||||
```
|
```
|
||||||
|
|
|
@ -68,14 +68,14 @@ int getHostIPs(map<string, string>& addressMap)
|
||||||
// below are SFINAE template functions to check for function member signatures of class
|
// below are SFINAE template functions to check for function member signatures of class
|
||||||
namespace details
|
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<class T, class Sig, class=void>
|
template<class T, class Sig, class=void>
|
||||||
struct has_BindSendPart : false_type {};
|
struct has_BindSendHeader : false_type {};
|
||||||
|
|
||||||
template<class T, class R, class... Args>
|
template<class T, class R, class... Args>
|
||||||
struct has_BindSendPart
|
struct has_BindSendHeader
|
||||||
<T, R(Args...), typename enable_if<
|
<T, R(Args...), typename enable_if<
|
||||||
is_convertible<decltype(declval<T>().BindSendPart(declval<Args>()...)), R>::value || is_same<R, void>::value>::type
|
is_convertible<decltype(declval<T>().BindSendHeader(declval<Args>()...)), R>::value || is_same<R, void>::value>::type
|
||||||
>:true_type {};
|
>:true_type {};
|
||||||
|
|
||||||
// test, at compile time, whether T has BindGetSocketNumber member function with returned type R and argument ...Args 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
|
||||||
<T, R(Args...), typename enable_if<
|
<T, R(Args...), typename enable_if<
|
||||||
is_convertible<decltype(declval<T>().BindGetCurrentIndex(declval<Args>()...)), R>::value || is_same<R, void>::value>::type
|
is_convertible<decltype(declval<T>().BindGetCurrentIndex(declval<Args>()...)), R>::value || is_same<R, void>::value>::type
|
||||||
>:true_type {};
|
>:true_type {};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // end namespace details
|
} // end namespace details
|
||||||
|
|
||||||
// Alias template of the above structs
|
// Alias template of the above structs
|
||||||
template<class T, class Sig>
|
template<class T, class Sig>
|
||||||
using has_BindSendPart = integral_constant<bool, details::has_BindSendPart<T, Sig>::value>;
|
using has_BindSendHeader = integral_constant<bool, details::has_BindSendHeader<T, Sig>::value>;
|
||||||
|
|
||||||
template<class T, class Sig>
|
template<class T, class Sig>
|
||||||
using has_BindGetSocketNumber = integral_constant<bool, details::has_BindGetSocketNumber<T, Sig>::value>;
|
using has_BindGetSocketNumber = integral_constant<bool, details::has_BindGetSocketNumber<T, Sig>::value>;
|
||||||
|
@ -111,9 +114,9 @@ using has_BindGetCurrentIndex = integral_constant<bool, details::has_BindGetCurr
|
||||||
|
|
||||||
// enable_if Alias template
|
// enable_if Alias template
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using enable_if_has_BindSendPart = typename enable_if<has_BindSendPart<T, void(int)>::value, int>::type;
|
using enable_if_has_BindSendHeader = typename enable_if<has_BindSendHeader<T, void(int)>::value, int>::type;
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using enable_if_hasNot_BindSendPart = typename enable_if<!has_BindSendPart<T, void(int)>::value, int>::type;
|
using enable_if_hasNot_BindSendHeader = typename enable_if<!has_BindSendHeader<T, void(int)>::value, int>::type;
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
using enable_if_has_BindGetSocketNumber = typename enable_if<has_BindGetSocketNumber<T, int()>::value, int>::type;
|
using enable_if_has_BindGetSocketNumber = typename enable_if<has_BindGetSocketNumber<T, int()>::value, int>::type;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user