mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-16 01:51:45 +00:00
Rename device property to have a common format and some code cleanup.
FairMQDevice: Rename property for socket rate logging to have common format (old name is still available for compatibility). FairMQ: Avoid using std namespace in class headers (may require adding std namespace to some child devices). FairMQ: A bit of code cleanup FairMQConfigurable: Stop with an error if a property assignment failed due to incorrect key.
This commit is contained in:
committed by
Florian Uhlig
parent
61f24eb73a
commit
26a1033e9d
@@ -20,6 +20,8 @@
|
||||
#include "FairMQBenchmarkSampler.h"
|
||||
#include "FairMQLogger.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
FairMQBenchmarkSampler::FairMQBenchmarkSampler()
|
||||
: fEventSize(10000)
|
||||
, fEventRate(1)
|
||||
|
@@ -37,8 +37,8 @@ class FairMQBenchmarkSampler : public FairMQDevice
|
||||
virtual ~FairMQBenchmarkSampler();
|
||||
void Log(int intervalInMs);
|
||||
void ResetEventCounter();
|
||||
virtual void SetProperty(const int key, const string& value, const int slot = 0);
|
||||
virtual string GetProperty(const int key, const string& default_ = "", const int slot = 0);
|
||||
virtual void SetProperty(const int key, const std::string& value, const int slot = 0);
|
||||
virtual std::string GetProperty(const int key, const std::string& default_ = "", const int slot = 0);
|
||||
virtual void SetProperty(const int key, const int value, const int slot = 0);
|
||||
virtual int GetProperty(const int key, const int default_ = 0, const int slot = 0);
|
||||
|
||||
|
@@ -8,9 +8,10 @@
|
||||
#ifndef GENERICFILESINK_H
|
||||
#define GENERICFILESINK_H
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
#include "FairMQLogger.h"
|
||||
|
||||
template <typename InputPolicy, typename OutputPolicy>
|
||||
@@ -19,25 +20,24 @@ class GenericFileSink : public FairMQDevice, public InputPolicy, public OutputPo
|
||||
//using InputPolicy::message;
|
||||
//using OutputPolicy::InitOutFile;
|
||||
//using OutputPolicy::AddToFile;
|
||||
|
||||
public:
|
||||
|
||||
public:
|
||||
GenericFileSink();
|
||||
virtual ~GenericFileSink();
|
||||
|
||||
|
||||
template <typename... Args>
|
||||
void InitInputPolicyContainer(Args... args)
|
||||
{
|
||||
InputPolicy::InitContainer(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
||||
|
||||
virtual void SetTransport(FairMQTransportFactory* transport);
|
||||
virtual void InitOutputFile();
|
||||
|
||||
protected:
|
||||
|
||||
protected:
|
||||
virtual void Run();
|
||||
virtual void Init();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#include "GenericFileSink.tpl"
|
||||
|
@@ -17,45 +17,40 @@ class GenericProcessor: public FairMQDevice,
|
||||
public TaskPolicy
|
||||
{
|
||||
public:
|
||||
|
||||
GenericProcessor() : InputPolicy(), OutputPolicy(), TaskPolicy()
|
||||
{}
|
||||
|
||||
|
||||
virtual ~GenericProcessor()
|
||||
{}
|
||||
|
||||
|
||||
void SetTransport(FairMQTransportFactory* transport)
|
||||
{
|
||||
FairMQDevice::SetTransport(transport);
|
||||
//InputPolicy::SetTransport(transport);
|
||||
//OutputPolicy::SetTransport(transport);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename... Args>
|
||||
void InitTask(Args... args)
|
||||
{
|
||||
TaskPolicy::InitTask(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
||||
template <typename... Args>
|
||||
void InitInputContainer(Args... args)
|
||||
{
|
||||
InputPolicy::InitContainer(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
||||
template <typename... Args>
|
||||
void InitOutputContainer(Args... args)
|
||||
{
|
||||
OutputPolicy::InitContainer(std::forward<Args>(args)...);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//void SendPart();
|
||||
//bool ReceivePart();
|
||||
|
||||
|
||||
|
||||
void SendPart()
|
||||
{
|
||||
fPayloadOutputs->at(0)->Send(OutputPolicy::SerializeMsg(TaskPolicy::GetData()), "snd-more");
|
||||
@@ -81,7 +76,7 @@ class GenericProcessor: public FairMQDevice,
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
protected:
|
||||
virtual void Init()
|
||||
{
|
||||
@@ -91,7 +86,7 @@ class GenericProcessor: public FairMQDevice,
|
||||
//fProcessorTask->SetSendPart(boost::bind(&FairMQProcessor::SendPart, this));
|
||||
//fProcessorTask->SetReceivePart(boost::bind(&FairMQProcessor::ReceivePart, this));
|
||||
}
|
||||
|
||||
|
||||
virtual void Run()
|
||||
{
|
||||
MQLOG(INFO) << ">>>>>>> Run <<<<<<<";
|
||||
@@ -100,7 +95,7 @@ class GenericProcessor: public FairMQDevice,
|
||||
int receivedMsgs = 0;
|
||||
int sentMsgs = 0;
|
||||
int received = 0;
|
||||
|
||||
|
||||
while ( fState == RUNNING )
|
||||
{
|
||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||
@@ -148,7 +143,6 @@ class GenericProcessor: public FairMQDevice,
|
||||
fRunningCondition.notify_one();
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
//#include "GenericSampler.tpl"
|
||||
|
@@ -8,9 +8,6 @@
|
||||
#ifndef GENERICSAMPLER_H
|
||||
#define GENERICSAMPLER_H
|
||||
|
||||
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
@@ -18,12 +15,6 @@
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/timer/timer.hpp>
|
||||
|
||||
#include "TList.h"
|
||||
#include "TObjString.h"
|
||||
#include "TClonesArray.h"
|
||||
#include "TROOT.h"
|
||||
|
||||
|
||||
#include "FairMQDevice.h"
|
||||
#include "FairMQLogger.h"
|
||||
|
||||
@@ -44,7 +35,7 @@ class GenericSampler: public FairMQDevice, public SamplerPolicy, public OutputPo
|
||||
{
|
||||
//using SamplerPolicy::GetDataBranch; // get data from file
|
||||
//using OutputPolicy::message; // serialize method
|
||||
|
||||
|
||||
public:
|
||||
enum {
|
||||
InputFile = FairMQDevice::Last,
|
||||
@@ -57,15 +48,15 @@ class GenericSampler: public FairMQDevice, public SamplerPolicy, public OutputPo
|
||||
virtual void SetTransport(FairMQTransportFactory* factory);
|
||||
void ResetEventCounter();
|
||||
virtual void ListenToCommands();
|
||||
|
||||
|
||||
template <typename... Args>
|
||||
void SetFileProperties(Args&... args)
|
||||
{
|
||||
SamplerPolicy::SetFileProperties(args...);
|
||||
}
|
||||
|
||||
virtual void SetProperty(const int key, const string& value, const int slot = 0);
|
||||
virtual string GetProperty(const int key, const string& default_ = "", const int slot = 0);
|
||||
virtual void SetProperty(const int key, const std::string& value, const int slot = 0);
|
||||
virtual std::string GetProperty(const int key, const std::string& default_ = "", const int slot = 0);
|
||||
virtual void SetProperty(const int key, const int value, const int slot = 0);
|
||||
virtual int GetProperty(const int key, const int default_ = 0, const int slot = 0);
|
||||
|
||||
@@ -84,9 +75,9 @@ protected:
|
||||
virtual void Run();
|
||||
|
||||
protected:
|
||||
string fInputFile; // Filename of a root file containing the simulated digis.
|
||||
string fParFile;
|
||||
string fBranch; // The name of the sub-detector branch to stream the digis from.
|
||||
std::string fInputFile; // Filename of a root file containing the simulated digis.
|
||||
std::string fParFile;
|
||||
std::string fBranch; // The name of the sub-detector branch to stream the digis from.
|
||||
int fNumEvents;
|
||||
int fEventRate;
|
||||
int fEventCounter;
|
||||
|
@@ -6,29 +6,25 @@
|
||||
*/
|
||||
|
||||
template <typename SamplerPolicy, typename OutputPolicy>
|
||||
GenericSampler<SamplerPolicy,OutputPolicy>::GenericSampler() :
|
||||
fNumEvents(0),
|
||||
fEventRate(1),
|
||||
fEventCounter(0),
|
||||
fContinuous(false)
|
||||
{
|
||||
}
|
||||
|
||||
GenericSampler<SamplerPolicy,OutputPolicy>::GenericSampler() :
|
||||
fNumEvents(0),
|
||||
fEventRate(1),
|
||||
fEventCounter(0),
|
||||
fContinuous(false)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename SamplerPolicy, typename OutputPolicy>
|
||||
GenericSampler<SamplerPolicy,OutputPolicy>::~GenericSampler()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
GenericSampler<SamplerPolicy,OutputPolicy>::~GenericSampler()
|
||||
{
|
||||
}
|
||||
|
||||
template <typename SamplerPolicy, typename OutputPolicy>
|
||||
void GenericSampler<SamplerPolicy,OutputPolicy>::SetTransport(FairMQTransportFactory* factory)
|
||||
{
|
||||
FairMQDevice::SetTransport(factory);
|
||||
//OutputPolicy::SetTransport(factory);
|
||||
}
|
||||
void GenericSampler<SamplerPolicy,OutputPolicy>::SetTransport(FairMQTransportFactory* factory)
|
||||
{
|
||||
FairMQDevice::SetTransport(factory);
|
||||
//OutputPolicy::SetTransport(factory);
|
||||
}
|
||||
|
||||
template <typename SamplerPolicy, typename OutputPolicy>
|
||||
void GenericSampler<SamplerPolicy,OutputPolicy>::Init()
|
||||
@@ -57,7 +53,7 @@ void GenericSampler<SamplerPolicy,OutputPolicy>::Run()
|
||||
|
||||
do
|
||||
{
|
||||
for ( Long64_t eventNr = 0 ; eventNr < fNumEvents; ++eventNr )
|
||||
for ( unsigned long eventNr = 0 ; eventNr < fNumEvents; ++eventNr )
|
||||
{
|
||||
//fSamplerTask->SetEventIndex(eventNr);
|
||||
FairMQMessage* msg = fTransportFactory->CreateMessage();
|
||||
@@ -166,7 +162,7 @@ void GenericSampler<SamplerPolicy,OutputPolicy>::ListenToCommands()
|
||||
}
|
||||
|
||||
template <typename SamplerPolicy, typename OutputPolicy>
|
||||
void GenericSampler<SamplerPolicy,OutputPolicy>::SetProperty(const int key, const string& value, const int slot/*= 0*/)
|
||||
void GenericSampler<SamplerPolicy,OutputPolicy>::SetProperty(const int key, const std::string& value, const int slot/*= 0*/)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
@@ -186,7 +182,7 @@ void GenericSampler<SamplerPolicy,OutputPolicy>::SetProperty(const int key, cons
|
||||
}
|
||||
|
||||
template <typename SamplerPolicy, typename OutputPolicy>
|
||||
string GenericSampler<SamplerPolicy,OutputPolicy>::GetProperty(const int key, const string& default_/*= ""*/, const int slot/*= 0*/)
|
||||
std::string GenericSampler<SamplerPolicy,OutputPolicy>::GetProperty(const int key, const std::string& default_/*= ""*/, const int slot/*= 0*/)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
|
Reference in New Issue
Block a user