YARP
Yet Another Robot Platform
WireBottle.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2021 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 YARP2_WIREBOTTLE
11 #define YARP2_WIREBOTTLE
12 
13 #include <yarp/os/SizedWriter.h>
14 
16 
17 namespace yarp {
18 namespace wire_rep_utils {
19 
22 {
23 private:
24  yarp::os::SizedWriter *delegate;
25  size_t payload_index, payload_offset;
26 public:
27  void setDelegate(yarp::os::SizedWriter *delegate, int index,
28  int offset) {
29  this->delegate = delegate;
30  payload_index = index;
31  payload_offset = offset;
32  }
33 
34  size_t length() const override {
35  return delegate->length()-payload_index;
36  }
37 
38  size_t headerLength() const override {
39  return 0; // not supported
40  }
41 
42  size_t length(size_t index) const override {
43  index += payload_index;
44  if (index==payload_index) return delegate->length(index)-payload_offset;
45  return delegate->length(index);
46  }
47 
48  const char *data(size_t index) const override {
49  index += payload_index;
50  if (index==payload_index) return delegate->data(index)+payload_offset;
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 {
74 public:
75  static bool checkBottle(void *cursor, int len);
76  static bool extractBlobFromBottle(yarp::os::SizedWriter& src,
77  SizedWriterTail& dest);
78 };
79 
80 } // namespace wire_rep_utils
81 } // namespace yarp
82 
83 #endif
static char * checkBottle(char *cursor, int &remaining, int ct, int list_tag)
Definition: WireBottle.cpp:25
Interface implemented by all objects that can read themselves from the network, such as Bottle object...
Definition: PortReader.h:28
This is a base class for objects that can be both read from and be written to the YARP network.
Definition: Portable.h:29
Minimal requirements for an efficient Writer.
Definition: SizedWriter.h:36
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:38
yarp::os::PortReader * getReplyHandler() override
Definition: WireBottle.h:54
size_t length(size_t index) const override
Definition: WireBottle.h:42
const char * data(size_t index) const override
Definition: WireBottle.h:48
void stopWrite() const override
Call when all writing is finished.
Definition: WireBottle.h:68
size_t length() const override
Definition: WireBottle.h:34
yarp::os::Portable * getReference() override
Definition: WireBottle.h:58
void startWrite() const override
Call when writing is about to begin.
Definition: WireBottle.h:65
void setDelegate(yarp::os::SizedWriter *delegate, int index, int offset)
Definition: WireBottle.h:27
The main, catch-all namespace for YARP.
Definition: environment.h:25
#define YARP_wire_rep_utils_API
Definition: api.h:15