YARP
Yet Another Robot Platform
NameserCarrier.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_OS_IMPL_NAMESERCARRIER_H
11 #define YARP_OS_IMPL_NAMESERCARRIER_H
12 
13 #include <yarp/os/TwoWayStream.h>
15 
16 
17 namespace yarp {
18 namespace os {
19 namespace impl {
20 
27  public TwoWayStream,
29 {
30 private:
31  TwoWayStream* delegate;
32  std::string pendingRead;
33  std::string swallowRead;
34 
35 public:
37 
38  virtual ~NameserTwoWayStream();
39 
40  InputStream& getInputStream() override;
41  OutputStream& getOutputStream() override;
42  const Contact& getLocalAddress() const override;
43  const Contact& getRemoteAddress() const override;
44 
45  bool isOk() const override;
46  void reset() override;
47  void close() override;
48  void beginPacket() override;
49  void endPacket() override;
50 
53 };
54 
55 
62  public TcpCarrier
63 {
64 private:
65  bool firstSend;
66 
67 public:
69 
70  std::string getName() const override;
71  std::string getSpecifierName() const;
72 
73  Carrier* create() const override;
74 
75  bool checkHeader(const Bytes& header) override;
76  void getHeader(Bytes& header) const override;
77  bool requireAck() const override;
78  bool isTextMode() const override;
79  bool supportReply() const override;
80  bool canEscape() const override;
81  bool sendHeader(ConnectionState& proto) override;
82  bool expectSenderSpecifier(ConnectionState& proto) override;
83  bool expectIndex(ConnectionState& proto) override;
84  bool sendAck(ConnectionState& proto) override;
85  bool expectAck(ConnectionState& proto) override;
86  bool respondToHeader(ConnectionState& proto) override;
87  bool expectReplyToHeader(ConnectionState& proto) override;
88  bool write(ConnectionState& proto, SizedWriter& writer) override;
89 };
90 
91 } // namespace impl
92 } // namespace os
93 } // namespace yarp
94 
95 #endif // YARP_OS_IMPL_NAMESERCARRIER_H
A simple abstraction for a block of bytes.
Definition: Bytes.h:28
A base class for connection types (tcp, mcast, shmem, ...) which are called carriers in YARP.
Definition: Carrier.h:48
The basic state of a connection - route, streams in use, etc.
Represents how to reach a part of a YARP network.
Definition: Contact.h:39
Simple specification of the minimum functions needed from input streams.
Definition: InputStream.h:29
virtual int read()
Read and return a single byte.
Definition: InputStream.cpp:23
Simple specification of the minimum functions needed from output streams.
Definition: OutputStream.h:25
Minimal requirements for an efficient Writer.
Definition: SizedWriter.h:36
A stream which can be asked to perform bidirectional communication.
Definition: TwoWayStream.h:29
Communicating between two ports via a variant plain-text protocol originally designed for the yarp na...
bool write(ConnectionState &proto, SizedWriter &writer) override
Write a message.
bool canEscape() const override
Check if carrier can encode administrative messages, as opposed to just user data.
bool respondToHeader(ConnectionState &proto) override
Respond to the header.
bool requireAck() const override
Check if carrier has flow control, requiring sent messages to be acknowledged by recipient.
std::string getName() const override
Get the name of this connection type ("tcp", "mcast", "shmem", ...)
bool sendHeader(ConnectionState &proto) override
Write a header appropriate to the carrier to the connection, followed by any carrier-specific data.
void getHeader(Bytes &header) const override
Provide 8 bytes describing this connection sufficiently to allow the other side of a connection to se...
Carrier * create() const override
Factory method.
bool expectReplyToHeader(ConnectionState &proto) override
Process reply to header, if one is expected for this carrier.
bool expectIndex(ConnectionState &proto) override
Expect a message header, if there is one for this carrier.
bool expectSenderSpecifier(ConnectionState &proto) override
Expect the name of the sending port.
bool checkHeader(const Bytes &header) override
Given the first 8 bytes received on a connection, decide if this is the right carrier type to use for...
bool sendAck(ConnectionState &proto) override
Send an acknowledgement, if needed for this carrier.
bool supportReply() const override
This flag is used by YARP to determine whether the connection can carry RPC traffic,...
std::string getSpecifierName() const
bool expectAck(ConnectionState &proto) override
Receive an acknowledgement, if expected for this carrier.
bool isTextMode() const override
Check if carrier is textual in nature.
Communicating between two ports via a variant plain-text protocol originally designed for the yarp na...
void reset() override
Reset the stream.
const Contact & getLocalAddress() const override
Get the address of the local side of the stream.
OutputStream & getOutputStream() override
Get an OutputStream to write to.
InputStream & getInputStream() override
Get an InputStream to read from.
NameserTwoWayStream(TwoWayStream *delegate)
void endPacket() override
Mark the end of a logical packet (see beginPacket).
bool isOk() const override
Check if the stream is ok or in an error state.
void close() override
Terminate the stream.
void beginPacket() override
Mark the beginning of a logical packet.
const Contact & getRemoteAddress() const override
Get the address of the remote side of the stream.
Communicating between two ports via TCP.
Definition: TcpCarrier.h:24
::ssize_t ssize_t
Definition: numeric.h:60
The main, catch-all namespace for YARP.
Definition: environment.h:18