YARP
Yet Another Robot Platform
WireBottle.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 YARP2_WIREBOTTLE
8#define YARP2_WIREBOTTLE
9
10#include <yarp/os/SizedWriter.h>
11
13
14namespace yarp::wire_rep_utils {
15
18{
19private:
20 yarp::os::SizedWriter *delegate;
21 size_t payload_index, payload_offset;
22public:
23 void setDelegate(yarp::os::SizedWriter *delegate, int index,
24 int offset) {
25 this->delegate = delegate;
26 payload_index = index;
27 payload_offset = offset;
28 }
29
30 size_t length() const override {
31 return delegate->length()-payload_index;
32 }
33
34 size_t headerLength() const override {
35 return 0; // not supported
36 }
37
38 size_t length(size_t index) const override {
39 index += payload_index;
40 if (index == payload_index) {
41 return delegate->length(index) - payload_offset;
42 }
43 return delegate->length(index);
44 }
45
46 const char *data(size_t index) const override {
47 index += payload_index;
48 if (index == payload_index) {
49 return delegate->data(index) + payload_offset;
50 }
51 return delegate->data(index);
52 }
53
55 return delegate->getReplyHandler();
56 }
57
59 return delegate->getReference();
60 }
61
62 bool dropRequested() override { return false; }
63
64
65 void startWrite() const override {
66 }
67
68 void stopWrite() const override {
69 }
70};
71
73{
74public:
75 static bool checkBottle(void *cursor, int len);
76 static bool extractBlobFromBottle(yarp::os::SizedWriter& src,
77 SizedWriterTail& dest);
78};
79
80} // namespace yarp::wire_rep_utils
81
82#endif
static char * checkBottle(char *cursor, int &remaining, int ct, int list_tag)
Definition: WireBottle.cpp:22
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:24
This is a base class for objects that can be both read from and be written to the YARP network.
Definition: Portable.h:25
Minimal requirements for an efficient Writer.
Definition: SizedWriter.h:32
virtual Portable * getReference()=0
virtual const char * data(size_t index) const =0
virtual size_t length() const =0
virtual PortReader * getReplyHandler()=0
size_t headerLength() const override
Definition: WireBottle.h:34
size_t length(size_t index) const override
Definition: WireBottle.h:38
yarp::os::Portable * getReference() override
Definition: WireBottle.h:58
void stopWrite() const override
Call when all writing is finished.
Definition: WireBottle.h:68
size_t length() const override
Definition: WireBottle.h:30
void startWrite() const override
Call when writing is about to begin.
Definition: WireBottle.h:65
const char * data(size_t index) const override
Definition: WireBottle.h:46
yarp::os::PortReader * getReplyHandler() override
Definition: WireBottle.h:54
void setDelegate(yarp::os::SizedWriter *delegate, int index, int offset)
Definition: WireBottle.h:23
#define YARP_wire_rep_utils_API
Definition: api.h:12