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