[wpilib] Allow SendableCameraWrappers to take arbitrary URLs (#3850)

Useful for adding cameras that are streamed from a coprocessor

Co-authored-by: Peter Johnson <johnson.peter@gmail.com>
Co-authored-by: Sam Carlberg <sam.carlberg@gmail.com>
This commit is contained in:
Peter Johnson
2022-01-01 10:10:37 -08:00
committed by GitHub
parent a3645dea34
commit ecee224e81
6 changed files with 191 additions and 19 deletions

View File

@@ -8,19 +8,19 @@
#include <memory>
#include <string>
#include <wpi/DenseMap.h>
#include <wpi/StringMap.h>
#include <wpi/sendable/SendableBuilder.h>
#include <wpi/sendable/SendableRegistry.h>
namespace frc {
namespace detail {
std::shared_ptr<SendableCameraWrapper>& GetSendableCameraWrapper(
CS_Source source) {
static wpi::DenseMap<int, std::shared_ptr<SendableCameraWrapper>> wrappers;
return wrappers[static_cast<int>(source)];
std::string_view cameraName) {
static wpi::StringMap<std::shared_ptr<SendableCameraWrapper>> wrappers;
return wrappers[cameraName];
}
void AddToSendableRegistry(wpi::Sendable* sendable, std::string name) {
void AddToSendableRegistry(wpi::Sendable* sendable, std::string_view name) {
wpi::SendableRegistry::Add(sendable, name);
}
} // namespace detail