YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
PortMonitor.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 PORTMONITOR_INC
7#define PORTMONITOR_INC
8
11#include <yarp/os/Election.h>
13#include <yarp/os/Things.h>
14
15#include "MonitorBinding.h"
16#include "MonitorEvent.h"
17
18#include <mutex>
19
20
21class PortMonitor;
22
27 public yarp::os::PeerRecord<PortMonitor>
28{
29public:
30 virtual ~PortMonitorGroup() {}
31 virtual bool acceptIncomingData(PortMonitor *source);
32};
33
34
35
52{
53
54public:
55 PortMonitor() = default;
56 PortMonitor(const PortMonitor&) = delete;
60
61 ~PortMonitor() override
62 {
63 if (!portName.empty()) {
64 getPeers().remove(portName,this);
65 }
66 delete binder;
67 }
68
69 Carrier *create() const override
70 {
71 return new PortMonitor();
72 }
73
74 std::string getName() const override
75 {
76 return "portmonitor";
77 }
78
79 std::string toString() const override
80 {
81 return "portmonitor_carrier";
82 }
83
84 bool configure(yarp::os::ConnectionState& proto) override;
85 bool configureFromProperty(yarp::os::Property& options) override;
86
87 //bool modifiesIncomingData() override;
89
91
93
94 bool acceptOutgoingData(const yarp::os::PortWriter& writer) override;
95
97
98 void setCarrierParams(const yarp::os::Property& params) override;
99
100 void getCarrierParams(yarp::os::Property& params) const override;
101
102
103 void lock() const { mutex.lock(); }
104 void unlock() const { mutex.unlock(); }
105
107 {
108 if(!bReady) {
109 return nullptr;
110 }
111 return binder;
112 }
113
114public:
115 std::string portName;
116 std::string sourceName;
117
118private:
121
122
123private:
124 bool bReady {false};
126 yarp::os::ConnectionReader* localReader {nullptr};
127 yarp::os::Things thing;
128 MonitorBinding* binder {nullptr};
129 PortMonitorGroup *group {nullptr};
130 mutable std::mutex mutex;
131};
132
133#endif //PORTMONITOR_INC
Manager for arbitration-aware inputs to a given port.
Definition PortMonitor.h:28
virtual ~PortMonitorGroup()
Definition PortMonitor.h:30
virtual bool acceptIncomingData(PortMonitor *source)
Allow to monitor and modify port data from Lua script Under development.
Definition PortMonitor.h:52
MonitorBinding * getBinder()
~PortMonitor() override
Definition PortMonitor.h:61
void lock() const
PortMonitor & operator=(const PortMonitor &)=delete
void getCarrierParams(yarp::os::Property &params) const override
Get carrier configuration and deliver it by port administrative commands.
yarp::os::ConnectionReader & modifyIncomingData(yarp::os::ConnectionReader &reader) override
Modify incoming payload data, if appropriate.
void unlock() const
const yarp::os::PortWriter & modifyOutgoingData(const yarp::os::PortWriter &writer) override
Modify outgoing payload data, if appropriate.
PortMonitor(const PortMonitor &)=delete
Carrier * create() const override
Factory method.
Definition PortMonitor.h:69
std::string getName() const override
Get the name of this connection type ("tcp", "mcast", "shmem", ...)
Definition PortMonitor.h:74
std::string toString() const override
Get name of carrier.
Definition PortMonitor.h:79
PortMonitor & operator=(PortMonitor &&)=delete
PortMonitor(PortMonitor &&)=delete
yarp::os::PortReader & modifyReply(yarp::os::PortReader &reader) override
Modify reply payload data, if appropriate.
void setCarrierParams(const yarp::os::Property &params) override
Configure carrier from port administrative commands.
bool configureFromProperty(yarp::os::Property &options) override
bool acceptIncomingData(yarp::os::ConnectionReader &reader) override
Determine whether incoming data should be accepted.
std::string sourceName
bool acceptOutgoingData(const yarp::os::PortWriter &writer) override
Determine whether outgoing data should be accepted.
std::string portName
bool configure(yarp::os::ConnectionState &proto) override
Class PortMonitor.
PortMonitor()=default
A mini-server for performing network communication in the background.
An interface for reading from a network connection.
The basic state of a connection - route, streams in use, etc.
A dummy connection to test yarp::os::Portable implementations.
void remove(const std::string &key, typename PR::peer_type *entity)
Definition Election.h:98
A starter class for implementing simple modifying carriers.
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition PortReader.h:24
Interface implemented by all objects that can write themselves to the network, such as Bottle objects...
Definition PortWriter.h:23
A class for storing options and configuration information.
Definition Property.h:33
Base class for generic things.
Definition Things.h:18