RobotCore 1.0
WPILib port to raspberry Pi
Loading...
Searching...
No Matches
Topic.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
5package org.wpilib.networktables;
6
8public class Topic {
15 Topic(NetworkTableInstance inst, int handle) {
16 m_inst = inst;
17 m_handle = handle;
18 }
19
25 public boolean isValid() {
26 return m_handle != 0;
27 }
28
34 public int getHandle() {
35 return m_handle;
36 }
37
44 return m_inst;
45 }
46
52 public String getName() {
53 return NetworkTablesJNI.getTopicName(m_handle);
54 }
55
64
71 public String getTypeString() {
72 return NetworkTablesJNI.getTopicTypeString(m_handle);
73 }
74
80 public TopicInfo getInfo() {
81 return NetworkTablesJNI.getTopicInfo(m_inst, m_handle);
82 }
83
89 public void setPersistent(boolean persistent) {
90 NetworkTablesJNI.setTopicPersistent(m_handle, persistent);
91 }
92
98 public boolean isPersistent() {
99 return NetworkTablesJNI.getTopicPersistent(m_handle);
100 }
101
107 public void setRetained(boolean retained) {
108 NetworkTablesJNI.setTopicRetained(m_handle, retained);
109 }
110
116 public boolean isRetained() {
117 return NetworkTablesJNI.getTopicRetained(m_handle);
118 }
119
126 public void setCached(boolean cached) {
127 NetworkTablesJNI.setTopicCached(m_handle, cached);
128 }
129
135 public boolean isCached() {
136 return NetworkTablesJNI.getTopicCached(m_handle);
137 }
138
144 public boolean exists() {
145 return NetworkTablesJNI.getTopicExists(m_handle);
146 }
147
154 public String getProperty(String name) {
155 return NetworkTablesJNI.getTopicProperty(m_handle, name);
156 }
157
165 public void setProperty(String name, String value) {
166 NetworkTablesJNI.setTopicProperty(m_handle, name, value);
167 }
168
174 public void deleteProperty(String name) {
175 NetworkTablesJNI.deleteTopicProperty(m_handle, name);
176 }
177
184 public String getProperties() {
185 return NetworkTablesJNI.getTopicProperties(m_handle);
186 }
187
196 public void setProperties(String properties) {
197 NetworkTablesJNI.setTopicProperties(m_handle, properties);
198 }
199
209 return genericSubscribe("", options);
210 }
211
224 public GenericSubscriber genericSubscribe(String typeString, PubSubOption... options) {
225 return new GenericEntryImpl(
226 this,
227 NetworkTablesJNI.subscribe(
228 m_handle, NetworkTableType.getFromString(typeString).getValue(), typeString, options));
229 }
230
245 public GenericPublisher genericPublish(String typeString, PubSubOption... options) {
246 return new GenericEntryImpl(
247 this,
248 NetworkTablesJNI.publish(
249 m_handle, NetworkTableType.getFromString(typeString).getValue(), typeString, options));
250 }
251
269 String typeString, String properties, PubSubOption... options) {
270 return new GenericEntryImpl(
271 this,
272 NetworkTablesJNI.publishEx(
273 m_handle,
275 typeString,
276 properties,
277 options));
278 }
279
296 return getGenericEntry("", options);
297 }
298
315 public GenericEntry getGenericEntry(String typeString, PubSubOption... options) {
316 return new GenericEntryImpl(
317 this,
318 NetworkTablesJNI.getEntry(
319 m_handle, NetworkTableType.getFromString(typeString).getValue(), typeString, options));
320 }
321
322 @Override
323 public boolean equals(Object other) {
324 return other instanceof Topic topic && m_handle == topic.m_handle;
325 }
326
327 @Override
328 public int hashCode() {
329 return m_handle;
330 }
331
334
336 protected final int m_handle;
337}
final NetworkTableInstance m_inst
Definition Topic.java:333
GenericSubscriber genericSubscribe(String typeString, PubSubOption... options)
Definition Topic.java:224
String getProperty(String name)
Definition Topic.java:154
GenericEntry getGenericEntry(String typeString, PubSubOption... options)
Definition Topic.java:315
void setProperties(String properties)
Definition Topic.java:196
GenericPublisher genericPublishEx(String typeString, String properties, PubSubOption... options)
Definition Topic.java:268
void deleteProperty(String name)
Definition Topic.java:174
GenericEntry getGenericEntry(PubSubOption... options)
Definition Topic.java:295
void setCached(boolean cached)
Definition Topic.java:126
void setRetained(boolean retained)
Definition Topic.java:107
void setPersistent(boolean persistent)
Definition Topic.java:89
NetworkTableType getType()
Definition Topic.java:61
GenericPublisher genericPublish(String typeString, PubSubOption... options)
Definition Topic.java:245
NetworkTableInstance getInstance()
Definition Topic.java:43
GenericSubscriber genericSubscribe(PubSubOption... options)
Definition Topic.java:208
void setProperty(String name, String value)
Definition Topic.java:165
static NetworkTableType getFromString(String typeString)
static NetworkTableType getFromInt(int value)