YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
NetworkProfilerBasic.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6#ifndef YARP_PROFILER_NETWORK_PROFILER_BASIC_H
7#define YARP_PROFILER_NETWORK_PROFILER_BASIC_H
8
9#include <string>
10#include <sstream>
11#include <iostream>
12#include <vector>
13
14#include <yarp/os/Network.h>
15#include <yarp/os/LogStream.h>
16#include <yarp/os/Bottle.h>
17
18
19namespace yarp::profiler {
20
22{
23public:
25 {
26 std::string port_name;
27 std::string carrier;
28 };
29
30 struct PortInfo
31 {
32 std::string name;
33 std::string ip;
34 std::string port_number;
35 };
36
38 {
41 std::string carrier;
43 {
44 return (this->src.name == rhs.src.name &&
45 this->dst.name == rhs.dst.name &&
46 this->carrier == rhs.carrier);
47 }
48 bool isValid()
49 {
50 if (src.name != "" &&
51 dst.name != "" &&
52 carrier != "") return true;
53 return false;
54 }
55 };
56
58 {
59 std::string os;
60 std::string hostname;
61 std::string ip;
62 };
63
65 {
67 std::string process_name;
68 std::string arguments;
69 std::string process_fullname;
70 int pid;
72 int policy;
74 };
75
77 {
79 std::vector<ConnectedPortInfo> outputs;
80 std::vector<ConnectedPortInfo> inputs;
82 std::string toString() const;
83 };
84
85public:
86 typedef std::vector<PortInfo> ports_name_set;
87 typedef ports_name_set::iterator ports_name_iterator;
88
89 typedef std::vector<PortDetails> ports_detail_set;
90 typedef ports_detail_set::iterator ports_detail_iterator;
91
92 typedef std::vector<ConnectionDetails> connections_set;
93
94 typedef std::vector<std::string> machines_list;
95 typedef std::vector<std::string> processes_list;
96
97public:
98 static bool getPortDetails(const std::string& portName, PortDetails& info);
99
100 static bool getMachinesList(const ports_detail_set& ports, machines_list& l);
101 static bool getProcessesList(const ports_detail_set& ports, processes_list& l);
102
103 static bool getPortsList(ports_name_set& ports, bool complete = false);
104 static bool getPortsDetailedList(ports_detail_set& ports, bool complete = false);
105 static bool getConnectionsList(connections_set& connections);
106 static bool getPortInfo(const std::string& name, const ports_name_set& ports, PortInfo& p);
107
108 static void filterConnectionListByName(const connections_set& in, connections_set& filtered_out, std::string src_name = "*", std::string dst_name = "*");
109 static void filterConnectionListByIp(const connections_set& in, connections_set& filtered_out, std::string src_name = "*", std::string dst_name = "*");
110 static void filterConnectionListByPortNumber(const connections_set& in, connections_set& filtered_out, std::string src_name = "*", std::string dst_name = "*");
111
112 static void filterPortsListByIp(const ports_detail_set& in, ports_detail_set& filtered_out, std::string ip = "*");
113 static void filterPortsListByProcess(const ports_detail_set& in, ports_detail_set& filtered_out, std::string fullprocess = "*");
114
115 static bool yarpClean(float timeout = 0.1);
116};
117
118} // namespace yarp::profiler
119
120
121#endif //YARP_PROFILER_NETWORK_PROFILER_BASIC_H
std::vector< ConnectionDetails > connections_set
static bool getProcessesList(const ports_detail_set &ports, processes_list &l)
ports_detail_set::iterator ports_detail_iterator
static void filterConnectionListByName(const connections_set &in, connections_set &filtered_out, std::string src_name="*", std::string dst_name="*")
static bool getPortsList(ports_name_set &ports, bool complete=false)
static void filterConnectionListByPortNumber(const connections_set &in, connections_set &filtered_out, std::string src_name="*", std::string dst_name="*")
static void filterPortsListByProcess(const ports_detail_set &in, ports_detail_set &filtered_out, std::string fullprocess="*")
std::vector< PortDetails > ports_detail_set
std::vector< std::string > processes_list
static bool getPortDetails(const std::string &portName, PortDetails &info)
static bool yarpClean(float timeout=0.1)
static void filterConnectionListByIp(const connections_set &in, connections_set &filtered_out, std::string src_name="*", std::string dst_name="*")
static bool getConnectionsList(connections_set &connections)
static bool getMachinesList(const ports_detail_set &ports, machines_list &l)
static void filterPortsListByIp(const ports_detail_set &in, ports_detail_set &filtered_out, std::string ip="*")
static bool getPortsDetailedList(ports_detail_set &ports, bool complete=false)
ports_name_set::iterator ports_name_iterator
static bool getPortInfo(const std::string &name, const ports_name_set &ports, PortInfo &p)
std::vector< std::string > machines_list