mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-12 16:21:13 +00:00
Apply readability-container-size-empty
This commit is contained in:
parent
f25cca2073
commit
c847a7ca02
|
@ -49,7 +49,7 @@ bool DeviceRunner::HandleGeneralOptions(const fair::mq::ProgOptions& config, boo
|
|||
string verbosity = config.GetProperty<string>("verbosity");
|
||||
fair::Logger::SetVerbosity(verbosity);
|
||||
|
||||
if (logFile != "") {
|
||||
if (!logFile.empty()) {
|
||||
fair::Logger::InitFileSink(logFileSeverity, logFile);
|
||||
fair::Logger::SetConsoleSeverity("nolog");
|
||||
} else {
|
||||
|
@ -58,7 +58,7 @@ bool DeviceRunner::HandleGeneralOptions(const fair::mq::ProgOptions& config, boo
|
|||
if (envFairMQSeverity) {
|
||||
severity = envFairMQSeverity;
|
||||
}
|
||||
if (severity != "") {
|
||||
if (!severity.empty()) {
|
||||
fair::Logger::SetConsoleSeverity(severity);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -190,7 +190,7 @@ try {
|
|||
}
|
||||
|
||||
// validate socket address
|
||||
if (fAddress == "unspecified" || fAddress == "") {
|
||||
if (fAddress == "unspecified" || fAddress.empty()) {
|
||||
ss << "INVALID";
|
||||
LOG(debug) << ss.str();
|
||||
LOG(debug) << "invalid channel address: '" << fAddress << "'";
|
||||
|
@ -226,7 +226,7 @@ try {
|
|||
} else if (address.compare(0, 6, "ipc://") == 0) {
|
||||
// check if IPC address is not empty
|
||||
string addressString = address.substr(6);
|
||||
if (addressString == "") {
|
||||
if (addressString.empty()) {
|
||||
ss << "INVALID";
|
||||
LOG(debug) << ss.str();
|
||||
LOG(error) << "invalid channel address: '" << address << "' (empty IPC address?)";
|
||||
|
@ -235,7 +235,7 @@ try {
|
|||
} else if (address.compare(0, 9, "inproc://") == 0) {
|
||||
// check if IPC address is not empty
|
||||
string addressString = address.substr(9);
|
||||
if (addressString == "") {
|
||||
if (addressString.empty()) {
|
||||
ss << "INVALID";
|
||||
LOG(debug) << ss.str();
|
||||
LOG(error) << "invalid channel address: '" << address << "' (empty inproc address?)";
|
||||
|
@ -244,7 +244,7 @@ try {
|
|||
} else if (address.compare(0, 8, "verbs://") == 0) {
|
||||
// check if IPC address is not empty
|
||||
string addressString = address.substr(8);
|
||||
if (addressString == "") {
|
||||
if (addressString.empty()) {
|
||||
ss << "INVALID";
|
||||
LOG(debug) << ss.str();
|
||||
LOG(error) << "invalid channel address: '" << address << "' (empty verbs address?)";
|
||||
|
|
|
@ -246,7 +246,7 @@ void FairMQDevice::InitWrapper()
|
|||
|
||||
if (subChannel.fMethod == "bind") {
|
||||
// if binding address is not specified, try getting it from the configured network interface
|
||||
if (subChannel.fAddress == "unspecified" || subChannel.fAddress == "") {
|
||||
if (subChannel.fAddress == "unspecified" || subChannel.fAddress.empty()) {
|
||||
// if the configured network interface is default, get its name from the default route
|
||||
try {
|
||||
if (networkInterface == "default") {
|
||||
|
@ -381,7 +381,7 @@ bool FairMQDevice::AttachChannel(FairMQChannel& chan)
|
|||
if (!(bind && hostPart == "*")) {
|
||||
string portPart = addressString.substr(pos + 1);
|
||||
string resolvedHost = tools::getIpFromHostname(hostPart);
|
||||
if (resolvedHost == "") {
|
||||
if (resolvedHost.empty()) {
|
||||
return false;
|
||||
}
|
||||
address.assign("tcp://" + resolvedHost + ":" + portPart);
|
||||
|
@ -490,11 +490,11 @@ void FairMQDevice::HandleSingleChannelInput()
|
|||
{
|
||||
bool proceed = true;
|
||||
|
||||
if (fMsgInputs.size() > 0) {
|
||||
if (!fMsgInputs.empty()) {
|
||||
while (!NewStatePending() && proceed) {
|
||||
proceed = HandleMsgInput(fInputChannelKeys.at(0), fMsgInputs.begin()->second, 0);
|
||||
}
|
||||
} else if (fMultipartInputs.size() > 0) {
|
||||
} else if (!fMultipartInputs.empty()) {
|
||||
while (!NewStatePending() && proceed) {
|
||||
proceed = HandleMultipartInput(fInputChannelKeys.at(0), fMultipartInputs.begin()->second, 0);
|
||||
}
|
||||
|
|
|
@ -324,7 +324,7 @@ class FairMQDevice
|
|||
|
||||
void PrintRegisteredChannels()
|
||||
{
|
||||
if (fChannelRegistry.size() < 1) {
|
||||
if (fChannelRegistry.empty()) {
|
||||
LOGV(info, verylow) << "no channels registered.";
|
||||
} else {
|
||||
for (const auto& c : fChannelRegistry) {
|
||||
|
|
|
@ -35,7 +35,7 @@ auto FairMQTransportFactory::CreateTransportFactory(const string& type,
|
|||
auto finalId = id;
|
||||
|
||||
// Generate uuid if empty
|
||||
if (finalId == "") {
|
||||
if (finalId.empty()) {
|
||||
finalId = fair::mq::tools::Uuid();
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ namespace fair::mq
|
|||
|
||||
fair::mq::Properties PtreeParser(const ptree& pt, const string& id)
|
||||
{
|
||||
if (id == "") {
|
||||
if (id.empty()) {
|
||||
throw ParserError("no device ID provided. Provide with `--id` cmd option");
|
||||
}
|
||||
|
||||
|
|
|
@ -242,7 +242,7 @@ Properties ProgOptions::GetProperties(const string& q) const
|
|||
}
|
||||
}
|
||||
|
||||
if (properties.size() == 0) {
|
||||
if (properties.empty()) {
|
||||
LOG(warn) << "could not find anything with \"" << q << "\"";
|
||||
}
|
||||
|
||||
|
@ -277,7 +277,7 @@ map<string, string> ProgOptions::GetPropertiesAsString(const string& q) const
|
|||
}
|
||||
}
|
||||
|
||||
if (properties.size() == 0) {
|
||||
if (properties.empty()) {
|
||||
LOG(warn) << "could not find anything with \"" << q << "\"";
|
||||
}
|
||||
|
||||
|
@ -439,7 +439,7 @@ void ProgOptions::PrintOptionsRaw() const
|
|||
|
||||
replace(description.begin(), description.end(), '\n', ' ');
|
||||
|
||||
cout << o->long_name() << ":" << value.value << ":" << (value.type == "" ? "<unknown>" : value.type) << ":" << description << endl;
|
||||
cout << o->long_name() << ":" << value.value << ":" << (value.type.empty() ? "<unknown>" : value.type) << ":" << description << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class PropertyHelper
|
|||
template<typename T>
|
||||
static void AddType(std::string label = "")
|
||||
{
|
||||
if (label == "") {
|
||||
if (label.empty()) {
|
||||
label = boost::core::demangle(typeid(T).name());
|
||||
}
|
||||
fTypeInfos[std::type_index(typeid(T))] = [label](const Property& p) {
|
||||
|
|
|
@ -109,7 +109,7 @@ Properties SuboptParser(const vector<string>& channelConfig, const string& devic
|
|||
}
|
||||
}
|
||||
|
||||
if (channelName != "") {
|
||||
if (!channelName.empty()) {
|
||||
channelProperties.add_child("sockets", socketsArray);
|
||||
} else {
|
||||
// TODO: what is the error policy here, should we abort?
|
||||
|
|
|
@ -31,7 +31,7 @@ Config::Config(const string& name, const Plugin::Version version, const string&
|
|||
idForParser = GetProperty<string>("id");
|
||||
}
|
||||
|
||||
if (idForParser != "") {
|
||||
if (!idForParser.empty()) {
|
||||
try {
|
||||
if (PropertyExists("mq-config")) {
|
||||
LOG(debug) << "mq-config: Using default JSON parser";
|
||||
|
|
|
@ -67,7 +67,7 @@ auto DDSTopology::GetTasks(const std::string& path /* = "" */) const -> std::vec
|
|||
std::vector<DDSTask> list;
|
||||
|
||||
dds::topology_api::STopoRuntimeTask::FilterIteratorPair_t itPair;
|
||||
if (path == "") {
|
||||
if (path.empty()) {
|
||||
itPair = fImpl->fTopo.getRuntimeTaskIterator(nullptr); // passing nullptr will get all tasks
|
||||
} else {
|
||||
itPair = fImpl->fTopo.getRuntimeTaskIteratorMatchingPath(path);
|
||||
|
|
|
@ -1066,7 +1066,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
|
|||
{
|
||||
if (!fOp.IsCompleted() && fCount == fExpectedCount) {
|
||||
fTimer.cancel();
|
||||
if (fResult.failed.size() > 0) {
|
||||
if (!fResult.failed.empty()) {
|
||||
fOp.Complete(MakeErrorCode(ErrorCode::DeviceGetPropertiesFailed), std::move(fResult));
|
||||
} else {
|
||||
fOp.Complete(std::move(fResult));
|
||||
|
@ -1221,7 +1221,7 @@ class BasicTopology : public AsioBase<Executor, Allocator>
|
|||
{
|
||||
if (!fOp.IsCompleted() && fCount == fExpectedCount) {
|
||||
fTimer.cancel();
|
||||
if (fFailedDevices.size() > 0) {
|
||||
if (!fFailedDevices.empty()) {
|
||||
fOp.Complete(MakeErrorCode(ErrorCode::DeviceSetPropertiesFailed), fFailedDevices);
|
||||
} else {
|
||||
fOp.Complete(fFailedDevices);
|
||||
|
|
|
@ -76,7 +76,7 @@ void handleCommand(const string& command, const string& path, unsigned int timeo
|
|||
}
|
||||
return;
|
||||
} else if (command == "o") {
|
||||
cout << "> dumping config of " << (path == "" ? "all" : path) << endl;
|
||||
cout << "> dumping config of " << (path.empty() ? "all" : path) << endl;
|
||||
// TODO: extend this regex to return all properties, once command size limitation is removed.
|
||||
auto const result = topo.GetProperties("^(session|id)$", path, std::chrono::milliseconds(timeout));
|
||||
if (result.first != std::error_code()) {
|
||||
|
@ -90,12 +90,12 @@ void handleCommand(const string& command, const string& path, unsigned int timeo
|
|||
}
|
||||
return;
|
||||
} else if (command == "p") {
|
||||
if (pKey == "" || pVal == "") {
|
||||
if (pKey.empty() || pVal.empty()) {
|
||||
cout << "cannot send property with empty key and/or value! given key: '" << pKey << "', value: '" << pVal << "'." << endl;
|
||||
throw runtime_error(tools::ToString("cannot send property with empty key and/or value! given key: '", pKey, "', value: '", pVal, "'."));
|
||||
}
|
||||
const DeviceProperties props{{pKey, pVal}};
|
||||
cout << "> setting properties --> " << (path == "" ? "all" : path) << endl;
|
||||
cout << "> setting properties --> " << (path.empty() ? "all" : path) << endl;
|
||||
auto const result = topo.SetProperties(props, path);
|
||||
if (result.first != std::error_code()) {
|
||||
cout << "ERROR: SetProperties failed for '" << path << "': " << result.first.message() << endl;
|
||||
|
@ -105,34 +105,34 @@ void handleCommand(const string& command, const string& path, unsigned int timeo
|
|||
this_thread::sleep_for(chrono::milliseconds(100));
|
||||
return;
|
||||
} else if (command == "i") {
|
||||
cout << "> initiating InitDevice transition --> " << (path == "" ? "all" : path) << endl;
|
||||
cout << "> initiating InitDevice transition --> " << (path.empty() ? "all" : path) << endl;
|
||||
changeStateResult = topo.ChangeState(TopologyTransition::InitDevice, path, std::chrono::milliseconds(timeout));
|
||||
} else if (command == "k") {
|
||||
cout << "> initiating CompleteInit transition --> " << (path == "" ? "all" : path) << endl;
|
||||
cout << "> initiating CompleteInit transition --> " << (path.empty() ? "all" : path) << endl;
|
||||
changeStateResult = topo.ChangeState(TopologyTransition::CompleteInit, path, std::chrono::milliseconds(timeout));
|
||||
} else if (command == "b") {
|
||||
cout << "> initiating Bind transition --> " << (path == "" ? "all" : path) << endl;
|
||||
cout << "> initiating Bind transition --> " << (path.empty() ? "all" : path) << endl;
|
||||
changeStateResult = topo.ChangeState(TopologyTransition::Bind, path, std::chrono::milliseconds(timeout));
|
||||
} else if (command == "x") {
|
||||
cout << "> initiating Connect transition --> " << (path == "" ? "all" : path) << endl;
|
||||
cout << "> initiating Connect transition --> " << (path.empty() ? "all" : path) << endl;
|
||||
changeStateResult = topo.ChangeState(TopologyTransition::Connect, path, std::chrono::milliseconds(timeout));
|
||||
} else if (command == "j") {
|
||||
cout << "> initiating InitTask transition --> " << (path == "" ? "all" : path) << endl;
|
||||
cout << "> initiating InitTask transition --> " << (path.empty() ? "all" : path) << endl;
|
||||
changeStateResult = topo.ChangeState(TopologyTransition::InitTask, path, std::chrono::milliseconds(timeout));
|
||||
} else if (command == "r") {
|
||||
cout << "> initiating Run transition --> " << (path == "" ? "all" : path) << endl;
|
||||
cout << "> initiating Run transition --> " << (path.empty() ? "all" : path) << endl;
|
||||
changeStateResult = topo.ChangeState(TopologyTransition::Run, path, std::chrono::milliseconds(timeout));
|
||||
} else if (command == "s") {
|
||||
cout << "> initiating Stop transition --> " << (path == "" ? "all" : path) << endl;
|
||||
cout << "> initiating Stop transition --> " << (path.empty() ? "all" : path) << endl;
|
||||
changeStateResult = topo.ChangeState(TopologyTransition::Stop, path, std::chrono::milliseconds(timeout));
|
||||
} else if (command == "t") {
|
||||
cout << "> initiating ResetTask transition --> " << (path == "" ? "all" : path) << endl;
|
||||
cout << "> initiating ResetTask transition --> " << (path.empty() ? "all" : path) << endl;
|
||||
changeStateResult = topo.ChangeState(TopologyTransition::ResetTask, path, std::chrono::milliseconds(timeout));
|
||||
} else if (command == "d") {
|
||||
cout << "> initiating ResetDevice transition --> " << (path == "" ? "all" : path) << endl;
|
||||
cout << "> initiating ResetDevice transition --> " << (path.empty() ? "all" : path) << endl;
|
||||
changeStateResult = topo.ChangeState(TopologyTransition::ResetDevice, path, std::chrono::milliseconds(timeout));
|
||||
} else if (command == "q") {
|
||||
cout << "> initiating End transition --> " << (path == "" ? "all" : path) << endl;
|
||||
cout << "> initiating End transition --> " << (path.empty() ? "all" : path) << endl;
|
||||
changeStateResult = topo.ChangeState(TopologyTransition::End, path, std::chrono::milliseconds(timeout));
|
||||
} else if (command == "h") {
|
||||
cout << "> help" << endl;
|
||||
|
@ -151,7 +151,7 @@ void handleCommand(const string& command, const string& path, unsigned int timeo
|
|||
|
||||
void sendCommand(const string& commandIn, const string& path, unsigned int timeout, Topology& topo, const string& pKey, const string& pVal)
|
||||
{
|
||||
if (commandIn != "") {
|
||||
if (!commandIn.empty()) {
|
||||
handleCommand(commandIn, path, timeout, topo, pKey, pVal);
|
||||
return;
|
||||
}
|
||||
|
@ -232,12 +232,12 @@ try {
|
|||
|
||||
Topology topo(ddsTopo, session, true);
|
||||
|
||||
if (targetState != "") {
|
||||
if (command != "") {
|
||||
if (!targetState.empty()) {
|
||||
if (!command.empty()) {
|
||||
sendCommand(command, path, timeout, topo, pKey, pVal);
|
||||
}
|
||||
size_t pos = targetState.find("->");
|
||||
cout << "> waiting for " << (path == "" ? "all" : path) << " to reach " << targetState << endl;
|
||||
cout << "> waiting for " << (path.empty() ? "all" : path) << " to reach " << targetState << endl;
|
||||
if (pos == string::npos) {
|
||||
/* auto ec = */topo.WaitForState(GetState(targetState), path, std::chrono::milliseconds(timeout));
|
||||
// cout << "WaitForState(" << targetState << ") result: " << ec.message() << endl;
|
||||
|
|
|
@ -575,7 +575,7 @@ std::vector<std::pair<std::string, bool>> Monitor::Cleanup(const ShmId& shmId, b
|
|||
if (verbose) {
|
||||
LOG(info) << "Found RegionInfo with path: '" << path << "', flags: " << flags << ", fDestroyed: " << ri.fDestroyed << ".";
|
||||
}
|
||||
if (path != "") {
|
||||
if (!path.empty()) {
|
||||
result.emplace_back(RunRemoval(Monitor::RemoveFileMapping, path + "fmq_" + shmId.shmId + "_rg_" + to_string(i), verbose));
|
||||
} else {
|
||||
result.emplace_back(RunRemoval(Monitor::RemoveObject, "fmq_" + shmId.shmId + "_rg_" + to_string(i), verbose));
|
||||
|
|
|
@ -59,7 +59,7 @@ struct Region
|
|||
{
|
||||
using namespace boost::interprocess;
|
||||
|
||||
if (path != "") {
|
||||
if (!path.empty()) {
|
||||
fName = std::string(path + fName);
|
||||
|
||||
if (!fRemote) {
|
||||
|
|
|
@ -469,7 +469,7 @@ class Socket final : public fair::mq::Socket
|
|||
|
||||
static int GetConstant(const std::string& constant)
|
||||
{
|
||||
if (constant == "") return 0;
|
||||
if (constant.empty()) return 0;
|
||||
if (constant == "sub") return ZMQ_SUB;
|
||||
if (constant == "pub") return ZMQ_PUB;
|
||||
if (constant == "xsub") return ZMQ_XSUB;
|
||||
|
|
|
@ -421,7 +421,7 @@ class Socket final : public fair::mq::Socket
|
|||
|
||||
static int GetConstant(const std::string& constant)
|
||||
{
|
||||
if (constant == "") return 0;
|
||||
if (constant.empty()) return 0;
|
||||
if (constant == "sub") return ZMQ_SUB;
|
||||
if (constant == "pub") return ZMQ_PUB;
|
||||
if (constant == "xsub") return ZMQ_XSUB;
|
||||
|
|
Loading…
Reference in New Issue
Block a user