use clang-format for Tutorial3

This commit is contained in:
Alexey Rybalchenko 2014-06-06 11:48:52 +02:00
parent 08e603911d
commit c03d4ad6d5
7 changed files with 127 additions and 105 deletions

View File

@ -32,7 +32,8 @@ void FairMQDevice::Init()
fInputSndBufSize = new vector<int>(); fInputSndBufSize = new vector<int>();
fInputRcvBufSize = new vector<int>(); fInputRcvBufSize = new vector<int>();
for (int i = 0; i < fNumInputs; ++i) { for (int i = 0; i < fNumInputs; ++i)
{
fInputMethod->push_back("connect"); // default value, can be overwritten in configuration fInputMethod->push_back("connect"); // default value, can be overwritten in configuration
fInputSocketType->push_back("sub"); // default value, can be overwritten in configuration fInputSocketType->push_back("sub"); // default value, can be overwritten in configuration
fInputSndBufSize->push_back(10000); // default value, can be overwritten in configuration fInputSndBufSize->push_back(10000); // default value, can be overwritten in configuration
@ -45,7 +46,8 @@ void FairMQDevice::Init()
fOutputSndBufSize = new vector<int>(); fOutputSndBufSize = new vector<int>();
fOutputRcvBufSize = new vector<int>(); fOutputRcvBufSize = new vector<int>();
for (int i = 0; i < fNumOutputs; ++i) { for (int i = 0; i < fNumOutputs; ++i)
{
fOutputMethod->push_back("bind"); // default value, can be overwritten in configuration fOutputMethod->push_back("bind"); // default value, can be overwritten in configuration
fOutputSocketType->push_back("pub"); // default value, can be overwritten in configuration fOutputSocketType->push_back("pub"); // default value, can be overwritten in configuration
fOutputSndBufSize->push_back(10000); // default value, can be overwritten in configuration fOutputSndBufSize->push_back(10000); // default value, can be overwritten in configuration
@ -57,7 +59,8 @@ void FairMQDevice::InitInput()
{ {
LOG(INFO) << ">>>>>>> InitInput <<<<<<<"; LOG(INFO) << ">>>>>>> InitInput <<<<<<<";
for (int i = 0; i < fNumInputs; ++i) { for (int i = 0; i < fNumInputs; ++i)
{
FairMQSocket* socket = fTransportFactory->CreateSocket(fInputSocketType->at(i), i, fNumIoThreads); FairMQSocket* socket = fTransportFactory->CreateSocket(fInputSocketType->at(i), i, fNumIoThreads);
socket->SetOption("snd-hwm", &fInputSndBufSize->at(i), sizeof(fInputSndBufSize->at(i))); socket->SetOption("snd-hwm", &fInputSndBufSize->at(i), sizeof(fInputSndBufSize->at(i)));
@ -65,13 +68,19 @@ void FairMQDevice::InitInput()
fPayloadInputs->push_back(socket); fPayloadInputs->push_back(socket);
try { try
if (fInputMethod->at(i) == "bind") { {
if (fInputMethod->at(i) == "bind")
{
fPayloadInputs->at(i)->Bind(fInputAddress->at(i)); fPayloadInputs->at(i)->Bind(fInputAddress->at(i));
} else { }
else
{
fPayloadInputs->at(i)->Connect(fInputAddress->at(i)); fPayloadInputs->at(i)->Connect(fInputAddress->at(i));
} }
} catch (std::out_of_range& e) { }
catch (std::out_of_range& e)
{
} }
} }
} }
@ -80,7 +89,8 @@ void FairMQDevice::InitOutput()
{ {
LOG(INFO) << ">>>>>>> InitOutput <<<<<<<"; LOG(INFO) << ">>>>>>> InitOutput <<<<<<<";
for (int i = 0; i < fNumOutputs; ++i) { for (int i = 0; i < fNumOutputs; ++i)
{
FairMQSocket* socket = fTransportFactory->CreateSocket(fOutputSocketType->at(i), i, fNumIoThreads); FairMQSocket* socket = fTransportFactory->CreateSocket(fOutputSocketType->at(i), i, fNumIoThreads);
socket->SetOption("snd-hwm", &fOutputSndBufSize->at(i), sizeof(fOutputSndBufSize->at(i))); socket->SetOption("snd-hwm", &fOutputSndBufSize->at(i), sizeof(fOutputSndBufSize->at(i)));
@ -88,13 +98,19 @@ void FairMQDevice::InitOutput()
fPayloadOutputs->push_back(socket); fPayloadOutputs->push_back(socket);
try { try
if (fOutputMethod->at(i) == "bind") { {
if (fOutputMethod->at(i) == "bind")
{
fPayloadOutputs->at(i)->Bind(fOutputAddress->at(i)); fPayloadOutputs->at(i)->Bind(fOutputAddress->at(i));
} else { }
else
{
fPayloadOutputs->at(i)->Connect(fOutputAddress->at(i)); fPayloadOutputs->at(i)->Connect(fOutputAddress->at(i));
} }
} catch (std::out_of_range& e) { }
catch (std::out_of_range& e)
{
} }
} }
} }

View File

@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
find . -type f \( -iname "*.h" ! -iname "*.pb.h" -o -iname "*.cxx" \) -execdir clang-format -i {} \; find . -type f \( -iname "*.h" ! -iname "*.pb.h" ! -iname "*LinkDef.h" -o -iname "*.cxx" -o -iname "*.tpl" \) -execdir clang-format -i {} \;

View File

@ -11,22 +11,24 @@
#include "FairMQMessageNN.h" #include "FairMQMessageNN.h"
#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), : fBytesTx(0)
fBytesRx(0), , fBytesRx(0)
fMessagesTx(0), , fMessagesTx(0)
fMessagesRx(0) , fMessagesRx(0)
{ {
stringstream id; stringstream id;
id << type << "." << num; id << type << "." << num;
fId = id.str(); fId = id.str();
if ( numIoThreads > 1 ) { if (numIoThreads > 1)
{
LOG(INFO) << "number of I/O threads is not used in nanomsg"; LOG(INFO) << "number of I/O threads is not used in nanomsg";
} }
fSocket = nn_socket(AF_SP, GetConstant(type)); fSocket = nn_socket(AF_SP, GetConstant(type));
if (type == "sub") { if (type == "sub")
{
nn_setsockopt(fSocket, NN_SUB, NN_SUB_SUBSCRIBE, NULL, 0); nn_setsockopt(fSocket, NN_SUB, NN_SUB_SUBSCRIBE, NULL, 0);
} }

View File

@ -12,31 +12,35 @@
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), : fBytesTx(0)
fBytesRx(0), , fBytesRx(0)
fMessagesTx(0), , fMessagesTx(0)
fMessagesRx(0) , fMessagesRx(0)
{ {
stringstream id; stringstream id;
id << type << "." << num; id << type << "." << num;
fId = id.str(); fId = id.str();
int rc = zmq_ctx_set(fContext->GetContext(), ZMQ_IO_THREADS, numIoThreads); int rc = zmq_ctx_set(fContext->GetContext(), ZMQ_IO_THREADS, numIoThreads);
if (rc != 0){ if (rc != 0)
{
LOG(ERROR) << "failed configuring context, reason: " << zmq_strerror(errno); LOG(ERROR) << "failed configuring context, reason: " << zmq_strerror(errno);
} }
fSocket = zmq_socket(fContext->GetContext(), GetConstant(type)); fSocket = zmq_socket(fContext->GetContext(), GetConstant(type));
rc = zmq_setsockopt(fSocket, ZMQ_IDENTITY, &fId, fId.length()); rc = zmq_setsockopt(fSocket, ZMQ_IDENTITY, &fId, fId.length());
if (rc != 0) { if (rc != 0)
{
LOG(ERROR) << "failed setting socket option, reason: " << zmq_strerror(errno); LOG(ERROR) << "failed setting socket option, reason: " << zmq_strerror(errno);
} }
if (type == "sub") { if (type == "sub")
{
rc = zmq_setsockopt(fSocket, ZMQ_SUBSCRIBE, NULL, 0); rc = zmq_setsockopt(fSocket, ZMQ_SUBSCRIBE, NULL, 0);
if (rc != 0) { if (rc != 0)
{
LOG(ERROR) << "failed setting socket option, reason: " << zmq_strerror(errno); LOG(ERROR) << "failed setting socket option, reason: " << zmq_strerror(errno);
} }
} }