// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.

#pragma once

#include "wpi/cs/VideoProperty.hpp"
#include "wpi/cs/VideoSink.hpp"
#include "wpi/cs/VideoSource.hpp"
#include "wpi/cs/cscore_cpp.hpp"

namespace wpi::cs {

/**
 * An event generated by the library and provided to event listeners.
 */
class VideoEvent : public RawEvent {
 public:
  /**
   * Returns the source associated with the event (if any).
   *
   * @return The source associated with the event (if any).
   */
  VideoSource GetSource() const {
    CS_Status status = 0;
    return VideoSource{sourceHandle == 0 ? 0
                                         : CopySource(sourceHandle, &status)};
  }

  /**
   * Returns the sink associated with the event (if any).
   *
   * @return The sink associated with the event (if any).
   */
  VideoSink GetSink() const {
    CS_Status status = 0;
    return VideoSink{sinkHandle == 0 ? 0 : CopySink(sinkHandle, &status)};
  }

  /**
   * Returns the property associated with the event (if any).
   *
   * @return The property associated with the event (if any).
   */
  VideoProperty GetProperty() const {
    return VideoProperty{propertyHandle,
                         static_cast<VideoProperty::Kind>(propertyKind)};
  }
};

}  // namespace wpi::cs
