YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ShmemHybridStream.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef YARP_SHMEM_SHMEMHYBRIDSTREAM_H
8#define YARP_SHMEM_SHMEMHYBRIDSTREAM_H
9
10#include <yarp/os/InputStream.h>
11#include <yarp/os/NetType.h>
14
15#include "ShmemInputStream.h"
16#include "ShmemOutputStream.h"
17
18
25{
26public:
28 virtual ~ShmemHybridStream();
29
30 int open(const yarp::os::Contact& yarp_address, bool sender);
31 int accept();
32
33 void close() override;
34 void interrupt() override;
35
37 void write(const yarp::os::Bytes& b) override;
38
41
42 // TwoWayStrem implementation
45 bool isOk() const override;
46
47 void reset() override;
48
49 void beginPacket() override;
50 void endPacket() override;
51
52 const yarp::os::Contact& getLocalAddress() const override;
53 const yarp::os::Contact& getRemoteAddress() const override;
54
55private:
56 enum
57 {
58 CONNECT = 0,
59 ACKNOWLEDGE,
60 READ,
61 WRITE,
62 CLOSE,
63 WAKE_UP_MF,
64 RESIZE
65 };
66
67 // DATA
68 bool m_bLinked;
69
70 yarp::os::Contact m_LocalAddress;
71 yarp::os::Contact m_RemoteAddress;
72 ACE_SOCK_Stream m_SockStream;
73 ACE_SOCK_Acceptor m_Acceptor;
74
77
78 // FUNCTIONS
79 int connect(const ACE_INET_Addr& ace_address);
80};
81
82#endif // YARP_SHMEM_SHMEMHYBRIDSTREAM_H
A stream abstraction for shared memory communication.
void write(const yarp::os::Bytes &b) override
Write a block of bytes to the stream.
void reset() override
Reset the stream.
yarp::os::OutputStream & getOutputStream() override
Get an OutputStream to write to.
void interrupt() override
Interrupt the stream.
int open(const yarp::os::Contact &yarp_address, bool sender)
bool isOk() const override
Check if the stream is ok or in an error state.
const yarp::os::Contact & getRemoteAddress() const override
Get the address of the remote side of the stream.
void beginPacket() override
Mark the beginning of a logical packet.
const yarp::os::Contact & getLocalAddress() const override
Get the address of the local side of the stream.
void endPacket() override
Mark the end of a logical packet (see beginPacket).
yarp::os::InputStream & getInputStream() override
Get an InputStream to read from.
void close() override
Terminate the stream.
A simple abstraction for a block of bytes.
Definition Bytes.h:24
Represents how to reach a part of a YARP network.
Definition Contact.h:33
Simple specification of the minimum functions needed from input streams.
Definition InputStream.h:25
virtual int read()
Read and return a single byte.
Simple specification of the minimum functions needed from output streams.
virtual void write(char ch)
Write a single byte to the stream.
A stream which can be asked to perform bidirectional communication.
::ssize_t ssize_t
Definition numeric.h:86