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 org.wpilib.networktables; 006 007/** NetworkTables value event data. */ 008public final class ValueEventData { 009 /** Topic handle. Topic.getHandle() can be used to map this to the corresponding Topic object. */ 010 public final int topic; 011 012 /** 013 * Subscriber/entry handle. Subscriber.getHandle() or entry.getHandle() can be used to map this to 014 * the corresponding Subscriber or Entry object. 015 */ 016 public final int subentry; 017 018 /** The new value. */ 019 public final NetworkTableValue value; 020 021 /** 022 * Constructor. This should generally only be used internally to NetworkTables. 023 * 024 * @param inst Instance 025 * @param topic Topic handle 026 * @param subentry Subscriber/entry handle 027 * @param value The new value 028 */ 029 public ValueEventData( 030 NetworkTableInstance inst, int topic, int subentry, NetworkTableValue value) { 031 this.m_inst = inst; 032 this.topic = topic; 033 this.subentry = subentry; 034 this.value = value; 035 } 036 037 /* Cached topic object. */ 038 private Topic m_topicObject; 039 040 private final NetworkTableInstance m_inst; 041 042 /** 043 * Get the topic as an object. 044 * 045 * @return Topic for this notification. 046 */ 047 public Topic getTopic() { 048 if (m_topicObject == null) { 049 m_topicObject = new Topic(m_inst, topic); 050 } 051 return m_topicObject; 052 } 053}