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
009/** NetworkTables Raw topic. */
010public final class RawTopic extends Topic {
011  /**
012   * Construct from a generic topic.
013   *
014   * @param topic Topic
015   */
016  public RawTopic(Topic topic) {
017    super(topic.m_inst, topic.m_handle);
018  }
019
020  /**
021   * Constructor; use NetworkTableInstance.getRawTopic() instead.
022   *
023   * @param inst Instance
024   * @param handle Native handle
025   */
026  public RawTopic(NetworkTableInstance inst, int handle) {
027    super(inst, handle);
028  }
029
030  /**
031   * Create a new subscriber to the topic.
032   *
033   * <p>The subscriber is only active as long as the returned object
034   * is not closed.
035   *
036   * <p>Subscribers that do not match the published data type do not return
037   * any values. To determine if the data type matches, use the appropriate
038   * Topic functions.
039   *
040   * @param typeString type string
041
042   * @param defaultValue default value used when a default is not provided to a
043   *        getter function
044   * @param options subscribe options
045   * @return subscriber
046   */
047  public RawSubscriber subscribe(
048      String typeString,
049
050      byte[] defaultValue,
051      PubSubOption... options) {
052    return new RawEntryImpl(
053        this,
054        NetworkTablesJNI.subscribe(
055            m_handle, NetworkTableType.kRaw.getValue(),
056            typeString, options),
057        defaultValue);
058  }
059
060  /**
061   * Create a new publisher to the topic.
062   *
063   * <p>The publisher is only active as long as the returned object
064   * is not closed.
065   *
066   * <p>It is not possible to publish two different data types to the same
067   * topic. Conflicts between publishers are typically resolved by the server on
068   * a first-come, first-served basis. Any published values that do not match
069   * the topic's data type are dropped (ignored). To determine if the data type
070   * matches, use the appropriate Topic functions.
071   *
072   * @param typeString type string
073
074   * @param options publish options
075   * @return publisher
076   */
077  public RawPublisher publish(
078      String typeString,
079
080      PubSubOption... options) {
081    return new RawEntryImpl(
082        this,
083        NetworkTablesJNI.publish(
084            m_handle, NetworkTableType.kRaw.getValue(),
085            typeString, options),
086        new byte[] {});
087  }
088
089  /**
090   * Create a new publisher to the topic, with type string and initial properties.
091   *
092   * <p>The publisher is only active as long as the returned object
093   * is not closed.
094   *
095   * <p>It is not possible to publish two different data types to the same
096   * topic. Conflicts between publishers are typically resolved by the server on
097   * a first-come, first-served basis. Any published values that do not match
098   * the topic's data type are dropped (ignored). To determine if the data type
099   * matches, use the appropriate Topic functions.
100   *
101   * @param typeString type string
102   * @param properties JSON properties
103   * @param options publish options
104   * @return publisher
105   * @throws IllegalArgumentException if properties is not a JSON object
106   */
107  public RawPublisher publishEx(
108      String typeString,
109      String properties,
110      PubSubOption... options) {
111    return new RawEntryImpl(
112        this,
113        NetworkTablesJNI.publishEx(
114            m_handle, NetworkTableType.kRaw.getValue(),
115            typeString, properties, options),
116        new byte[] {});
117  }
118
119  /**
120   * Create a new entry for the topic.
121   *
122   * <p>Entries act as a combination of a subscriber and a weak publisher. The
123   * subscriber is active as long as the entry is not closed. The publisher is
124   * created when the entry is first written to, and remains active until either
125   * unpublish() is called or the entry is closed.
126   *
127   * <p>It is not possible to use two different data types with the same
128   * topic. Conflicts between publishers are typically resolved by the server on
129   * a first-come, first-served basis. Any published values that do not match
130   * the topic's data type are dropped (ignored), and the entry will show no new
131   * values if the data type does not match. To determine if the data type
132   * matches, use the appropriate Topic functions.
133   *
134   * @param typeString type string
135
136   * @param defaultValue default value used when a default is not provided to a
137   *        getter function
138   * @param options publish and/or subscribe options
139   * @return entry
140   */
141  public RawEntry getEntry(
142      String typeString,
143
144      byte[] defaultValue,
145      PubSubOption... options) {
146    return new RawEntryImpl(
147        this,
148        NetworkTablesJNI.getEntry(
149            m_handle, NetworkTableType.kRaw.getValue(),
150            typeString, options),
151        defaultValue);
152  }
153
154}