001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005// THIS FILE WAS AUTO-GENERATED BY ./ntcore/generate_topics.py. DO NOT MODIFY
006
007package edu.wpi.first.networktables;
008
009import java.nio.ByteBuffer;
010import java.util.function.Consumer;
011
012/** NetworkTables generic publisher. */
013public interface GenericPublisher extends Publisher, Consumer<NetworkTableValue> {
014  /**
015   * Get the corresponding topic.
016   *
017   * @return Topic
018   */
019  @Override
020  Topic getTopic();
021
022  /**
023   * Publish a new value.
024   *
025   * @param value value to publish
026   * @return False if the topic already exists with a different type
027   */
028  boolean set(NetworkTableValue value);
029
030  /**
031   * Publish a new value.
032   *
033   * @param value value to publish
034   * @return False if the topic already exists with a different type
035   * @throws IllegalArgumentException if the value is not a known type
036   */
037  default boolean setValue(Object value) {
038    return setValue(value, 0);
039  }
040
041  /**
042   * Publish a new value.
043   *
044   * @param value value to publish
045   * @param time timestamp; 0 indicates current NT time should be used
046   * @return False if the topic already exists with a different type
047   * @throws IllegalArgumentException if the value is not a known type
048   */
049  boolean setValue(Object value, long time);
050
051  /**
052   * Publish a new value.
053   *
054   * @param value value to publish
055   * @return False if the topic already exists with a different type
056   */
057  default boolean setBoolean(boolean value) {
058    return setBoolean(value, 0);
059  }
060
061  /**
062   * Publish a new value.
063   *
064   * @param value value to publish
065   * @param time timestamp; 0 indicates current NT time should be used
066   * @return False if the topic already exists with a different type
067   */
068  boolean setBoolean(boolean value, long time);
069
070  /**
071   * Publish a new value.
072   *
073   * @param value value to publish
074   * @return False if the topic already exists with a different type
075   */
076  default boolean setInteger(long value) {
077    return setInteger(value, 0);
078  }
079
080  /**
081   * Publish a new value.
082   *
083   * @param value value to publish
084   * @param time timestamp; 0 indicates current NT time should be used
085   * @return False if the topic already exists with a different type
086   */
087  boolean setInteger(long value, long time);
088
089  /**
090   * Publish a new value.
091   *
092   * @param value value to publish
093   * @return False if the topic already exists with a different type
094   */
095  default boolean setFloat(float value) {
096    return setFloat(value, 0);
097  }
098
099  /**
100   * Publish a new value.
101   *
102   * @param value value to publish
103   * @param time timestamp; 0 indicates current NT time should be used
104   * @return False if the topic already exists with a different type
105   */
106  boolean setFloat(float value, long time);
107
108  /**
109   * Publish a new value.
110   *
111   * @param value value to publish
112   * @return False if the topic already exists with a different type
113   */
114  default boolean setDouble(double value) {
115    return setDouble(value, 0);
116  }
117
118  /**
119   * Publish a new value.
120   *
121   * @param value value to publish
122   * @param time timestamp; 0 indicates current NT time should be used
123   * @return False if the topic already exists with a different type
124   */
125  boolean setDouble(double value, long time);
126
127  /**
128   * Publish a new value.
129   *
130   * @param value value to publish
131   * @return False if the topic already exists with a different type
132   */
133  default boolean setString(String value) {
134    return setString(value, 0);
135  }
136
137  /**
138   * Publish a new value.
139   *
140   * @param value value to publish
141   * @param time timestamp; 0 indicates current NT time should be used
142   * @return False if the topic already exists with a different type
143   */
144  boolean setString(String value, long time);
145
146  /**
147   * Publish a new value.
148   *
149   * @param value value to publish
150   * @return False if the topic already exists with a different type
151   */
152  default boolean setRaw(byte[] value) {
153    return setRaw(value, 0);
154  }
155
156  /**
157   * Publish a new value.
158   *
159   * @param value value to publish
160   * @return False if the topic already exists with a different type
161   */
162  default boolean setRaw(ByteBuffer value) {
163    return setRaw(value, 0);
164  }
165
166  /**
167   * Publish a new value.
168   *
169   * @param value value to publish
170   * @param time timestamp; 0 indicates current NT time should be used
171   * @return False if the topic already exists with a different type
172   */
173  default boolean setRaw(byte[] value, long time) {
174    return setRaw(value, 0, value.length, time);
175  }
176
177  /**
178   * Publish a new value.
179   *
180   * @param value value to publish; will send from value.position() to value.limit()
181   * @param time timestamp; 0 indicates current NT time should be used
182   * @return False if the topic already exists with a different type
183   */
184  default boolean setRaw(ByteBuffer value, long time) {
185    int pos = value.position();
186    return setRaw(value, pos, value.limit() - pos, time);
187  }
188
189  /**
190   * Publish a new value.
191   *
192   * @param value value to publish
193   * @param start Start position of data (in buffer)
194   * @param len Length of data (must be less than or equal to value.length - start)
195   * @return False if the topic already exists with a different type
196   */
197  default boolean setRaw(byte[] value, int start, int len) {
198    return setRaw(value, start, len, 0);
199  }
200
201  /**
202   * Publish a new value.
203   *
204   * @param value value to publish
205   * @param start Start position of data (in buffer)
206   * @param len Length of data (must be less than or equal to value.length - start)
207   * @param time timestamp; 0 indicates current NT time should be used
208   * @return False if the topic already exists with a different type
209   */
210  boolean setRaw(byte[] value, int start, int len, long time);
211
212  /**
213   * Publish a new value.
214   *
215   * @param value value to publish
216   * @param start Start position of data (in buffer)
217   * @param len Length of data (must be less than or equal to value.capacity() - start)
218   * @return False if the topic already exists with a different type
219   */
220  default boolean setRaw(ByteBuffer value, int start, int len) {
221    return setRaw(value, start, len, 0);
222  }
223
224  /**
225   * Publish a new value.
226   *
227   * @param value value to publish
228   * @param start Start position of data (in buffer)
229   * @param len Length of data (must be less than or equal to value.capacity() - start)
230   * @param time timestamp; 0 indicates current NT time should be used
231   * @return False if the topic already exists with a different type
232   */
233  boolean setRaw(ByteBuffer value, int start, int len, long time);
234
235  /**
236   * Publish a new value.
237   *
238   * @param value value to publish
239   * @return False if the topic already exists with a different type
240   */
241  default boolean setBooleanArray(boolean[] value) {
242    return setBooleanArray(value, 0);
243  }
244
245  /**
246   * Publish a new value.
247   *
248   * @param value value to publish
249   * @param time timestamp; 0 indicates current NT time should be used
250   * @return False if the topic already exists with a different type
251   */
252  boolean setBooleanArray(boolean[] value, long time);
253
254  /**
255   * Publish a new value.
256   *
257   * @param value value to publish
258   * @return False if the topic already exists with a different type
259   */
260  default boolean setBooleanArray(Boolean[] value) {
261    return setBooleanArray(value, 0);
262  }
263
264  /**
265   * Publish a new value.
266   *
267   * @param value value to publish
268   * @param time timestamp; 0 indicates current NT time should be used
269   * @return False if the topic already exists with a different type
270   */
271  boolean setBooleanArray(Boolean[] value, long time);
272
273  /**
274   * Publish a new value.
275   *
276   * @param value value to publish
277   * @return False if the topic already exists with a different type
278   */
279  default boolean setIntegerArray(long[] value) {
280    return setIntegerArray(value, 0);
281  }
282
283  /**
284   * Publish a new value.
285   *
286   * @param value value to publish
287   * @param time timestamp; 0 indicates current NT time should be used
288   * @return False if the topic already exists with a different type
289   */
290  boolean setIntegerArray(long[] value, long time);
291
292  /**
293   * Publish a new value.
294   *
295   * @param value value to publish
296   * @return False if the topic already exists with a different type
297   */
298  default boolean setIntegerArray(Long[] value) {
299    return setIntegerArray(value, 0);
300  }
301
302  /**
303   * Publish a new value.
304   *
305   * @param value value to publish
306   * @param time timestamp; 0 indicates current NT time should be used
307   * @return False if the topic already exists with a different type
308   */
309  boolean setIntegerArray(Long[] value, long time);
310
311  /**
312   * Publish a new value.
313   *
314   * @param value value to publish
315   * @return False if the topic already exists with a different type
316   */
317  default boolean setFloatArray(float[] value) {
318    return setFloatArray(value, 0);
319  }
320
321  /**
322   * Publish a new value.
323   *
324   * @param value value to publish
325   * @param time timestamp; 0 indicates current NT time should be used
326   * @return False if the topic already exists with a different type
327   */
328  boolean setFloatArray(float[] value, long time);
329
330  /**
331   * Publish a new value.
332   *
333   * @param value value to publish
334   * @return False if the topic already exists with a different type
335   */
336  default boolean setFloatArray(Float[] value) {
337    return setFloatArray(value, 0);
338  }
339
340  /**
341   * Publish a new value.
342   *
343   * @param value value to publish
344   * @param time timestamp; 0 indicates current NT time should be used
345   * @return False if the topic already exists with a different type
346   */
347  boolean setFloatArray(Float[] value, long time);
348
349  /**
350   * Publish a new value.
351   *
352   * @param value value to publish
353   * @return False if the topic already exists with a different type
354   */
355  default boolean setDoubleArray(double[] value) {
356    return setDoubleArray(value, 0);
357  }
358
359  /**
360   * Publish a new value.
361   *
362   * @param value value to publish
363   * @param time timestamp; 0 indicates current NT time should be used
364   * @return False if the topic already exists with a different type
365   */
366  boolean setDoubleArray(double[] value, long time);
367
368  /**
369   * Publish a new value.
370   *
371   * @param value value to publish
372   * @return False if the topic already exists with a different type
373   */
374  default boolean setDoubleArray(Double[] value) {
375    return setDoubleArray(value, 0);
376  }
377
378  /**
379   * Publish a new value.
380   *
381   * @param value value to publish
382   * @param time timestamp; 0 indicates current NT time should be used
383   * @return False if the topic already exists with a different type
384   */
385  boolean setDoubleArray(Double[] value, long time);
386
387  /**
388   * Publish a new value.
389   *
390   * @param value value to publish
391   * @return False if the topic already exists with a different type
392   */
393  default boolean setStringArray(String[] value) {
394    return setStringArray(value, 0);
395  }
396
397  /**
398   * Publish a new value.
399   *
400   * @param value value to publish
401   * @param time timestamp; 0 indicates current NT time should be used
402   * @return False if the topic already exists with a different type
403   */
404  boolean setStringArray(String[] value, long time);
405
406  /**
407   * Sets the entry's value if it does not exist.
408   *
409   * @param defaultValue the default value to set
410   * @return False if the entry exists with a different type
411   */
412  boolean setDefault(NetworkTableValue defaultValue);
413
414  /**
415   * Sets the entry's value if it does not exist.
416   *
417   * @param defaultValue the default value to set
418   * @return False if the entry exists with a different type
419   * @throws IllegalArgumentException if the value is not a known type
420   */
421  boolean setDefaultValue(Object defaultValue);
422
423
424  /**
425   * Sets the entry's value if it does not exist.
426   *
427   * @param defaultValue the default value to set
428   * @return False if the entry exists with a different type
429   */
430  boolean setDefaultBoolean(boolean defaultValue);
431
432
433  /**
434   * Sets the entry's value if it does not exist.
435   *
436   * @param defaultValue the default value to set
437   * @return False if the entry exists with a different type
438   */
439  boolean setDefaultInteger(long defaultValue);
440
441
442  /**
443   * Sets the entry's value if it does not exist.
444   *
445   * @param defaultValue the default value to set
446   * @return False if the entry exists with a different type
447   */
448  boolean setDefaultFloat(float defaultValue);
449
450
451  /**
452   * Sets the entry's value if it does not exist.
453   *
454   * @param defaultValue the default value to set
455   * @return False if the entry exists with a different type
456   */
457  boolean setDefaultDouble(double defaultValue);
458
459
460  /**
461   * Sets the entry's value if it does not exist.
462   *
463   * @param defaultValue the default value to set
464   * @return False if the entry exists with a different type
465   */
466  boolean setDefaultString(String defaultValue);
467
468
469  /**
470   * Sets the entry's value if it does not exist.
471   *
472   * @param defaultValue the default value to set
473   * @return False if the entry exists with a different type
474   */
475  default boolean setDefaultRaw(byte[] defaultValue) {
476    return setDefaultRaw(defaultValue, 0, defaultValue.length);
477  }
478
479  /**
480   * Sets the entry's value if it does not exist.
481   *
482   * @param defaultValue the default value to set; will send from defaultValue.position() to
483   *                     defaultValue.limit()
484   * @return False if the entry exists with a different type
485   */
486  default boolean setDefaultRaw(ByteBuffer defaultValue) {
487    int pos = defaultValue.position();
488    return setDefaultRaw(defaultValue, pos, defaultValue.limit() - pos);
489  }
490
491  /**
492   * Sets the entry's value if it does not exist.
493   *
494   * @param defaultValue the default value to set
495   * @param start Start position of data (in buffer)
496   * @param len Length of data (must be less than or equal to value.length - start)
497   * @return False if the entry exists with a different type
498   */
499  boolean setDefaultRaw(byte[] defaultValue, int start, int len);
500
501  /**
502   * Sets the entry's value if it does not exist.
503   *
504   * @param defaultValue the default value to set
505   * @param start Start position of data (in buffer)
506   * @param len Length of data (must be less than or equal to value.capacity() - start)
507   * @return False if the entry exists with a different type
508   */
509  boolean setDefaultRaw(ByteBuffer defaultValue, int start, int len);
510
511
512  /**
513   * Sets the entry's value if it does not exist.
514   *
515   * @param defaultValue the default value to set
516   * @return False if the entry exists with a different type
517   */
518  boolean setDefaultBooleanArray(boolean[] defaultValue);
519
520  boolean setDefaultBooleanArray(Boolean[] defaultValue);
521
522
523  /**
524   * Sets the entry's value if it does not exist.
525   *
526   * @param defaultValue the default value to set
527   * @return False if the entry exists with a different type
528   */
529  boolean setDefaultIntegerArray(long[] defaultValue);
530
531  boolean setDefaultIntegerArray(Long[] defaultValue);
532
533
534  /**
535   * Sets the entry's value if it does not exist.
536   *
537   * @param defaultValue the default value to set
538   * @return False if the entry exists with a different type
539   */
540  boolean setDefaultFloatArray(float[] defaultValue);
541
542  boolean setDefaultFloatArray(Float[] defaultValue);
543
544
545  /**
546   * Sets the entry's value if it does not exist.
547   *
548   * @param defaultValue the default value to set
549   * @return False if the entry exists with a different type
550   */
551  boolean setDefaultDoubleArray(double[] defaultValue);
552
553  boolean setDefaultDoubleArray(Double[] defaultValue);
554
555
556  /**
557   * Sets the entry's value if it does not exist.
558   *
559   * @param defaultValue the default value to set
560   * @return False if the entry exists with a different type
561   */
562  boolean setDefaultStringArray(String[] defaultValue);
563
564  @Override
565  default void accept(NetworkTableValue value) {
566    set(value);
567  }
568}