From 9782abbcb168fa90390adba0977cda3ae71cbdbf Mon Sep 17 00:00:00 2001 From: Dean Brettle Date: Mon, 27 May 2024 21:19:12 -0700 Subject: [PATCH] [wpilib] Add protected default constructor for CallbackStore (#6667) This is to allow 3rd party sim providers (eg vendors) to subclass this class so that the register methods of their sim classes can return CallbackStores like the builtin sims. Although it was already possible to create such a subclass but passing dummy parameters to one of the other constructors, this eliminates the need to pass such dummy parameters and makes it clearer that subclassing is allowed. --- .../first/wpilibj/simulation/CallbackStore.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/CallbackStore.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/CallbackStore.java index 69daa87ff8..b9bc746a23 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/CallbackStore.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/simulation/CallbackStore.java @@ -21,6 +21,20 @@ public class CallbackStore implements AutoCloseable { void cancel(int uid); } + /** + * Constructs an empty CallbackStore. This constructor is to allow 3rd party sim providers (eg + * vendors) to subclass this class (without needing provide dummy constructing parameters) so that + * the register methods of their sim classes can return CallbackStores like the builtin sims. + * Note: It should not be called by teams that are just using sims! + */ + protected CallbackStore() { + this.m_cancelType = -1; + this.m_index = -1; + this.m_uid = -1; + this.m_cancelCallback = null; + this.m_cancelCallbackChannel = null; + } + /** * Note: This constructor is for simulation classes only. It should not be called by teams! *