From 1a01012e7c93c1e69836539a59f7e6a74881bea4 Mon Sep 17 00:00:00 2001 From: Manuel Pitz Date: Tue, 10 Jan 2023 15:25:27 +0100 Subject: [PATCH 1/6] make compatible to fmt version 9.0.3 Signed-off-by: Manuel Pitz --- include/villas/nodes/websocket.hpp | 11 +++++++++-- include/villas/path.hpp | 6 ++++++ lib/hooks/print.cpp | 4 ++-- lib/hooks/restart.cpp | 2 +- lib/node.cpp | 2 +- lib/nodes/mqtt.cpp | 6 +++--- lib/nodes/ngsi.cpp | 6 +++--- lib/nodes/signal_v1.cpp | 2 +- lib/nodes/websocket.cpp | 20 ++++++++++---------- lib/path.cpp | 26 +++++++++++++------------- lib/path_destination.cpp | 18 +++++++++--------- lib/path_source.cpp | 18 +++++++++--------- lib/super_node.cpp | 14 +++++++------- plugins/example_hook.cpp | 2 +- src/villas-pipe.cpp | 12 ++++++------ src/villas-signal.cpp | 8 ++++---- src/villas-test-rtt.cpp | 10 +++++----- 17 files changed, 90 insertions(+), 77 deletions(-) diff --git a/include/villas/nodes/websocket.hpp b/include/villas/nodes/websocket.hpp index b2b775a57..821f2aa57 100644 --- a/include/villas/nodes/websocket.hpp +++ b/include/villas/nodes/websocket.hpp @@ -17,6 +17,7 @@ #include #include #include +#include /* Forward declaration */ struct lws; @@ -25,7 +26,7 @@ namespace villas { namespace node { /* Forward declarations */ -class NodeCompat; +// class NodeCompat; #define DEFAULT_WEBSOCKET_QUEUE_LENGTH (DEFAULT_QUEUE_LENGTH * 64) @@ -89,12 +90,18 @@ struct websocket_connection { os << "dest=" << c.destination->info.address << ":" << c.destination->info.port; if (c.node) - os << ", node=" << *c.node; + os << ", node=" << c.node->getName(); os << ", mode=" << (c.mode == websocket_connection::Mode::CLIENT ? "client" : "server"); return os; } + + std::string toString() { + std::stringstream ss; + ss << *this; + return ss.str(); + } }; int websocket_protocol_cb(struct lws *wsi, enum lws_callback_reasons reason, void *user, void *in, size_t len); diff --git a/include/villas/path.hpp b/include/villas/path.hpp index 7bf48073f..59a5fd673 100644 --- a/include/villas/path.hpp +++ b/include/villas/path.hpp @@ -126,6 +126,12 @@ public: return os; } + std::string toString() { + std::stringstream ss; + ss << *this; + return ss.str(); + } + Path(); ~Path(); diff --git a/lib/hooks/print.cpp b/lib/hooks/print.cpp index 553de3a3d..7467cb29f 100644 --- a/lib/hooks/print.cpp +++ b/lib/hooks/print.cpp @@ -120,9 +120,9 @@ public: buf[wbytes-1] = 0; if (node) - logger->info("{}{} {}", prefix, *node, buf); + logger->info("{}{} {}", prefix, node->getName(), buf); else if (path) - logger->info("{}{} {}", prefix, *path, buf); + logger->info("{}{} {}", prefix, path->toString(), buf); } else formatter->print(output, smp); diff --git a/lib/hooks/restart.cpp b/lib/hooks/restart.cpp index ec5ee85be..4ec1f6fca 100644 --- a/lib/hooks/restart.cpp +++ b/lib/hooks/restart.cpp @@ -49,7 +49,7 @@ public: /* A wrap around of the sequence no should not be treated as a simulation restart */ if (smp->sequence == 0 && prev->sequence != 0 && prev->sequence < UINT64_MAX - 16) { logger->warn("Simulation from node {} restarted (previous->sequence={}, current->sequence={})", - *node, prev->sequence, smp->sequence); + node->getName(), prev->sequence, smp->sequence); smp->flags |= (int) SampleFlags::IS_FIRST; diff --git a/lib/node.cpp b/lib/node.cpp index a7b761084..530210a24 100644 --- a/lib/node.cpp +++ b/lib/node.cpp @@ -405,7 +405,7 @@ const std::string & Node::getNameFull() getOutputSignals(false) ? getOutputSignals(false)->size() : 0, getOutputSignals() ? getOutputSignals()->size() : 0); - name_full += fmt::format(", out.path={}", *out.path); + name_full += fmt::format(", out.path={}", out.path->toString()); } /* Append node-type specific details */ diff --git a/lib/nodes/mqtt.cpp b/lib/nodes/mqtt.cpp index 52b86c063..304b3941e 100644 --- a/lib/nodes/mqtt.cpp +++ b/lib/nodes/mqtt.cpp @@ -206,7 +206,7 @@ int villas::node::mqtt_parse(NodeCompat *n, json_t *json) m->password = password ? strdup(password) : nullptr; if (!m->publish && !m->subscribe) - throw ConfigError(json, "node-config-node-mqtt", "At least one topic has to be specified for node {}", *n); + throw ConfigError(json, "node-config-node-mqtt", "At least one topic has to be specified for node {}", n->getName()); if (json_ssl) { m->ssl.enabled = 1; @@ -230,10 +230,10 @@ int villas::node::mqtt_parse(NodeCompat *n, json_t *json) "tls_version", &tls_version ); if (ret) - throw ConfigError(json_ssl, err, "node-config-node-mqtt-ssl", "Failed to parse SSL configuration of node {}", *n); + throw ConfigError(json_ssl, err, "node-config-node-mqtt-ssl", "Failed to parse SSL configuration of node {}", n->getName()); if (m->ssl.enabled && !cafile && !capath) - throw ConfigError(json_ssl, "node-config-node-mqtt-ssl", "Either 'ssl.cafile' or 'ssl.capath' settings must be set for node {}.", *n); + throw ConfigError(json_ssl, "node-config-node-mqtt-ssl", "Either 'ssl.cafile' or 'ssl.capath' settings must be set for node {}.", n->getName()); m->ssl.cafile = cafile ? strdup(cafile) : nullptr; m->ssl.capath = capath ? strdup(capath) : nullptr; diff --git a/lib/nodes/ngsi.cpp b/lib/nodes/ngsi.cpp index c40185f44..250c54ebe 100644 --- a/lib/nodes/ngsi.cpp +++ b/lib/nodes/ngsi.cpp @@ -640,13 +640,13 @@ int villas::node::ngsi_parse(NodeCompat *n, json_t *json) if (json_signals_in) { ret = ngsi_parse_signals(json_signals_in, &i->in.signals, n->in.signals); if (ret) - throw ConfigError(json_signals_in, "node-config-node-ngsi-in-signals", "Invalid setting 'in.signals' of node {}", *n); + throw ConfigError(json_signals_in, "node-config-node-ngsi-in-signals", "Invalid setting 'in.signals' of node {}", n->getName()); } if (json_signals_out) { ret = ngsi_parse_signals(json_signals_out, &i->out.signals, n->out.signals); if (ret) - throw ConfigError(json_signals_out, "node-config-node-ngsi-out-signals", "Invalid setting 'out.signals' of node {}", *n); + throw ConfigError(json_signals_out, "node-config-node-ngsi-out-signals", "Invalid setting 'out.signals' of node {}", n->getName()); } return 0; @@ -698,7 +698,7 @@ int villas::node::ngsi_start(NodeCompat *n) int ret = ngsi_request_context_update(i->out.curl, i->endpoint, "APPEND", json_entity, n->logger); if (ret) - throw RuntimeError("Failed to create NGSI context for node {}", *n); + throw RuntimeError("Failed to create NGSI context for node {}", n->getName()); json_decref(json_entity); } diff --git a/lib/nodes/signal_v1.cpp b/lib/nodes/signal_v1.cpp index 18c20a484..be94579b0 100644 --- a/lib/nodes/signal_v1.cpp +++ b/lib/nodes/signal_v1.cpp @@ -244,7 +244,7 @@ int villas::node::signal_node_parse(NodeCompat *n, json_t *json) break; default: - throw ConfigError(json_type, "node-config-node-signal", "Invalid setting 'signal' for node {}", *n); + throw ConfigError(json_type, "node-config-node-signal", "Invalid setting 'signal' for node {}", n->getName()); } for (auto &a : arrays) { diff --git a/lib/nodes/websocket.cpp b/lib/nodes/websocket.cpp index c4db02617..d43f4926f 100644 --- a/lib/nodes/websocket.cpp +++ b/lib/nodes/websocket.cpp @@ -106,11 +106,11 @@ int websocket_connection_write(struct websocket_connection *c, struct Sample * c pushed = queue_push_many(&c->queue, (void **) smps, cnt); if (pushed < (int) cnt) - c->node->logger->warn("Queue overrun in WebSocket connection: {}", *c); + c->node->logger->warn("Queue overrun in WebSocket connection: {}", c->toString()); sample_incref_many(smps, pushed); - c->node->logger->debug("Enqueued {} samples to {}", pushed, *c); + c->node->logger->debug("Enqueued {} samples to {}", pushed, c->toString()); /* Client connections which are currently connecting don't have an associate c->wsi yet */ if (c->wsi) @@ -126,7 +126,7 @@ void websocket_connection_close(struct websocket_connection *c, struct lws *wsi, { lws_close_reason(wsi, status, (unsigned char *) reason, strlen(reason)); - c->node->logger->debug("Closing WebSocket connection with {}: status={}, reason={}", *c, status, reason); + c->node->logger->debug("Closing WebSocket connection with {}: status={}, reason={}", c->toString(), status, reason); c->state = websocket_connection::State::CLOSED; } @@ -205,7 +205,7 @@ int villas::node::websocket_protocol_cb(struct lws *wsi, enum lws_callback_reaso c->wsi = wsi; c->state = websocket_connection::State::ESTABLISHED; - c->node->logger->info("Established WebSocket connection: {}", *c); + c->node->logger->info("Established WebSocket connection: {}", c->toString()); { std::lock_guard guard(connections_lock); @@ -223,7 +223,7 @@ int villas::node::websocket_protocol_cb(struct lws *wsi, enum lws_callback_reaso case LWS_CALLBACK_CLOSED: c->state = websocket_connection::State::CLOSED; - c->node->logger->debug("Closed WebSocket connection: {}", *c); + c->node->logger->debug("Closed WebSocket connection: {}", c->toString()); if (c->state != websocket_connection::State::CLOSING) { /** @todo Attempt reconnect here */ @@ -260,7 +260,7 @@ int villas::node::websocket_protocol_cb(struct lws *wsi, enum lws_callback_reaso if (ret < 0) return ret; - c->node->logger->debug("Send {} samples to connection: {}, bytes={}", pulled, *c, ret); + c->node->logger->debug("Send {} samples to connection: {}, bytes={}", pulled, c->toString(), ret); } if (queue_available(&c->queue) > 0) @@ -291,15 +291,15 @@ int villas::node::websocket_protocol_cb(struct lws *wsi, enum lws_callback_reaso avail = sample_alloc_many(&w->pool, smps, cnt); if (avail < cnt) - c->node->logger->warn("Pool underrun for connection: {}", *c); + c->node->logger->warn("Pool underrun for connection: {}", c->toString()); recvd = c->formatter->sscan(c->buffers.recv->data(), c->buffers.recv->size(), nullptr, smps, avail); if (recvd < 0) { - c->node->logger->warn("Failed to parse sample data received on connection: {}", *c); + c->node->logger->warn("Failed to parse sample data received on connection: {}", c->toString()); break; } - c->node->logger->debug("Received {} samples from connection: {}", recvd, *c); + c->node->logger->debug("Received {} samples from connection: {}", recvd, c->toString()); /* Set receive timestamp */ for (int i = 0; i < recvd; i++) { @@ -309,7 +309,7 @@ int villas::node::websocket_protocol_cb(struct lws *wsi, enum lws_callback_reaso enqueued = queue_signalled_push_many(&w->queue, (void **) smps, recvd); if (enqueued < recvd) - c->node->logger->warn("Queue overrun in connection: {}", *c); + c->node->logger->warn("Queue overrun in connection: {}", c->toString()); /* Release unused samples back to pool */ if (enqueued < avail) diff --git a/lib/path.cpp b/lib/path.cpp index e22ea1e76..ad8e4e7f7 100644 --- a/lib/path.cpp +++ b/lib/path.cpp @@ -144,7 +144,7 @@ void Path::startPoll() auto fds = ps->getNode()->getPollFDs(); for (auto fd : fds) { if (fd < 0) - throw RuntimeError("Failed to get file descriptor for node {}", *ps->getNode()); + throw RuntimeError("Failed to get file descriptor for node {}", (ps->getNode())->getName()); /* This slot is only used if it is not masked */ struct pollfd pfd = { @@ -166,7 +166,7 @@ void Path::startPoll() }; if (pfd.fd < 0) - throw RuntimeError("Failed to get file descriptor for timer of path {}", *this); + throw RuntimeError("Failed to get file descriptor for timer of path {}", this->toString()); pfds.push_back(pfd); } @@ -186,7 +186,7 @@ void Path::prepare(NodeList &nodes) /* Prepare mappings */ ret = mappings.prepare(nodes); if (ret) - throw RuntimeError("Failed to prepare mappings of path: {}", *this); + throw RuntimeError("Failed to prepare mappings of path: {}", this->toString()); /* Create path sources */ std::map psm; @@ -256,7 +256,7 @@ void Path::prepare(NodeList &nodes) if (me->type == MappingEntry::Type::DATA) { sig = sigs->getByIndex(me->data.offset + j); if (!sig) { - logger->warn("Failed to create signal description for path {}", *this); + logger->warn("Failed to create signal description for path {}", this->toString()); continue; } } @@ -290,7 +290,7 @@ void Path::prepare(NodeList &nodes) ret = pd->prepare(queuelen); if (ret) - throw RuntimeError("Failed to prepare path destination {} of path {}", *pd->node, *this); + throw RuntimeError("Failed to prepare path destination {} of path {}", (pd->node)->getName(), this->toString()); } /* Autodetect whether to use original sequence numbers or not */ @@ -316,7 +316,7 @@ void Path::prepare(NodeList &nodes) /* Add internal hooks if they are not already in the list */ hooks.prepare(signals, m, this, nullptr); - hooks.dump(logger, fmt::format("path {}", *this)); + hooks.dump(logger, fmt::format("path {}", this->toString())); #endif /* WITH_HOOKS */ /* Prepare pool */ @@ -325,9 +325,9 @@ void Path::prepare(NodeList &nodes) ret = pool_init(&pool, pool_size, SAMPLE_LENGTH(osigs->size()), pool_mt); if (ret) - throw RuntimeError("Failed to initialize pool of path: {}", *this); + throw RuntimeError("Failed to initialize pool of path: {}", this->toString()); - logger->debug("Prepared path {} with {} output signals:", *this, osigs->size()); + logger->debug("Prepared path {} with {} output signals:", this->toString(), osigs->size()); if (logger->level() <= spdlog::level::debug) osigs->dump(logger); @@ -397,7 +397,7 @@ void Path::parse(json_t *json, NodeList &nodes, const uuid_t sn_uuid) /* Input node(s) */ ret = mappings.parse(json_in); if (ret) - throw ConfigError(json_in, "node-config-path-in", "Failed to parse input mapping of path {}", *this); + throw ConfigError(json_in, "node-config-path-in", "Failed to parse input mapping of path {}", this->toString()); /* Output node(s) */ NodeList dests; @@ -462,7 +462,7 @@ void Path::check() assert(state != State::DESTROYED); if (rate < 0) - throw RuntimeError("Setting 'rate' of path {} must be a positive number.", *this); + throw RuntimeError("Setting 'rate' of path {} must be a positive number.", this->toString()); if (!IS_POW2(queuelen)) { queuelen = LOG2_CEIL(queuelen); @@ -492,7 +492,7 @@ void Path::checkPrepared() /* Check that all path sources provide a file descriptor for polling if fixed rate is disabled */ for (auto ps : sources) { if (!(ps->getNode()->getFactory()->getFlags() & (int) NodeFactory::Flags::SUPPORTS_POLL)) - throw RuntimeError("Node {} can not be used in polling mode with path {}", *ps->getNode(), *this); + throw RuntimeError("Node {} can not be used in polling mode with path {}", (ps->getNode())->getName(), this->toString()); } } } @@ -522,7 +522,7 @@ void Path::start() logger->info("Starting path {}: #signals={}/{}, #hooks={}, #sources={}, " "#destinations={}, mode={}, poll={}, mask=0b{:b}, rate={}, " "enabled={}, reversed={}, queuelen={}, original_sequence_no={}", - *this, + this->toString(), signals->size(), getOutputSignals()->size(), hooks.size(), @@ -596,7 +596,7 @@ void Path::stop() state != State::STOPPING) return; - logger->info("Stopping path: {}", *this); + logger->info("Stopping path: {}", this->toString()); if (state != State::STOPPING) state = State::STOPPING; diff --git a/lib/path_destination.cpp b/lib/path_destination.cpp index 4900ca62f..d8d8f4d19 100644 --- a/lib/path_destination.cpp +++ b/lib/path_destination.cpp @@ -49,17 +49,17 @@ void PathDestination::enqueueAll(Path *p, const struct Sample * const smps[], un cloned = sample_clone_many(clones, smps, cnt); if (cloned < cnt) - p->logger->warn("Pool underrun in path {}", *p); + p->logger->warn("Pool underrun in path {}", p->toString()); for (auto pd : p->destinations) { enqueued = queue_push_many(&pd->queue, (void **) clones, cloned); if (enqueued != cnt) - p->logger->warn("Queue overrun for path {}", *p); + p->logger->warn("Queue overrun for path {}", p->toString()); /* Increase reference counter of these samples as they are now also owned by the queue. */ sample_incref_many(clones, cloned); - p->logger->debug("Enqueued {} samples to destination {} of path {}", enqueued, *pd->node, *p); + p->logger->debug("Enqueued {} samples to destination {} of path {}", enqueued, pd->node->getName(), p->toString()); } sample_decref_many(clones, cloned); @@ -79,17 +79,17 @@ void PathDestination::write() if (allocated == 0) break; else if (allocated < cnt) - path->logger->debug("Queue underrun for path {}: allocated={} expected={}", *path, allocated, cnt); + path->logger->debug("Queue underrun for path {}: allocated={} expected={}", path->toString(), allocated, cnt); - path->logger->debug("Dequeued {} samples from queue of node {} which is part of path {}", allocated, *node, *path); + path->logger->debug("Dequeued {} samples from queue of node {} which is part of path {}", allocated, node->getName(), path->toString()); sent = node->write(smps, allocated); if (sent < 0) { - path->logger->error("Failed to sent {} samples to node {}: reason={}", cnt, *node, sent); + path->logger->error("Failed to sent {} samples to node {}: reason={}", cnt, node->getName(), sent); return; } else if (sent < allocated) - path->logger->debug("Partial write to node {}: written={}, expected={}", *node, sent, allocated); + path->logger->debug("Partial write to node {}: written={}, expected={}", node->getName(), sent, allocated); int released = sample_decref_many(smps, allocated); @@ -100,8 +100,8 @@ void PathDestination::write() void PathDestination::check() { if (!node->isEnabled()) - throw RuntimeError("Destination {} is not enabled", *node); + throw RuntimeError("Destination {} is not enabled", node->getName()); if (!(node->getFactory()->getFlags() & (int) NodeFactory::Flags::SUPPORTS_WRITE)) - throw RuntimeError("Destination node {} is not supported as a sink for path ", *node); + throw RuntimeError("Destination node {} is not supported as a sink for path ", node->getName()); } diff --git a/lib/path_source.cpp b/lib/path_source.cpp index e3f71a72d..d630c6f7d 100644 --- a/lib/path_source.cpp +++ b/lib/path_source.cpp @@ -55,7 +55,7 @@ int PathSource::read(int i) /* Fill smps[] free sample blocks from the pool */ allocated = sample_alloc_many(&pool, read_smps, cnt); if (allocated != cnt) - path->logger->warn("Pool underrun for path source {}", *node); + path->logger->warn("Pool underrun for path source {}", node->getName()); /* Read ready samples and store them to blocks pointed by smps[] */ recv = node->read(read_smps, allocated); @@ -71,13 +71,13 @@ int PathSource::read(int i) goto out2; } else { - path->logger->error("Failed to read samples from node {}", *node); + path->logger->error("Failed to read samples from node {}", node->getName()); enqueued = 0; goto out2; } } else if (recv < allocated) - path->logger->warn("Partial read for path {}: read={}, expected={}", *path, recv, allocated); + path->logger->warn("Partial read for path {}: read={}, expected={}", path->toString(), recv, allocated); /* Let the master path sources forward received samples to their secondaries */ writeToSecondaries(read_smps, recv); @@ -96,7 +96,7 @@ int PathSource::read(int i) ? sample_clone(path->last_sample) : sample_clone(muxed_smps[i-1]); if (!muxed_smps[i]) { - path->logger->error("Pool underrun in path {}", *path); + path->logger->error("Pool underrun in path {}", path->toString()); return -1; } @@ -137,7 +137,7 @@ int PathSource::read(int i) else if (toenqueue != tomux) { int skipped = tomux - toenqueue; - path->logger->debug("Hooks skipped {} out of {} samples for path {}", skipped, tomux, *path); + path->logger->debug("Hooks skipped {} out of {} samples for path {}", skipped, tomux, path->toString()); } #else toenqueue = tomux; @@ -178,10 +178,10 @@ out2: sample_decref_many(read_smps, recv); void PathSource::check() { if (!node->isEnabled()) - throw RuntimeError("Source {} is not enabled", *node); + throw RuntimeError("Source {} is not enabled", node->getName()); if (!(node->getFactory()->getFlags() & (int) NodeFactory::Flags::SUPPORTS_READ)) - throw RuntimeError("Node {} is not supported as a source for a path", *node); + throw RuntimeError("Node {} is not supported as a source for a path", node->getName()); } MasterPathSource::MasterPathSource(Path *p, Node *n) : @@ -193,9 +193,9 @@ void MasterPathSource::writeToSecondaries(struct Sample *smps[], unsigned cnt) for (auto sps : secondaries) { int sent = sps->getNode()->write(smps, cnt); if (sent < 0) - throw RuntimeError("Failed to write secondary path source {} of path {}", *sps->getNode(), *path); + throw RuntimeError("Failed to write secondary path source {} of path {}", (sps->getNode())->getName(), path->toString()); else if ((unsigned) sent < cnt) - path->logger->warn("Partial write to secondary path source {} of path {}", *sps->getNode(), *path); + path->logger->warn("Partial write to secondary path source {} of path {}", (sps->getNode())->getName(), path->toString()); } } diff --git a/lib/super_node.cpp b/lib/super_node.cpp index 5dd96111f..dafbe0681 100644 --- a/lib/super_node.cpp +++ b/lib/super_node.cpp @@ -214,7 +214,7 @@ void SuperNode::check() for (auto *n : nodes) { ret = n->check(); if (ret) - throw RuntimeError("Invalid configuration for node {}", *n); + throw RuntimeError("Invalid configuration for node {}", n->getName()); } for (auto *p : paths) @@ -235,7 +235,7 @@ void SuperNode::prepareNodeTypes() ret = nf->start(this); if (ret) - throw RuntimeError("Failed to start node-type: {}", *n->getFactory()); + throw RuntimeError("Failed to start node-type: {}", (n->getFactory())->getName()); } } @@ -262,7 +262,7 @@ void SuperNode::startNodes() ret = n->start(); if (ret) - throw RuntimeError("Failed to start node: {}", *n); + throw RuntimeError("Failed to start node: {}", n->getName()); } } @@ -284,7 +284,7 @@ void SuperNode::prepareNodes() ret = n->prepare(); if (ret) - throw RuntimeError("Failed to prepare node: {}", *n); + throw RuntimeError("Failed to prepare node: {}", n->getName()); } } @@ -315,7 +315,7 @@ void SuperNode::prepare() for (auto *n : nodes) { if (n->sources.size() == 0 && n->destinations.size() == 0) { - logger->info("Node {} is not used by any path. Disabling...", *n); + logger->info("Node {} is not used by any path. Disabling...", n->getName()); n->setEnabled(false); } } @@ -366,7 +366,7 @@ void SuperNode::stopNodes() n->getState() == State::STOPPING) { ret = n->stop(); if (ret) - throw RuntimeError("Failed to stop node: {}", *n); + throw RuntimeError("Failed to stop node: {}", n->getName()); } } } @@ -383,7 +383,7 @@ void SuperNode::stopNodeTypes() ret = nf->stop(); if (ret) - throw RuntimeError("Failed to stop node-type: {}", *n->getFactory()); + throw RuntimeError("Failed to stop node-type: {}", (n->getFactory())->getName()); } } diff --git a/plugins/example_hook.cpp b/plugins/example_hook.cpp index a20fa3619..eada31936 100644 --- a/plugins/example_hook.cpp +++ b/plugins/example_hook.cpp @@ -18,7 +18,7 @@ public: virtual void restart() { - logger->info("The path {} restarted!", *path); + logger->info("The path {} restarted!", path->toString()); } }; diff --git a/src/villas-pipe.cpp b/src/villas-pipe.cpp index 40f54835b..44b1beb72 100644 --- a/src/villas-pipe.cpp +++ b/src/villas-pipe.cpp @@ -200,7 +200,7 @@ public: goto leave; } - logger->warn("Failed to receive samples from node {}: reason={}", *node, recv); + logger->warn("Failed to receive samples from node {}: reason={}", node->getName(), recv); } else formatter->print(stdout, smps, recv); @@ -452,7 +452,7 @@ check: if (optarg == endptr) ret = node->getFactory()->start(&sn); if (ret) - throw RuntimeError("Failed to intialize node type {}: reason={}", *node->getFactory(), ret); + throw RuntimeError("Failed to intialize node type {}: reason={}", (node->getFactory())->getName(), ret); sn.startInterfaces(); @@ -462,11 +462,11 @@ check: if (optarg == endptr) ret = node->prepare(); if (ret) - throw RuntimeError("Failed to prepare node {}: reason={}", *node, ret); + throw RuntimeError("Failed to prepare node {}: reason={}", node->getName(), ret); ret = node->start(); if (ret) - throw RuntimeError("Failed to start node {}: reason={}", *node, ret); + throw RuntimeError("Failed to start node {}: reason={}", node->getName(), ret); recv.dir = std::make_unique(node, formatter, recv.enabled, recv.limit); send.dir = std::make_unique(node, formatter, send.enabled, send.limit); @@ -484,7 +484,7 @@ check: if (optarg == endptr) * Node::read() call and allow it to be joined(). */ ret = node->stop(); if (ret) - throw RuntimeError("Failed to stop node {}: reason={}", *node, ret); + throw RuntimeError("Failed to stop node {}: reason={}", node->getName(), ret); recv.dir->stopThread(); send.dir->stopThread(); @@ -493,7 +493,7 @@ check: if (optarg == endptr) ret = node->getFactory()->stop(); if (ret) - throw RuntimeError("Failed to stop node type {}: reason={}", *node->getFactory(), ret); + throw RuntimeError("Failed to stop node type {}: reason={}", (node->getFactory())->getName(), ret); #if defined(WITH_NODE_WEBSOCKET) && defined(WITH_WEB) /* Only start web subsystem if villas-pipe is used with a websocket node */ diff --git a/src/villas-signal.cpp b/src/villas-signal.cpp index 9a3b4a73c..5492facd4 100644 --- a/src/villas-signal.cpp +++ b/src/villas-signal.cpp @@ -255,7 +255,7 @@ check: if (optarg == endptr) ret = node->getFactory()->start(nullptr); if (ret) - throw RuntimeError("Failed to intialize node type {}: reason={}", *node->getFactory(), ret); + throw RuntimeError("Failed to intialize node type {}: reason={}", (node->getFactory())->getName(), ret); ret = node->check(); if (ret) @@ -263,7 +263,7 @@ check: if (optarg == endptr) ret = node->prepare(); if (ret) - throw RuntimeError("Failed to prepare node {}: reason={}", *node, ret); + throw RuntimeError("Failed to prepare node {}: reason={}", node->getName(), ret); /* Try parsing format config as JSON */ json_format = json_loads(format.c_str(), 0, &err); @@ -281,7 +281,7 @@ check: if (optarg == endptr) ret = node->start(); if (ret) - throw RuntimeError("Failed to start node {}: reason={}", *node, ret); + throw RuntimeError("Failed to start node {}: reason={}", node->getName(), ret); while (!stop && node->getState() == State::STARTED) { t = sample_alloc(&pool); @@ -304,7 +304,7 @@ out: sample_decref(t); ret = node->getFactory()->stop(); if (ret) - throw RuntimeError("Failed to de-intialize node type {}: reason={}", *node->getFactory(), ret); + throw RuntimeError("Failed to de-intialize node type {}: reason={}", (node->getFactory())->getName(), ret); delete node; delete formatter; diff --git a/src/villas-test-rtt.cpp b/src/villas-test-rtt.cpp index 63d59a66d..8c945fadb 100644 --- a/src/villas-test-rtt.cpp +++ b/src/villas-test-rtt.cpp @@ -175,15 +175,15 @@ check: if (optarg == endptr) ret = node->getFactory()->start(&sn); if (ret) - throw RuntimeError("Failed to start node-type {}: reason={}", *node->getFactory(), ret); + throw RuntimeError("Failed to start node-type {}: reason={}", (node->getFactory())->getName(), ret); ret = node->prepare(); if (ret) - throw RuntimeError("Failed to prepare node {}: reason={}", *node, ret); + throw RuntimeError("Failed to prepare node {}: reason={}", node->getName(), ret); ret = node->start(); if (ret) - throw RuntimeError("Failed to start node {}: reason={}", *node, ret); + throw RuntimeError("Failed to start node {}: reason={}", node->getName(), ret); /* Print header */ fprintf(stdout, "%17s%5s%10s%10s%10s%10s%10s\n", "timestamp", "seq", "rtt", "min", "max", "mean", "stddev"); @@ -225,11 +225,11 @@ check: if (optarg == endptr) ret = node->stop(); if (ret) - throw RuntimeError("Failed to stop node {}: reason={}", *node, ret); + throw RuntimeError("Failed to stop node {}: reason={}", node->getName(), ret); ret = node->getFactory()->stop(); if (ret) - throw RuntimeError("Failed to stop node-type {}: reason={}", *node->getFactory(), ret); + throw RuntimeError("Failed to stop node-type {}: reason={}", (node->getFactory())->getName(), ret); delete smp_send; delete smp_recv; From c4bce72c043cac500ad1f356f04f579f3187c15a Mon Sep 17 00:00:00 2001 From: Manuel Pitz Date: Tue, 10 Jan 2023 16:02:40 +0100 Subject: [PATCH 2/6] make compatible to fmt version 9.0.3 Signed-off-by: Manuel Pitz --- lib/nodes/fpga.cpp | 2 +- lib/nodes/kafka.cpp | 4 ++-- lib/super_node.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/nodes/fpga.cpp b/lib/nodes/fpga.cpp index 3049bf26f..0f8c08ee1 100644 --- a/lib/nodes/fpga.cpp +++ b/lib/nodes/fpga.cpp @@ -71,7 +71,7 @@ int FpgaNode::parse(json_t *cfg, const uuid_t sn_uuid) "polling", &polling ); if (ret) - throw ConfigError(cfg, err, "node-config-fpga", "Failed to parse configuration of node {}", *this); + throw ConfigError(cfg, err, "node-config-fpga", "Failed to parse configuration of node {}", this->getName()); if (card) cardName = card; diff --git a/lib/nodes/kafka.cpp b/lib/nodes/kafka.cpp index c8902b5a8..ac5d89052 100644 --- a/lib/nodes/kafka.cpp +++ b/lib/nodes/kafka.cpp @@ -199,7 +199,7 @@ int villas::node::kafka_parse(NodeCompat *n, json_t *json) throw ConfigError(json, "node-config-node-kafka-protocol", "Invalid security protocol: {}", protocol); if (!k->produce && !k->consume) - throw ConfigError(json, "node-config-node-kafka", "At least one topic has to be specified for node {}", *n); + throw ConfigError(json, "node-config-node-kafka", "At least one topic has to be specified for node {}", n->getName()); if (json_ssl) { const char *ca; @@ -208,7 +208,7 @@ int villas::node::kafka_parse(NodeCompat *n, json_t *json) "ca", &ca ); if (ret) - throw ConfigError(json_ssl, err, "node-config-node-kafka-ssl", "Failed to parse SSL configuration of node {}", *n); + throw ConfigError(json_ssl, err, "node-config-node-kafka-ssl", "Failed to parse SSL configuration of node {}", n->getName()); k->ssl.ca = strdup(ca); } diff --git a/lib/super_node.cpp b/lib/super_node.cpp index dafbe0681..72a710af5 100644 --- a/lib/super_node.cpp +++ b/lib/super_node.cpp @@ -508,7 +508,7 @@ graph_t * SuperNode::getGraph() uuid_unparse(n->getUuid(), uuid_str); set_attr(nodeMap[n], "shape", "ellipse"); - set_attr(nodeMap[n], "tooltip", fmt::format("type={}, uuid={}", *n->getFactory(), uuid_str)); + set_attr(nodeMap[n], "tooltip", fmt::format("type={}, uuid={}", (n->getFactory())->getName(), uuid_str)); // set_attr(nodeMap[n], "fixedsize", "true"); // set_attr(nodeMap[n], "width", "0.15"); // set_attr(nodeMap[n], "height", "0.15"); From cf04f6b569d97898fa13e57a9b4b61f916be6774 Mon Sep 17 00:00:00 2001 From: Manuel Pitz Date: Tue, 10 Jan 2023 16:32:24 +0100 Subject: [PATCH 3/6] make compatible to fmt version 9.0.3 review fixes Signed-off-by: Manuel Pitz --- include/villas/nodes/websocket.hpp | 5 +++-- include/villas/path.hpp | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/villas/nodes/websocket.hpp b/include/villas/nodes/websocket.hpp index 821f2aa57..ba6db028f 100644 --- a/include/villas/nodes/websocket.hpp +++ b/include/villas/nodes/websocket.hpp @@ -26,7 +26,7 @@ namespace villas { namespace node { /* Forward declarations */ -// class NodeCompat; +class NodeCompat; #define DEFAULT_WEBSOCKET_QUEUE_LENGTH (DEFAULT_QUEUE_LENGTH * 64) @@ -97,7 +97,8 @@ struct websocket_connection { return os; } - std::string toString() { + std::string toString() + { std::stringstream ss; ss << *this; return ss.str(); diff --git a/include/villas/path.hpp b/include/villas/path.hpp index 59a5fd673..b2a9e5050 100644 --- a/include/villas/path.hpp +++ b/include/villas/path.hpp @@ -126,7 +126,8 @@ public: return os; } - std::string toString() { + std::string toString() + { std::stringstream ss; ss << *this; return ss.str(); From 48b98c195c836477b8a281f8e1ec3374ac8cd487 Mon Sep 17 00:00:00 2001 From: Manuel Pitz Date: Tue, 10 Jan 2023 16:41:58 +0100 Subject: [PATCH 4/6] make compatible to fmt version 9.0.3 review fixes Signed-off-by: Manuel Pitz --- lib/path.cpp | 2 +- lib/super_node.cpp | 6 +++--- src/villas-pipe.cpp | 2 +- src/villas-signal.cpp | 2 +- src/villas-test-rtt.cpp | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/path.cpp b/lib/path.cpp index ad8e4e7f7..96172fb90 100644 --- a/lib/path.cpp +++ b/lib/path.cpp @@ -290,7 +290,7 @@ void Path::prepare(NodeList &nodes) ret = pd->prepare(queuelen); if (ret) - throw RuntimeError("Failed to prepare path destination {} of path {}", (pd->node)->getName(), this->toString()); + throw RuntimeError("Failed to prepare path destination {} of path {}", pd->node->getName(), this->toString()); } /* Autodetect whether to use original sequence numbers or not */ diff --git a/lib/super_node.cpp b/lib/super_node.cpp index 72a710af5..ec70b8287 100644 --- a/lib/super_node.cpp +++ b/lib/super_node.cpp @@ -235,7 +235,7 @@ void SuperNode::prepareNodeTypes() ret = nf->start(this); if (ret) - throw RuntimeError("Failed to start node-type: {}", (n->getFactory())->getName()); + throw RuntimeError("Failed to start node-type: {}", n->getFactory()->getName()); } } @@ -383,7 +383,7 @@ void SuperNode::stopNodeTypes() ret = nf->stop(); if (ret) - throw RuntimeError("Failed to stop node-type: {}", (n->getFactory())->getName()); + throw RuntimeError("Failed to stop node-type: {}", n->getFactory()->getName()); } } @@ -508,7 +508,7 @@ graph_t * SuperNode::getGraph() uuid_unparse(n->getUuid(), uuid_str); set_attr(nodeMap[n], "shape", "ellipse"); - set_attr(nodeMap[n], "tooltip", fmt::format("type={}, uuid={}", (n->getFactory())->getName(), uuid_str)); + set_attr(nodeMap[n], "tooltip", fmt::format("type={}, uuid={}", n->getFactory()->getName(), uuid_str)); // set_attr(nodeMap[n], "fixedsize", "true"); // set_attr(nodeMap[n], "width", "0.15"); // set_attr(nodeMap[n], "height", "0.15"); diff --git a/src/villas-pipe.cpp b/src/villas-pipe.cpp index 44b1beb72..33854324b 100644 --- a/src/villas-pipe.cpp +++ b/src/villas-pipe.cpp @@ -452,7 +452,7 @@ check: if (optarg == endptr) ret = node->getFactory()->start(&sn); if (ret) - throw RuntimeError("Failed to intialize node type {}: reason={}", (node->getFactory())->getName(), ret); + throw RuntimeError("Failed to intialize node type {}: reason={}", node->getFactory()->getName(), ret); sn.startInterfaces(); diff --git a/src/villas-signal.cpp b/src/villas-signal.cpp index 5492facd4..aa724c8e9 100644 --- a/src/villas-signal.cpp +++ b/src/villas-signal.cpp @@ -304,7 +304,7 @@ out: sample_decref(t); ret = node->getFactory()->stop(); if (ret) - throw RuntimeError("Failed to de-intialize node type {}: reason={}", (node->getFactory())->getName(), ret); + throw RuntimeError("Failed to de-intialize node type {}: reason={}", node->getFactory()->getName(), ret); delete node; delete formatter; diff --git a/src/villas-test-rtt.cpp b/src/villas-test-rtt.cpp index 8c945fadb..3b84c718e 100644 --- a/src/villas-test-rtt.cpp +++ b/src/villas-test-rtt.cpp @@ -175,7 +175,7 @@ check: if (optarg == endptr) ret = node->getFactory()->start(&sn); if (ret) - throw RuntimeError("Failed to start node-type {}: reason={}", (node->getFactory())->getName(), ret); + throw RuntimeError("Failed to start node-type {}: reason={}", node->getFactory()->getName(), ret); ret = node->prepare(); if (ret) @@ -229,7 +229,7 @@ check: if (optarg == endptr) ret = node->getFactory()->stop(); if (ret) - throw RuntimeError("Failed to stop node-type {}: reason={}", (node->getFactory())->getName(), ret); + throw RuntimeError("Failed to stop node-type {}: reason={}", node->getFactory()->getName(), ret); delete smp_send; delete smp_recv; From cdd8ad93e5996bb7924170987bfdb55e0b743250 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 11 Jan 2023 12:39:49 +0100 Subject: [PATCH 5/6] remove obsolete forward declaration Signed-off-by: Steffen Vogel --- include/villas/nodes/websocket.hpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/villas/nodes/websocket.hpp b/include/villas/nodes/websocket.hpp index ba6db028f..06501759c 100644 --- a/include/villas/nodes/websocket.hpp +++ b/include/villas/nodes/websocket.hpp @@ -25,9 +25,6 @@ struct lws; namespace villas { namespace node { -/* Forward declarations */ -class NodeCompat; - #define DEFAULT_WEBSOCKET_QUEUE_LENGTH (DEFAULT_QUEUE_LENGTH * 64) /** Internal data per websocket node */ From be1c68efc517f8226e5f9550cdaa903a77d131e6 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Wed, 11 Jan 2023 12:40:47 +0100 Subject: [PATCH 6/6] remove superfluous parantheses Signed-off-by: Steffen Vogel --- lib/path.cpp | 4 ++-- lib/path_source.cpp | 4 ++-- src/villas-pipe.cpp | 2 +- src/villas-signal.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/path.cpp b/lib/path.cpp index 96172fb90..28be09de3 100644 --- a/lib/path.cpp +++ b/lib/path.cpp @@ -144,7 +144,7 @@ void Path::startPoll() auto fds = ps->getNode()->getPollFDs(); for (auto fd : fds) { if (fd < 0) - throw RuntimeError("Failed to get file descriptor for node {}", (ps->getNode())->getName()); + throw RuntimeError("Failed to get file descriptor for node {}", ps->getNode()->getName()); /* This slot is only used if it is not masked */ struct pollfd pfd = { @@ -492,7 +492,7 @@ void Path::checkPrepared() /* Check that all path sources provide a file descriptor for polling if fixed rate is disabled */ for (auto ps : sources) { if (!(ps->getNode()->getFactory()->getFlags() & (int) NodeFactory::Flags::SUPPORTS_POLL)) - throw RuntimeError("Node {} can not be used in polling mode with path {}", (ps->getNode())->getName(), this->toString()); + throw RuntimeError("Node {} can not be used in polling mode with path {}", ps->getNode()->getName(), this->toString()); } } } diff --git a/lib/path_source.cpp b/lib/path_source.cpp index d630c6f7d..3fadf1153 100644 --- a/lib/path_source.cpp +++ b/lib/path_source.cpp @@ -193,9 +193,9 @@ void MasterPathSource::writeToSecondaries(struct Sample *smps[], unsigned cnt) for (auto sps : secondaries) { int sent = sps->getNode()->write(smps, cnt); if (sent < 0) - throw RuntimeError("Failed to write secondary path source {} of path {}", (sps->getNode())->getName(), path->toString()); + throw RuntimeError("Failed to write secondary path source {} of path {}", sps->getNode()->getName(), path->toString()); else if ((unsigned) sent < cnt) - path->logger->warn("Partial write to secondary path source {} of path {}", (sps->getNode())->getName(), path->toString()); + path->logger->warn("Partial write to secondary path source {} of path {}", sps->getNode()->getName(), path->toString()); } } diff --git a/src/villas-pipe.cpp b/src/villas-pipe.cpp index 33854324b..822caf22d 100644 --- a/src/villas-pipe.cpp +++ b/src/villas-pipe.cpp @@ -493,7 +493,7 @@ check: if (optarg == endptr) ret = node->getFactory()->stop(); if (ret) - throw RuntimeError("Failed to stop node type {}: reason={}", (node->getFactory())->getName(), ret); + throw RuntimeError("Failed to stop node type {}: reason={}", node->getFactory()->getName(), ret); #if defined(WITH_NODE_WEBSOCKET) && defined(WITH_WEB) /* Only start web subsystem if villas-pipe is used with a websocket node */ diff --git a/src/villas-signal.cpp b/src/villas-signal.cpp index aa724c8e9..88d61a799 100644 --- a/src/villas-signal.cpp +++ b/src/villas-signal.cpp @@ -255,7 +255,7 @@ check: if (optarg == endptr) ret = node->getFactory()->start(nullptr); if (ret) - throw RuntimeError("Failed to intialize node type {}: reason={}", (node->getFactory())->getName(), ret); + throw RuntimeError("Failed to intialize node type {}: reason={}", node->getFactory()->getName(), ret); ret = node->check(); if (ret)