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