LCOV - code coverage report
Current view: top level - utilities/src - ZmqUri.cpp (source / functions) Coverage Total Hit
Test: code.result Lines: 100.0 % 19 19
Test Date: 2025-12-21 13:07:08 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           45 : dunedaq::utilities::ZmqUri::ZmqUri(std::string connection_string)
      20              : {
      21           45 :   if (connection_string.find("://") == std::string::npos) {
      22            3 :     throw InvalidUri(ERS_HERE, connection_string);
      23              :   }
      24              : 
      25           42 :   scheme = connection_string.substr(0, connection_string.find("://"));
      26           42 :   connection_string = connection_string.substr(connection_string.find("://") + 3);
      27              : 
      28           42 :   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           42 :   host = connection_string;
      33           51 : }
      34              : 
      35              : std::vector<std::string>
      36           40 : dunedaq::utilities::ZmqUri::get_uri_ip_addresses()
      37              : {
      38           40 :   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           14 :     return output;
      45           14 :   } else {
      46           52 :     return { to_string() };
      47              :   }
      48           26 : }
        

Generated by: LCOV version 2.0-1