diff --git a/include/cscore_oo.h b/include/cscore_oo.h index 1e96bd5b65..a526e3833b 100644 --- a/include/cscore_oo.h +++ b/include/cscore_oo.h @@ -91,6 +91,14 @@ class VideoSource { explicit operator bool() const { return m_handle != 0; } + int GetHandle() const { return m_handle; } + + bool operator==(const VideoSource& other) const { + return m_handle == other.m_handle; + } + + bool operator!=(const VideoSource& other) const { return !(*this == other); } + /// Get the name of the source. The name is an arbitrary identifier /// provided when the source is created, and should be unique. std::string GetName() const; @@ -262,6 +270,14 @@ class VideoSink { explicit operator bool() const { return m_handle != 0; } + int GetHandle() const { return m_handle; } + + bool operator==(const VideoSink& other) const { + return m_handle == other.m_handle; + } + + bool operator!=(const VideoSink& other) const { return !(*this == other); } + /// Get the name of the sink. The name is an arbitrary identifier /// provided when the sink is created, and should be unique. std::string GetName() const; diff --git a/java/src/edu/wpi/cscore/VideoSink.java b/java/src/edu/wpi/cscore/VideoSink.java index ee187b4813..e7f001c59d 100644 --- a/java/src/edu/wpi/cscore/VideoSink.java +++ b/java/src/edu/wpi/cscore/VideoSink.java @@ -26,6 +26,22 @@ public class VideoSink { return m_handle != 0; } + public int getHandle() { + return m_handle; + } + + public boolean equals(Object other) { + if (this == other) return true; + if (other == null) return false; + if (getClass() != other.getClass()) return false; + VideoSink sink = (VideoSink) other; + return m_handle == sink.m_handle; + } + + public int hashCode() { + return m_handle; + } + /// Get the name of the sink. The name is an arbitrary identifier /// provided when the sink is created, and should be unique. public String getName() { diff --git a/java/src/edu/wpi/cscore/VideoSource.java b/java/src/edu/wpi/cscore/VideoSource.java index 478f2d8c7e..e7210b2ab1 100644 --- a/java/src/edu/wpi/cscore/VideoSource.java +++ b/java/src/edu/wpi/cscore/VideoSource.java @@ -26,6 +26,22 @@ public class VideoSource { return m_handle != 0; } + public int getHandle() { + return m_handle; + } + + public boolean equals(Object other) { + if (this == other) return true; + if (other == null) return false; + if (getClass() != other.getClass()) return false; + VideoSource source = (VideoSource) other; + return m_handle == source.m_handle; + } + + public int hashCode() { + return m_handle; + } + /// Get the name of the source. The name is an arbitrary identifier /// provided when the source is created, and should be unique. public String getName() {