001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.cameraserver;
006
007/** Storage for CameraServerShared instance. */
008public final class CameraServerSharedStore {
009  private static CameraServerShared cameraServerShared;
010
011  private CameraServerSharedStore() {}
012
013  /**
014   * Get the CameraServerShared object.
015   *
016   * @return The CameraServerSharedObject
017   */
018  public static synchronized CameraServerShared getCameraServerShared() {
019    if (cameraServerShared == null) {
020      cameraServerShared =
021          new CameraServerShared() {
022            @Override
023            public void reportUsage(String resource, String data) {}
024
025            @Override
026            public void reportDriverStationError(String error) {}
027
028            @Override
029            public Long getRobotMainThreadId() {
030              return null;
031            }
032          };
033    }
034    return cameraServerShared;
035  }
036
037  /**
038   * Report usage.
039   *
040   * @param resource the resource name
041   * @param data arbitrary string data
042   */
043  public static void reportUsage(String resource, String data) {
044    getCameraServerShared().reportUsage(resource, data);
045  }
046
047  /**
048   * Set the CameraServerShared object.
049   *
050   * @param shared The CameraServerShared object.
051   */
052  public static synchronized void setCameraServerShared(CameraServerShared shared) {
053    cameraServerShared = shared;
054  }
055}