YARP
Yet Another Robot Platform
MeshTriangle.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6// This is an automatically generated file.
7
8// Generated from the following "shape_msgs/MeshTriangle" msg definition:
9// # Definition of a triangle's vertices
10// uint32[3] vertex_indices
11// Instances of this class can be read and written with YARP ports,
12// using a ROS-compatible format.
13
14#ifndef YARP_ROSMSG_shape_msgs_MeshTriangle_h
15#define YARP_ROSMSG_shape_msgs_MeshTriangle_h
16
17#include <yarp/os/Wire.h>
18#include <yarp/os/Type.h>
20#include <string>
21#include <vector>
22
23namespace yarp {
24namespace rosmsg {
25namespace shape_msgs {
26
28{
29public:
30 std::vector<std::uint32_t> vertex_indices;
31
34 {
35 vertex_indices.resize(3, 0);
36 }
37
38 void clear()
39 {
40 // *** vertex_indices ***
41 vertex_indices.clear();
42 vertex_indices.resize(3, 0);
43 }
44
45 bool readBare(yarp::os::ConnectionReader& connection) override
46 {
47 // *** vertex_indices ***
48 int len = 3;
49 vertex_indices.resize(len);
50 if (len > 0 && !connection.expectBlock((char*)&vertex_indices[0], sizeof(std::uint32_t)*len)) {
51 return false;
52 }
53
54 return !connection.isError();
55 }
56
57 bool readBottle(yarp::os::ConnectionReader& connection) override
58 {
59 connection.convertTextMode();
60 yarp::os::idl::WireReader reader(connection);
61 if (!reader.readListHeader(1)) {
62 return false;
63 }
64
65 // *** vertex_indices ***
66 if (connection.expectInt32() != (BOTTLE_TAG_LIST|BOTTLE_TAG_INT32)) {
67 return false;
68 }
69 int len = connection.expectInt32();
70 vertex_indices.resize(len);
71 for (int i=0; i<len; i++) {
72 vertex_indices[i] = (std::uint32_t)connection.expectInt32();
73 }
74
75 return !connection.isError();
76 }
77
79 bool read(yarp::os::ConnectionReader& connection) override
80 {
81 return (connection.isBareMode() ? readBare(connection)
82 : readBottle(connection));
83 }
84
85 bool writeBare(yarp::os::ConnectionWriter& connection) const override
86 {
87 // *** vertex_indices ***
88 if (vertex_indices.size()>0) {
89 connection.appendExternalBlock((char*)&vertex_indices[0], sizeof(std::uint32_t)*vertex_indices.size());
90 }
91
92 return !connection.isError();
93 }
94
95 bool writeBottle(yarp::os::ConnectionWriter& connection) const override
96 {
97 connection.appendInt32(BOTTLE_TAG_LIST);
98 connection.appendInt32(1);
99
100 // *** vertex_indices ***
102 connection.appendInt32(vertex_indices.size());
103 for (size_t i=0; i<vertex_indices.size(); i++) {
104 connection.appendInt32(vertex_indices[i]);
105 }
106
107 connection.convertTextMode();
108 return !connection.isError();
109 }
110
112 bool write(yarp::os::ConnectionWriter& connection) const override
113 {
114 return (connection.isBareMode() ? writeBare(connection)
115 : writeBottle(connection));
116 }
117
118 // This class will serialize ROS style or YARP style depending on protocol.
119 // If you need to force a serialization style, use one of these classes:
122
123 // The name for this message, ROS will need this
124 static constexpr const char* typeName = "shape_msgs/MeshTriangle";
125
126 // The checksum for this message, ROS will need this
127 static constexpr const char* typeChecksum = "23688b2e6d2de3d32fe8af104a903253";
128
129 // The source text for this message, ROS will need this
130 static constexpr const char* typeText = "\
131# Definition of a triangle's vertices\n\
132uint32[3] vertex_indices\n\
133";
134
135 yarp::os::Type getType() const override
136 {
139 typ.addProperty("message_definition", yarp::os::Value(typeText));
140 return typ;
141 }
142};
143
144} // namespace shape_msgs
145} // namespace rosmsg
146} // namespace yarp
147
148#endif // YARP_ROSMSG_shape_msgs_MeshTriangle_h
#define BOTTLE_TAG_INT32
Definition: Bottle.h:21
#define BOTTLE_TAG_LIST
Definition: Bottle.h:28
An interface for reading from a network connection.
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary.
virtual bool isError() const =0
An interface for writing to a network connection.
virtual bool isError() const =0
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual void appendExternalBlock(const char *data, size_t len)=0
Send a block of data to the network connection, without making a copy.
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
static Type byName(const char *name)
Definition: Type.cpp:171
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:134
A single value (typically within a Bottle).
Definition: Value.h:43
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:21
virtual bool read(yarp::os::idl::WireReader &reader)
virtual bool write(const yarp::os::idl::WireWriter &writer) const
IDL-friendly connection reader.
Definition: WireReader.h:27
std::vector< std::uint32_t > vertex_indices
Definition: MeshTriangle.h:30
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: MeshTriangle.h:57
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: MeshTriangle.h:112
yarp::os::idl::BareStyle< yarp::rosmsg::shape_msgs::MeshTriangle > rosStyle
Definition: MeshTriangle.h:120
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: MeshTriangle.h:95
static constexpr const char * typeChecksum
Definition: MeshTriangle.h:127
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: MeshTriangle.h:85
static constexpr const char * typeName
Definition: MeshTriangle.h:124
static constexpr const char * typeText
Definition: MeshTriangle.h:130
yarp::os::Type getType() const override
Definition: MeshTriangle.h:135
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: MeshTriangle.h:45
yarp::os::idl::BottleStyle< yarp::rosmsg::shape_msgs::MeshTriangle > bottleStyle
Definition: MeshTriangle.h:121
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: MeshTriangle.h:79
The main, catch-all namespace for YARP.
Definition: dirs.h:16