RobotCore
1.0
WPILib port to raspberry Pi
Toggle main menu visibility
Loading...
Searching...
No Matches
ProtobufTopic.java
1
// Copyright (c) FIRST and other WPILib contributors.
2
// Open Source Software; you can modify and/or share it under the terms of
3
// the WPILib BSD license file in the root directory of this project.
4
5
package
org.wpilib.networktables;
6
7
import
org.wpilib.util.protobuf.Protobuf;
8
import
org.wpilib.util.protobuf.ProtobufBuffer;
9
15
public
final
class
ProtobufTopic<T>
extends
Topic {
16
private
ProtobufTopic(Topic topic,
Protobuf<T, ?>
proto) {
17
super(topic.
m_inst
, topic.
m_handle
);
18
m_proto = proto;
19
}
20
21
private
ProtobufTopic(
NetworkTableInstance
inst,
int
handle,
Protobuf<T, ?>
proto) {
22
super(inst, handle);
23
m_proto = proto;
24
}
25
34
public
static <T> ProtobufTopic<T>
wrap
(Topic topic,
Protobuf<T, ?>
proto) {
35
return
new
ProtobufTopic<>(topic, proto);
36
}
37
48
public
static <T> ProtobufTopic<T>
wrap
(
49
NetworkTableInstance
inst,
int
handle,
Protobuf<T, ?>
proto) {
50
return
new
ProtobufTopic<>(inst, handle, proto);
51
}
52
65
public
ProtobufSubscriber<T>
subscribe
(T defaultValue,
PubSubOption
... options) {
66
return
new
ProtobufEntryImpl<>(
67
this
,
68
ProtobufBuffer
.
create
(m_proto),
69
NetworkTablesJNI
.subscribe(
70
m_handle
,
NetworkTableType
.
RAW
.getValue(), m_proto.getTypeString(), options),
71
defaultValue,
72
false
);
73
}
74
88
public
ProtobufPublisher<T>
publish
(
PubSubOption
... options) {
89
m_inst
.
addSchema
(m_proto);
90
return
new
ProtobufEntryImpl<>(
91
this
,
92
ProtobufBuffer
.
create
(m_proto),
93
NetworkTablesJNI
.publish(
94
m_handle
,
NetworkTableType
.
RAW
.getValue(), m_proto.getTypeString(), options),
95
null
,
96
true
);
97
}
98
114
public
ProtobufPublisher<T>
publishEx
(String properties,
PubSubOption
... options) {
115
m_inst
.
addSchema
(m_proto);
116
return
new
ProtobufEntryImpl<>(
117
this
,
118
ProtobufBuffer
.
create
(m_proto),
119
NetworkTablesJNI
.publishEx(
120
m_handle
,
121
NetworkTableType
.
RAW
.getValue(),
122
m_proto.getTypeString(),
123
properties,
124
options),
125
null
,
126
true
);
127
}
128
146
public
ProtobufEntry<T>
getEntry
(T defaultValue,
PubSubOption
... options) {
147
return
new
ProtobufEntryImpl<>(
148
this
,
149
ProtobufBuffer
.
create
(m_proto),
150
NetworkTablesJNI
.getEntry(
151
m_handle
,
NetworkTableType
.
RAW
.getValue(), m_proto.getTypeString(), options),
152
defaultValue,
153
false
);
154
}
155
161
public
Protobuf<T, ?>
getProto
() {
162
return
m_proto;
163
}
164
165
@Override
166
public
boolean
equals(Object other) {
167
return
other ==
this
168
|| other instanceof
ProtobufTopic<?>
topic
169
&& super.equals(topic)
170
&& m_proto == topic.m_proto;
171
}
172
173
@Override
174
public
int
hashCode() {
175
return
super.hashCode() ^ m_proto.hashCode();
176
}
177
178
private
final
Protobuf<T, ?> m_proto;
179
}
org.wpilib.networktables.NetworkTableInstance
Definition
NetworkTableInstance.java:47
org.wpilib.networktables.NetworkTableInstance.addSchema
void addSchema(String name, String type, byte[] schema)
Definition
NetworkTableInstance.java:1635
org.wpilib.networktables.NetworkTablesJNI
Definition
NetworkTablesJNI.java:26
org.wpilib.networktables.ProtobufTopic
Definition
ProtobufTopic.java:15
org.wpilib.networktables.ProtobufTopic.publish
ProtobufPublisher< T > publish(PubSubOption... options)
Definition
ProtobufTopic.java:88
org.wpilib.networktables.ProtobufTopic.getProto
Protobuf< T, ?> getProto()
Definition
ProtobufTopic.java:161
org.wpilib.networktables.ProtobufTopic.wrap
static< T > ProtobufTopic< T > wrap(NetworkTableInstance inst, int handle, Protobuf< T, ?> proto)
Definition
ProtobufTopic.java:48
org.wpilib.networktables.ProtobufTopic.getEntry
ProtobufEntry< T > getEntry(T defaultValue, PubSubOption... options)
Definition
ProtobufTopic.java:146
org.wpilib.networktables.ProtobufTopic.publishEx
ProtobufPublisher< T > publishEx(String properties, PubSubOption... options)
Definition
ProtobufTopic.java:114
org.wpilib.networktables.ProtobufTopic.subscribe
ProtobufSubscriber< T > subscribe(T defaultValue, PubSubOption... options)
Definition
ProtobufTopic.java:65
org.wpilib.networktables.ProtobufTopic.wrap
static< T > ProtobufTopic< T > wrap(Topic topic, Protobuf< T, ?> proto)
Definition
ProtobufTopic.java:34
org.wpilib.networktables.Topic.m_inst
final NetworkTableInstance m_inst
Definition
Topic.java:333
org.wpilib.networktables.Topic.m_handle
final int m_handle
Definition
Topic.java:336
org.wpilib.util.protobuf.ProtobufBuffer
Definition
ProtobufBuffer.java:19
org.wpilib.util.protobuf.ProtobufBuffer.create
static< T, MessageType extends ProtoMessage<?> ProtobufBuffer< T, MessageType > create(Protobuf< T, MessageType > proto)
Definition
ProtobufBuffer.java:37
org.wpilib.networktables.NetworkTableType
Definition
NetworkTableType.java:8
org.wpilib.networktables.NetworkTableType.RAW
RAW
Definition
NetworkTableType.java:18
org.wpilib.networktables.ProtobufEntry
Definition
ProtobufEntry.java:14
org.wpilib.networktables.ProtobufPublisher
Definition
ProtobufPublisher.java:14
org.wpilib.networktables.ProtobufSubscriber
Definition
ProtobufSubscriber.java:15
org.wpilib.networktables.PubSubOption
Definition
PubSubOption.java:8
org.wpilib.util.protobuf.Protobuf
Definition
Protobuf.java:32
org
wpilib
networktables
ProtobufTopic.java
Generated by
1.18.0