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
005package edu.wpi.first.networktables;
006
007import java.util.function.LongSupplier;
008
009/** NetworkTables Integer subscriber. */
010@SuppressWarnings("PMD.MissingOverride")
011public interface IntegerSubscriber extends Subscriber, LongSupplier {
012  /**
013   * Get the corresponding topic.
014   *
015   * @return Topic
016   */
017  @Override
018  IntegerTopic getTopic();
019
020  /**
021   * Get the last published value.
022   * If no value has been published, returns the stored default value.
023   *
024   * @return value
025   */
026  long get();
027
028  /**
029   * Get the last published value.
030   * If no value has been published, returns the passed defaultValue.
031   *
032   * @param defaultValue default value to return if no value has been published
033   * @return value
034   */
035  long get(long defaultValue);
036
037  @Override
038  default long getAsLong() {
039    return get();
040  }
041
042  /**
043   * Get the last published value along with its timestamp
044   * If no value has been published, returns the stored default value and a
045   * timestamp of 0.
046   *
047   * @return timestamped value
048   */
049  TimestampedInteger getAtomic();
050
051  /**
052   * Get the last published value along with its timestamp
053   * If no value has been published, returns the passed defaultValue and a
054   * timestamp of 0.
055   *
056   * @param defaultValue default value to return if no value has been published
057   * @return timestamped value
058   */
059  TimestampedInteger getAtomic(long defaultValue);
060
061  /**
062   * Get an array of all value changes since the last call to readQueue.
063   * Also provides a timestamp for each value.
064   *
065   * <p>The "poll storage" subscribe option can be used to set the queue
066   * depth.
067   *
068   * @return Array of timestamped values; empty array if no new changes have
069   *     been published since the previous call.
070   */
071  TimestampedInteger[] readQueue();
072
073  /**
074   * Get an array of all value changes since the last call to readQueue.
075   *
076   * <p>The "poll storage" subscribe option can be used to set the queue
077   * depth.
078   *
079   * @return Array of values; empty array if no new changes have been
080   *     published since the previous call.
081   */
082  long[] readQueueValues();
083}