-
Notifications
You must be signed in to change notification settings - Fork 10
/
Ros2PublisherObject.java
82 lines (73 loc) · 2.98 KB
/
Ros2PublisherObject.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**********************************************************************
* Copyright (c) 2022 École Polytechnique de Montréal
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License 2.0 which
* accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
**********************************************************************/
package org.eclipse.tracecompass.incubator.internal.ros2.core.model.objects;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.datastore.core.serialization.ISafeByteBufferReader;
import org.eclipse.tracecompass.incubator.internal.ros2.core.model.HostProcessPointer;
/**
* Container for ROS 2 publisher object.
*
* @author Christophe Bedard
*/
public class Ros2PublisherObject extends Ros2PubSubObject {
/** Custom type value ID for this object */
public static final byte CUSTOM_TYPE_ID = 61;
/** CustomStateValueFactory for this object */
@SuppressWarnings("restriction")
public static final @NonNull CustomStateValueFactory ROS2_PUBLISHER_OBJECT_VALUE_FACTORY = b -> Ros2PublisherObject.read(b);
/**
* Constructor
*
* @param publisherHandle
* the publisher handle
* @param rmwPublisherHandle
* the rmw publisher handle
* @param nodeHandle
* the node handle
* @param topicName
* the topic name
* @param gid
* the DDS GID
* @param ddsWriter
* the DDS writer
*/
public Ros2PublisherObject(@NonNull Ros2ObjectHandle publisherHandle, @NonNull Ros2ObjectHandle rmwPublisherHandle, @NonNull String topicName, @NonNull Ros2ObjectHandle nodeHandle, @NonNull Gid gid, @NonNull HostProcessPointer ddsWriter) {
super(publisherHandle, rmwPublisherHandle, topicName, nodeHandle, gid, ddsWriter);
}
/**
* @return the DDS writer
*/
public @NonNull HostProcessPointer getDdsWriter() {
return super.getDdsHandle();
}
@Override
public String toString() {
return String.format("Ros2PublisherObject: %s", super.toString()); //$NON-NLS-1$
}
@Override
protected @NonNull Byte getCustomTypeId() {
return CUSTOM_TYPE_ID;
}
/**
* @param buffer
* the buffer
* @return the value
*/
public static @NonNull Ros2PublisherObject read(ISafeByteBufferReader buffer) {
Ros2ObjectHandle publisherHandle = Ros2ObjectHandle.read(buffer);
Ros2ObjectHandle rmwPublisherHandle = Ros2ObjectHandle.read(buffer);
String topicName = buffer.getString();
Ros2ObjectHandle nodeHandle = Ros2ObjectHandle.read(buffer);
Gid gid = Gid.read(buffer);
HostProcessPointer ddsWriter = HostProcessPointer.read(buffer);
return new Ros2PublisherObject(publisherHandle, rmwPublisherHandle, topicName, nodeHandle, gid, ddsWriter);
}
}