001/*----------------------------------------------------------------------------*/ 002/* Copyright (c) FIRST 2017-2018. All Rights Reserved. */ 003/* Open Source Software - may be modified and shared by FRC teams. The code */ 004/* must be accompanied by the FIRST BSD license file in the root directory of */ 005/* the project. */ 006/*----------------------------------------------------------------------------*/ 007 008package edu.wpi.first.networktables; 009 010/** 011 * NetworkTables Entry information. 012 */ 013public final class EntryInfo { 014 /** Entry handle. */ 015 public final int entry; 016 017 /** Entry name. */ 018 public final String name; 019 020 /** Entry type. */ 021 public final NetworkTableType type; 022 023 /** Entry flags. */ 024 public final int flags; 025 026 /** Timestamp of last change to entry (type or value). */ 027 public final long last_change; 028 029 /** Constructor. 030 * This should generally only be used internally to NetworkTables. 031 * @param inst Instance 032 * @param entry Entry handle 033 * @param name Name 034 * @param type Type (integer version of {@link NetworkTableType}) 035 * @param flags Flags 036 * @param last_change Timestamp of last change 037 */ 038 public EntryInfo(NetworkTableInstance inst, int entry, String name, int type, int flags, long last_change) { 039 this.inst = inst; 040 this.entry = entry; 041 this.name = name; 042 this.type = NetworkTableType.getFromInt(type); 043 this.flags = flags; 044 this.last_change = last_change; 045 } 046 047 /* Network table instance. */ 048 private final NetworkTableInstance inst; 049 050 /* Cached entry object. */ 051 private NetworkTableEntry entryObject; 052 053 /** 054 * Get the entry as an object. 055 * @return NetworkTableEntry for this entry. 056 */ 057 NetworkTableEntry getEntry() { 058 if (entryObject == null) { 059 entryObject = new NetworkTableEntry(inst, entry); 060 } 061 return entryObject; 062 } 063}