/*----------------------------------------------------------------------------*/ /* Copyright (c) 2018 FIRST. All Rights Reserved. */ /* Open Source Software - may be modified and shared by FRC teams. The code */ /* must be accompanied by the FIRST BSD license file in the root directory of */ /* the project. */ /*----------------------------------------------------------------------------*/ #ifndef CSCORE_INSTANCE_H_ #define CSCORE_INSTANCE_H_ #include #include #include #include #include "Log.h" #include "NetworkListener.h" #include "Notifier.h" #include "SinkImpl.h" #include "SourceImpl.h" #include "Telemetry.h" #include "UnlimitedHandleResource.h" namespace cs { struct SourceData { SourceData(CS_SourceKind kind_, std::shared_ptr source_) : kind{kind_}, refCount{0}, source{source_} {} CS_SourceKind kind; std::atomic_int refCount; std::shared_ptr source; }; struct SinkData { explicit SinkData(CS_SinkKind kind_, std::shared_ptr sink_) : kind{kind_}, refCount{0}, sourceHandle{0}, sink{sink_} {} CS_SinkKind kind; std::atomic_int refCount; std::atomic sourceHandle; std::shared_ptr sink; }; class Instance { public: Instance(const Instance&) = delete; Instance& operator=(const Instance&) = delete; ~Instance(); static Instance& GetInstance(); UnlimitedHandleResource sources; UnlimitedHandleResource sinks; wpi::Logger logger; Notifier notifier; Telemetry telemetry; NetworkListener network_listener; wpi::EventLoopRunner event_loop; std::pair> FindSink(const SinkImpl& sink); std::pair> FindSource( const SourceImpl& source); void SetDefaultLogger(); private: Instance(); }; } // namespace cs #endif // CSCORE_INSTANCE_H_