LCOV - code coverage report
Current view: top level - utilities/src - ZmqUri.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 94.4 % 18 17
Test Date: 2026-02-16 10:18:04 Functions: 100.0 % 2 2

            Line data    Source code
       1              : /**
       2              :  *
       3              :  * @file ZmqUri.cpp ZmqUri struct method implementations
       4              :  *
       5              :  * This is part of the DUNE DAQ Application Framework, copyright 2020.
       6              :  * Licensing/copyright details are in the COPYING file that you should have
       7              :  * received with this code.
       8              :  */
       9              : 
      10              : #include "utilities/ZmqUri.hpp"
      11              : #include "utilities/get_ips.hpp"
      12              : #include "utilities/Issues.hpp"
      13              : 
      14              : #include <string>
      15              : #include <vector>
      16              : 
      17              : 
      18              : // ZMQ URIs are formatted as follows: tcp://{host}:{port}
      19           46 : dunedaq::utilities::ZmqUri::ZmqUri(std::string connection_string)
      20              : {
      21           46 :   if (connection_string.find("://") == std::string::npos) {
      22            3 :     throw InvalidUri(ERS_HERE, connection_string);
      23              :   }
      24              : 
      25           43 :   scheme = connection_string.substr(0, connection_string.find("://"));
      26           43 :   connection_string = connection_string.substr(connection_string.find("://") + 3);
      27              : 
      28           43 :   if (connection_string.find(":") != std::string::npos) {
      29           13 :     port = connection_string.substr(connection_string.find(":") + 1);
      30           13 :     connection_string = connection_string.substr(0, connection_string.find(":"));
      31              :   }
      32           43 :   host = connection_string;
      33           52 : }
      34              : 
      35              : std::vector<std::string>
      36           41 : dunedaq::utilities::ZmqUri::get_uri_ip_addresses()
      37              : {
      38           41 :   if (scheme == "tcp") {
      39           14 :     auto output = get_hostname_ips(host);
      40              : 
      41           26 :     for (size_t ii = 0; ii < output.size(); ++ii) {
      42           12 :       output[ii] = "tcp://" + output[ii] + ":" + port;
      43              :     }
      44              :     return output;
      45            0 :   } else {
      46           54 :     return { to_string() };
      47              :   }
      48           27 : }
        

Generated by: LCOV version 2.0-1