mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +00:00
Fix warnings produced with -Weffc++ in fairmq, base/MQ and Tutorial3.
Remaining warnings originate from boost::msm and boost::mpl. Also, warnings with missing initializer list entries for DeviceOptions are false positives, since those are PODs.
This commit is contained in:
parent
a8854d36ac
commit
ce58ee2302
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using std::string;
|
using namespace std;
|
||||||
|
|
||||||
class FairMQConfigurable
|
class FairMQConfigurable
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,9 +19,22 @@
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
|
|
||||||
FairMQDevice::FairMQDevice()
|
FairMQDevice::FairMQDevice()
|
||||||
: fNumIoThreads(1)
|
: fId()
|
||||||
|
, fNumIoThreads(1)
|
||||||
, fNumInputs(0)
|
, fNumInputs(0)
|
||||||
, fNumOutputs(0)
|
, fNumOutputs(0)
|
||||||
|
, fInputAddress()
|
||||||
|
, fInputMethod()
|
||||||
|
, fInputSocketType()
|
||||||
|
, fInputSndBufSize()
|
||||||
|
, fInputRcvBufSize()
|
||||||
|
, fLogInputRate()
|
||||||
|
, fOutputAddress()
|
||||||
|
, fOutputMethod()
|
||||||
|
, fOutputSocketType()
|
||||||
|
, fOutputSndBufSize()
|
||||||
|
, fOutputRcvBufSize()
|
||||||
|
, fLogOutputRate()
|
||||||
, fPayloadInputs(new vector<FairMQSocket*>())
|
, fPayloadInputs(new vector<FairMQSocket*>())
|
||||||
, fPayloadOutputs(new vector<FairMQSocket*>())
|
, fPayloadOutputs(new vector<FairMQSocket*>())
|
||||||
, fLogIntervalInMs(1000)
|
, fLogIntervalInMs(1000)
|
||||||
|
@ -78,7 +91,7 @@ void FairMQDevice::InitInput()
|
||||||
fPayloadInputs->at(i)->Connect(fInputAddress.at(i));
|
fPayloadInputs->at(i)->Connect(fInputAddress.at(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::out_of_range& e)
|
catch (out_of_range& e)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << e.what();
|
LOG(ERROR) << e.what();
|
||||||
}
|
}
|
||||||
|
@ -109,7 +122,7 @@ void FairMQDevice::InitOutput()
|
||||||
fPayloadOutputs->at(i)->Connect(fOutputAddress.at(i));
|
fPayloadOutputs->at(i)->Connect(fOutputAddress.at(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (std::out_of_range& e)
|
catch (out_of_range& e)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << e.what();
|
LOG(ERROR) << e.what();
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,7 @@
|
||||||
#include "FairMQTransportFactory.h"
|
#include "FairMQTransportFactory.h"
|
||||||
#include "FairMQSocket.h"
|
#include "FairMQSocket.h"
|
||||||
|
|
||||||
using std::vector;
|
using namespace std;
|
||||||
using std::cin;
|
|
||||||
using std::cout;
|
|
||||||
using std::endl;
|
|
||||||
|
|
||||||
class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable
|
class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable
|
||||||
{
|
{
|
||||||
|
@ -92,8 +89,6 @@ class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable
|
||||||
vector<FairMQSocket*>* fPayloadInputs;
|
vector<FairMQSocket*>* fPayloadInputs;
|
||||||
vector<FairMQSocket*>* fPayloadOutputs;
|
vector<FairMQSocket*>* fPayloadOutputs;
|
||||||
|
|
||||||
FairMQSocket* fCommandSocket;
|
|
||||||
|
|
||||||
int fLogIntervalInMs;
|
int fLogIntervalInMs;
|
||||||
|
|
||||||
FairMQTransportFactory* fTransportFactory;
|
FairMQTransportFactory* fTransportFactory;
|
||||||
|
@ -106,6 +101,11 @@ class FairMQDevice : public FairMQStateMachine, public FairMQConfigurable
|
||||||
virtual void InitInput();
|
virtual void InitInput();
|
||||||
|
|
||||||
virtual void Terminate();
|
virtual void Terminate();
|
||||||
|
|
||||||
|
private:
|
||||||
|
/// Copy Constructor
|
||||||
|
FairMQDevice(const FairMQDevice&);
|
||||||
|
FairMQDevice operator=(const FairMQDevice&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FAIRMQDEVICE_H_ */
|
#endif /* FAIRMQDEVICE_H_ */
|
||||||
|
|
|
@ -17,11 +17,8 @@
|
||||||
|
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
|
|
||||||
using std::string;
|
|
||||||
using std::cout;
|
|
||||||
using std::endl;
|
|
||||||
|
|
||||||
FairMQLogger::FairMQLogger()
|
FairMQLogger::FairMQLogger()
|
||||||
|
: os()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,7 +27,7 @@ FairMQLogger::~FairMQLogger()
|
||||||
cout << os.str() << endl;
|
cout << os.str() << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ostringstream& FairMQLogger::Log(int type)
|
ostringstream& FairMQLogger::Log(int type)
|
||||||
{
|
{
|
||||||
string type_str;
|
string type_str;
|
||||||
switch (type)
|
switch (type)
|
||||||
|
@ -56,10 +53,10 @@ std::ostringstream& FairMQLogger::Log(int type)
|
||||||
timestamp_t tm = get_timestamp();
|
timestamp_t tm = get_timestamp();
|
||||||
timestamp_t ms = tm / 1000.0L;
|
timestamp_t ms = tm / 1000.0L;
|
||||||
timestamp_t s = ms / 1000.0L;
|
timestamp_t s = ms / 1000.0L;
|
||||||
std::time_t t = s;
|
time_t t = s;
|
||||||
// std::size_t fractional_seconds = ms % 1000;
|
// size_t fractional_seconds = ms % 1000;
|
||||||
char mbstr[100];
|
char mbstr[100];
|
||||||
std::strftime(mbstr, 100, "%H:%M:%S", std::localtime(&t));
|
strftime(mbstr, 100, "%H:%M:%S", localtime(&t));
|
||||||
|
|
||||||
os << "[\033[01;36m" << mbstr << "\033[0m]"
|
os << "[\033[01;36m" << mbstr << "\033[0m]"
|
||||||
<< "[" << type_str << "]"
|
<< "[" << type_str << "]"
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
using std::ostringstream;
|
using namespace std;
|
||||||
|
|
||||||
class FairMQLogger
|
class FairMQLogger
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,8 +18,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "FairMQMessage.h"
|
#include "FairMQMessage.h"
|
||||||
|
|
||||||
using std::string;
|
using namespace std;
|
||||||
using std::stringstream;
|
|
||||||
|
|
||||||
class FairMQSocket
|
class FairMQSocket
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
|
|
||||||
FairMQStateMachine::FairMQStateMachine()
|
FairMQStateMachine::FairMQStateMachine()
|
||||||
: fRunningFinished(false)
|
: fRunningFinished(false)
|
||||||
|
, fRunningCondition()
|
||||||
|
, fRunningMutex()
|
||||||
{
|
{
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
@ -59,6 +61,4 @@ void FairMQStateMachine::ChangeState(int event)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << e.what();
|
LOG(ERROR) << e.what();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
@ -47,6 +47,14 @@ namespace FairMQFSM
|
||||||
// defining the boost MSM state machine
|
// defining the boost MSM state machine
|
||||||
struct FairMQFSM_ : public msm::front::state_machine_def<FairMQFSM_>
|
struct FairMQFSM_ : public msm::front::state_machine_def<FairMQFSM_>
|
||||||
{
|
{
|
||||||
|
FairMQFSM_()
|
||||||
|
: fState()
|
||||||
|
, fRunningStateThread()
|
||||||
|
{}
|
||||||
|
|
||||||
|
// Destructor
|
||||||
|
virtual ~FairMQFSM_() {};
|
||||||
|
|
||||||
template <class Event, class FSM>
|
template <class Event, class FSM>
|
||||||
void on_entry(Event const&, FSM&)
|
void on_entry(Event const&, FSM&)
|
||||||
{
|
{
|
||||||
|
@ -109,7 +117,7 @@ namespace FairMQFSM
|
||||||
void operator()(EVT const&, FSM& fsm, SourceState&, TargetState&)
|
void operator()(EVT const&, FSM& fsm, SourceState&, TargetState&)
|
||||||
{
|
{
|
||||||
fsm.fState = RUNNING;
|
fsm.fState = RUNNING;
|
||||||
fsm.running_state = boost::thread(boost::bind(&FairMQFSM_::Run, &fsm));
|
fsm.fRunningStateThread = boost::thread(boost::bind(&FairMQFSM_::Run, &fsm));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct StopFct
|
struct StopFct
|
||||||
|
@ -119,7 +127,7 @@ namespace FairMQFSM
|
||||||
{
|
{
|
||||||
fsm.fState = IDLE;
|
fsm.fState = IDLE;
|
||||||
fsm.Terminate();
|
fsm.Terminate();
|
||||||
fsm.running_state.join();
|
fsm.fRunningStateThread.join();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct PauseFct
|
struct PauseFct
|
||||||
|
@ -128,7 +136,7 @@ namespace FairMQFSM
|
||||||
void operator()(EVT const&, FSM& fsm, SourceState&, TargetState&)
|
void operator()(EVT const&, FSM& fsm, SourceState&, TargetState&)
|
||||||
{
|
{
|
||||||
fsm.fState = WAITING;
|
fsm.fState = WAITING;
|
||||||
fsm.running_state.join();
|
fsm.fRunningStateThread.join();
|
||||||
fsm.Pause();
|
fsm.Pause();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -160,10 +168,10 @@ namespace FairMQFSM
|
||||||
template <class FSM, class Event>
|
template <class FSM, class Event>
|
||||||
void no_transition(Event const& e, FSM&, int state)
|
void no_transition(Event const& e, FSM&, int state)
|
||||||
{
|
{
|
||||||
LOG(STATE) << "no transition from state " << state << " on event " << typeid(e).name() << std::endl;
|
LOG(STATE) << "no transition from state " << state << " on event " << typeid(e).name();
|
||||||
}
|
}
|
||||||
// this is to run certain functions (e.g. Run()) as separate task
|
// this is to run certain functions (e.g. Run()) as separate task
|
||||||
boost::thread running_state;
|
boost::thread fRunningStateThread;
|
||||||
// backward compatibility to FairMQStateMachine
|
// backward compatibility to FairMQStateMachine
|
||||||
enum State
|
enum State
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include "FairMQPoller.h"
|
#include "FairMQPoller.h"
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
|
|
||||||
using std::vector;
|
using namespace std;
|
||||||
|
|
||||||
class FairMQTransportFactory
|
class FairMQTransportFactory
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,6 +46,7 @@ class FairMQBenchmarkSampler : public FairMQDevice
|
||||||
int fEventSize;
|
int fEventSize;
|
||||||
int fEventRate;
|
int fEventRate;
|
||||||
int fEventCounter;
|
int fEventCounter;
|
||||||
|
|
||||||
virtual void Init();
|
virtual void Init();
|
||||||
virtual void Run();
|
virtual void Run();
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
|
|
||||||
FairMQExampleClient::FairMQExampleClient()
|
FairMQExampleClient::FairMQExampleClient()
|
||||||
|
: fText()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ typedef struct DeviceOptions
|
||||||
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
{
|
{
|
||||||
if (_options == NULL)
|
if (_options == NULL)
|
||||||
throw std::runtime_error("Internal error: options' container is empty.");
|
throw runtime_error("Internal error: options' container is empty.");
|
||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
bpo::options_description desc("Options");
|
bpo::options_description desc("Options");
|
||||||
|
|
|
@ -20,14 +20,19 @@
|
||||||
#include "FairMQMessageNN.h"
|
#include "FairMQMessageNN.h"
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
FairMQMessageNN::FairMQMessageNN()
|
FairMQMessageNN::FairMQMessageNN()
|
||||||
: fSize(0)
|
: fMessage(NULL)
|
||||||
, fMessage(NULL)
|
, fSize(0)
|
||||||
, fReceiving(false)
|
, fReceiving(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQMessageNN::FairMQMessageNN(size_t size)
|
FairMQMessageNN::FairMQMessageNN(size_t size)
|
||||||
|
: fMessage(NULL)
|
||||||
|
, fSize(0)
|
||||||
|
, fReceiving(false)
|
||||||
{
|
{
|
||||||
fMessage = nn_allocmsg(size, 0);
|
fMessage = nn_allocmsg(size, 0);
|
||||||
if (!fMessage)
|
if (!fMessage)
|
||||||
|
@ -45,6 +50,9 @@ FairMQMessageNN::FairMQMessageNN(size_t size)
|
||||||
* possible TODO: make this zero copy (will should then be as efficient as ZeroMQ).
|
* possible TODO: make this zero copy (will should then be as efficient as ZeroMQ).
|
||||||
*/
|
*/
|
||||||
FairMQMessageNN::FairMQMessageNN(void* data, size_t size, fairmq_free_fn *ffn, void* hint)
|
FairMQMessageNN::FairMQMessageNN(void* data, size_t size, fairmq_free_fn *ffn, void* hint)
|
||||||
|
: fMessage(NULL)
|
||||||
|
, fSize(0)
|
||||||
|
, fReceiving(false)
|
||||||
{
|
{
|
||||||
fMessage = nn_allocmsg(size, 0);
|
fMessage = nn_allocmsg(size, 0);
|
||||||
if (!fMessage)
|
if (!fMessage)
|
||||||
|
@ -146,7 +154,7 @@ void FairMQMessageNN::Copy(FairMQMessage* msg)
|
||||||
{
|
{
|
||||||
LOG(ERROR) << "failed allocating message, reason: " << nn_strerror(errno);
|
LOG(ERROR) << "failed allocating message, reason: " << nn_strerror(errno);
|
||||||
}
|
}
|
||||||
std::memcpy(fMessage, msg->GetMessage(), size);
|
memcpy(fMessage, msg->GetMessage(), size);
|
||||||
fSize = size;
|
fSize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,10 @@ class FairMQMessageNN : public FairMQMessage
|
||||||
bool fReceiving;
|
bool fReceiving;
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
|
/// Copy Constructor
|
||||||
|
FairMQMessageNN(const FairMQMessageNN&);
|
||||||
|
FairMQMessageNN operator=(const FairMQMessageNN&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FAIRMQMESSAGENN_H_ */
|
#endif /* FAIRMQMESSAGENN_H_ */
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
#include "FairMQPollerNN.h"
|
#include "FairMQPollerNN.h"
|
||||||
|
|
||||||
FairMQPollerNN::FairMQPollerNN(const vector<FairMQSocket*>& inputs)
|
FairMQPollerNN::FairMQPollerNN(const vector<FairMQSocket*>& inputs)
|
||||||
|
: items()
|
||||||
|
, fNumItems()
|
||||||
{
|
{
|
||||||
fNumItems = inputs.size();
|
fNumItems = inputs.size();
|
||||||
items = new nn_pollfd[fNumItems];
|
items = new nn_pollfd[fNumItems];
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "FairMQPoller.h"
|
#include "FairMQPoller.h"
|
||||||
#include "FairMQSocket.h"
|
#include "FairMQSocket.h"
|
||||||
|
|
||||||
using std::vector;
|
using namespace std;
|
||||||
|
|
||||||
class FairMQPollerNN : public FairMQPoller
|
class FairMQPollerNN : public FairMQPoller
|
||||||
{
|
{
|
||||||
|
@ -36,6 +36,10 @@ class FairMQPollerNN : public FairMQPoller
|
||||||
private:
|
private:
|
||||||
nn_pollfd* items;
|
nn_pollfd* items;
|
||||||
int fNumItems;
|
int fNumItems;
|
||||||
|
|
||||||
|
/// Copy Constructor
|
||||||
|
FairMQPollerNN(const FairMQPollerNN&);
|
||||||
|
FairMQPollerNN operator=(const FairMQPollerNN&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FAIRMQPOLLERNN_H_ */
|
#endif /* FAIRMQPOLLERNN_H_ */
|
|
@ -19,7 +19,9 @@
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
|
|
||||||
FairMQSocketNN::FairMQSocketNN(const string& type, int num, int numIoThreads)
|
FairMQSocketNN::FairMQSocketNN(const string& type, int num, int numIoThreads)
|
||||||
: fBytesTx(0)
|
: fSocket()
|
||||||
|
, fId()
|
||||||
|
, fBytesTx(0)
|
||||||
, fBytesRx(0)
|
, fBytesRx(0)
|
||||||
, fMessagesTx(0)
|
, fMessagesTx(0)
|
||||||
, fMessagesRx(0)
|
, fMessagesRx(0)
|
||||||
|
|
|
@ -65,7 +65,7 @@ void FairMQProtoSampler::Run()
|
||||||
// LOG(INFO) << content->x() << " " << content->y() << " " << content->z() << " " << content->a() << " " << content->b();
|
// LOG(INFO) << content->x() << " " << content->y() << " " << content->z() << " " << content->a() << " " << content->b();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string str;
|
string str;
|
||||||
p.SerializeToString(&str);
|
p.SerializeToString(&str);
|
||||||
size_t size = str.length();
|
size_t size = str.length();
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
#include "FairMQDevice.h"
|
#include "FairMQDevice.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
class FairMQProtoSampler : public FairMQDevice
|
class FairMQProtoSampler : public FairMQDevice
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -66,7 +66,7 @@ typedef struct DeviceOptions
|
||||||
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
{
|
{
|
||||||
if (_options == NULL)
|
if (_options == NULL)
|
||||||
throw std::runtime_error("Internal error: options' container is empty.");
|
throw runtime_error("Internal error: options' container is empty.");
|
||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
bpo::options_description desc("Options");
|
bpo::options_description desc("Options");
|
||||||
|
|
|
@ -66,7 +66,7 @@ typedef struct DeviceOptions
|
||||||
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
{
|
{
|
||||||
if (_options == NULL)
|
if (_options == NULL)
|
||||||
throw std::runtime_error("Internal error: options' container is empty.");
|
throw runtime_error("Internal error: options' container is empty.");
|
||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
bpo::options_description desc("Options");
|
bpo::options_description desc("Options");
|
||||||
|
|
|
@ -64,7 +64,7 @@ typedef struct DeviceOptions
|
||||||
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
{
|
{
|
||||||
if (_options == NULL)
|
if (_options == NULL)
|
||||||
throw std::runtime_error("Internal error: options' container is empty.");
|
throw runtime_error("Internal error: options' container is empty.");
|
||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
bpo::options_description desc("Options");
|
bpo::options_description desc("Options");
|
||||||
|
|
|
@ -68,7 +68,7 @@ typedef struct DeviceOptions
|
||||||
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
{
|
{
|
||||||
if (_options == NULL)
|
if (_options == NULL)
|
||||||
throw std::runtime_error("Internal error: options' container is empty.");
|
throw runtime_error("Internal error: options' container is empty.");
|
||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
bpo::options_description desc("Options");
|
bpo::options_description desc("Options");
|
||||||
|
|
|
@ -69,7 +69,7 @@ typedef struct DeviceOptions
|
||||||
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
{
|
{
|
||||||
if (_options == NULL)
|
if (_options == NULL)
|
||||||
throw std::runtime_error("Internal error: options' container is empty.");
|
throw runtime_error("Internal error: options' container is empty.");
|
||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
bpo::options_description desc("Options");
|
bpo::options_description desc("Options");
|
||||||
|
|
|
@ -66,7 +66,7 @@ typedef struct DeviceOptions
|
||||||
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
{
|
{
|
||||||
if (_options == NULL)
|
if (_options == NULL)
|
||||||
throw std::runtime_error("Internal error: options' container is empty.");
|
throw runtime_error("Internal error: options' container is empty.");
|
||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
bpo::options_description desc("Options");
|
bpo::options_description desc("Options");
|
||||||
|
|
|
@ -64,7 +64,7 @@ typedef struct DeviceOptions
|
||||||
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
{
|
{
|
||||||
if (_options == NULL)
|
if (_options == NULL)
|
||||||
throw std::runtime_error("Internal error: options' container is empty.");
|
throw runtime_error("Internal error: options' container is empty.");
|
||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
bpo::options_description desc("Options");
|
bpo::options_description desc("Options");
|
||||||
|
|
|
@ -68,7 +68,7 @@ typedef struct DeviceOptions
|
||||||
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
{
|
{
|
||||||
if (_options == NULL)
|
if (_options == NULL)
|
||||||
throw std::runtime_error("Internal error: options' container is empty.");
|
throw runtime_error("Internal error: options' container is empty.");
|
||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
bpo::options_description desc("Options");
|
bpo::options_description desc("Options");
|
||||||
|
|
|
@ -64,7 +64,7 @@ typedef struct DeviceOptions
|
||||||
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
{
|
{
|
||||||
if (_options == NULL)
|
if (_options == NULL)
|
||||||
throw std::runtime_error("Internal error: options' container is empty.");
|
throw runtime_error("Internal error: options' container is empty.");
|
||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
bpo::options_description desc("Options");
|
bpo::options_description desc("Options");
|
||||||
|
|
|
@ -69,7 +69,7 @@ typedef struct DeviceOptions
|
||||||
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
inline bool parse_cmd_line(int _argc, char* _argv[], DeviceOptions* _options)
|
||||||
{
|
{
|
||||||
if (_options == NULL)
|
if (_options == NULL)
|
||||||
throw std::runtime_error("Internal error: options' container is empty.");
|
throw runtime_error("Internal error: options' container is empty.");
|
||||||
|
|
||||||
namespace bpo = boost::program_options;
|
namespace bpo = boost::program_options;
|
||||||
bpo::options_description desc("Options");
|
bpo::options_description desc("Options");
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
FairMQContextZMQ::FairMQContextZMQ(int numIoThreads)
|
FairMQContextZMQ::FairMQContextZMQ(int numIoThreads)
|
||||||
|
: fContext()
|
||||||
{
|
{
|
||||||
fContext = zmq_ctx_new();
|
fContext = zmq_ctx_new();
|
||||||
if (fContext == NULL)
|
if (fContext == NULL)
|
||||||
|
|
|
@ -20,13 +20,20 @@
|
||||||
class FairMQContextZMQ
|
class FairMQContextZMQ
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
/// Constructor
|
||||||
FairMQContextZMQ(int numIoThreads);
|
FairMQContextZMQ(int numIoThreads);
|
||||||
|
|
||||||
virtual ~FairMQContextZMQ();
|
virtual ~FairMQContextZMQ();
|
||||||
void* GetContext();
|
void* GetContext();
|
||||||
void Close();
|
void Close();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void* fContext;
|
void* fContext;
|
||||||
|
|
||||||
|
/// Copy Constructor
|
||||||
|
FairMQContextZMQ(const FairMQContextZMQ&);
|
||||||
|
FairMQContextZMQ operator=(const FairMQContextZMQ&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FAIRMQCONTEXTZMQ_H_ */
|
#endif /* FAIRMQCONTEXTZMQ_H_ */
|
||||||
|
|
|
@ -18,7 +18,10 @@
|
||||||
#include "FairMQMessageZMQ.h"
|
#include "FairMQMessageZMQ.h"
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
FairMQMessageZMQ::FairMQMessageZMQ()
|
FairMQMessageZMQ::FairMQMessageZMQ()
|
||||||
|
: fMessage()
|
||||||
{
|
{
|
||||||
int rc = zmq_msg_init(&fMessage);
|
int rc = zmq_msg_init(&fMessage);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
|
@ -28,6 +31,7 @@ FairMQMessageZMQ::FairMQMessageZMQ()
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQMessageZMQ::FairMQMessageZMQ(size_t size)
|
FairMQMessageZMQ::FairMQMessageZMQ(size_t size)
|
||||||
|
: fMessage()
|
||||||
{
|
{
|
||||||
int rc = zmq_msg_init_size(&fMessage, size);
|
int rc = zmq_msg_init_size(&fMessage, size);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
|
@ -37,6 +41,7 @@ FairMQMessageZMQ::FairMQMessageZMQ(size_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
FairMQMessageZMQ::FairMQMessageZMQ(void* data, size_t size, fairmq_free_fn *ffn, void* hint)
|
FairMQMessageZMQ::FairMQMessageZMQ(void* data, size_t size, fairmq_free_fn *ffn, void* hint)
|
||||||
|
: fMessage()
|
||||||
{
|
{
|
||||||
int rc = zmq_msg_init_data(&fMessage, data, size, ffn ? ffn : &CleanUp, hint);
|
int rc = zmq_msg_init_data(&fMessage, data, size, ffn ? ffn : &CleanUp, hint);
|
||||||
if (rc != 0)
|
if (rc != 0)
|
||||||
|
@ -109,7 +114,7 @@ void FairMQMessageZMQ::Copy(FairMQMessage* msg)
|
||||||
// CloseMessage();
|
// CloseMessage();
|
||||||
// size_t size = msg->GetSize();
|
// size_t size = msg->GetSize();
|
||||||
// zmq_msg_init_size(&fMessage, size);
|
// zmq_msg_init_size(&fMessage, size);
|
||||||
// std::memcpy(zmq_msg_data(&fMessage), msg->GetData(), size);
|
// memcpy(zmq_msg_data(&fMessage), msg->GetData(), size);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void FairMQMessageZMQ::CloseMessage()
|
inline void FairMQMessageZMQ::CloseMessage()
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
#include "FairMQLogger.h"
|
#include "FairMQLogger.h"
|
||||||
|
|
||||||
FairMQPollerZMQ::FairMQPollerZMQ(const vector<FairMQSocket*>& inputs)
|
FairMQPollerZMQ::FairMQPollerZMQ(const vector<FairMQSocket*>& inputs)
|
||||||
|
: items()
|
||||||
|
, fNumItems()
|
||||||
{
|
{
|
||||||
fNumItems = inputs.size();
|
fNumItems = inputs.size();
|
||||||
items = new zmq_pollitem_t[fNumItems];
|
items = new zmq_pollitem_t[fNumItems];
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "FairMQPoller.h"
|
#include "FairMQPoller.h"
|
||||||
#include "FairMQSocket.h"
|
#include "FairMQSocket.h"
|
||||||
|
|
||||||
using std::vector;
|
using namespace std;
|
||||||
|
|
||||||
class FairMQPollerZMQ : public FairMQPoller
|
class FairMQPollerZMQ : public FairMQPoller
|
||||||
{
|
{
|
||||||
|
@ -36,6 +36,10 @@ class FairMQPollerZMQ : public FairMQPoller
|
||||||
private:
|
private:
|
||||||
zmq_pollitem_t* items;
|
zmq_pollitem_t* items;
|
||||||
int fNumItems;
|
int fNumItems;
|
||||||
|
|
||||||
|
/// Copy Constructor
|
||||||
|
FairMQPollerZMQ(const FairMQPollerZMQ&);
|
||||||
|
FairMQPollerZMQ operator=(const FairMQPollerZMQ&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FAIRMQPOLLERZMQ_H_ */
|
#endif /* FAIRMQPOLLERZMQ_H_ */
|
|
@ -20,7 +20,9 @@
|
||||||
boost::shared_ptr<FairMQContextZMQ> FairMQSocketZMQ::fContext = boost::shared_ptr<FairMQContextZMQ>(new FairMQContextZMQ(1));
|
boost::shared_ptr<FairMQContextZMQ> FairMQSocketZMQ::fContext = boost::shared_ptr<FairMQContextZMQ>(new FairMQContextZMQ(1));
|
||||||
|
|
||||||
FairMQSocketZMQ::FairMQSocketZMQ(const string& type, int num, int numIoThreads)
|
FairMQSocketZMQ::FairMQSocketZMQ(const string& type, int num, int numIoThreads)
|
||||||
: fBytesTx(0)
|
: fSocket(NULL)
|
||||||
|
, fId()
|
||||||
|
, fBytesTx(0)
|
||||||
, fBytesRx(0)
|
, fBytesRx(0)
|
||||||
, fMessagesTx(0)
|
, fMessagesTx(0)
|
||||||
, fMessagesRx(0)
|
, fMessagesRx(0)
|
||||||
|
|
|
@ -61,6 +61,10 @@ class FairMQSocketZMQ : public FairMQSocket
|
||||||
unsigned long fMessagesRx;
|
unsigned long fMessagesRx;
|
||||||
|
|
||||||
static boost::shared_ptr<FairMQContextZMQ> fContext;
|
static boost::shared_ptr<FairMQContextZMQ> fContext;
|
||||||
|
|
||||||
|
/// Copy Constructor
|
||||||
|
FairMQSocketZMQ(const FairMQSocketZMQ&);
|
||||||
|
FairMQSocketZMQ operator=(const FairMQSocketZMQ&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* FAIRMQSOCKETZMQ_H_ */
|
#endif /* FAIRMQSOCKETZMQ_H_ */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user