2016-09-05 12:00:04 -07:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-01-02 09:16:20 -08:00
|
|
|
/* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
|
2016-09-05 12:00:04 -07:00
|
|
|
/* 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. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2017-08-25 17:48:06 -07:00
|
|
|
#ifndef CSCORE_SINKIMPL_H_
|
|
|
|
|
#define CSCORE_SINKIMPL_H_
|
2016-09-05 12:00:04 -07:00
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
2018-10-31 20:22:58 -07:00
|
|
|
#include <wpi/Logger.h>
|
2018-04-29 23:33:19 -07:00
|
|
|
#include <wpi/StringRef.h>
|
2018-07-29 12:53:41 -07:00
|
|
|
#include <wpi/Twine.h>
|
2018-04-29 23:33:19 -07:00
|
|
|
#include <wpi/mutex.h>
|
2016-09-05 12:00:04 -07:00
|
|
|
|
2016-09-08 23:52:23 -07:00
|
|
|
#include "SourceImpl.h"
|
|
|
|
|
|
2019-01-11 20:33:05 -08:00
|
|
|
namespace wpi {
|
|
|
|
|
class json;
|
|
|
|
|
} // namespace wpi
|
|
|
|
|
|
2016-09-05 12:00:04 -07:00
|
|
|
namespace cs {
|
|
|
|
|
|
|
|
|
|
class Frame;
|
2018-10-31 20:22:58 -07:00
|
|
|
class Notifier;
|
|
|
|
|
class Telemetry;
|
2016-09-05 12:00:04 -07:00
|
|
|
|
2018-07-27 22:12:30 -07:00
|
|
|
class SinkImpl : public PropertyContainer {
|
2016-09-05 12:00:04 -07:00
|
|
|
public:
|
2018-10-31 20:22:58 -07:00
|
|
|
explicit SinkImpl(const wpi::Twine& name, wpi::Logger& logger,
|
|
|
|
|
Notifier& notifier, Telemetry& telemetry);
|
2016-09-08 23:52:23 -07:00
|
|
|
virtual ~SinkImpl();
|
2016-09-05 12:00:04 -07:00
|
|
|
SinkImpl(const SinkImpl& queue) = delete;
|
|
|
|
|
SinkImpl& operator=(const SinkImpl& queue) = delete;
|
|
|
|
|
|
2018-04-29 23:33:19 -07:00
|
|
|
wpi::StringRef GetName() const { return m_name; }
|
2016-10-26 23:31:48 -07:00
|
|
|
|
2018-07-29 12:53:41 -07:00
|
|
|
void SetDescription(const wpi::Twine& description);
|
2018-04-29 23:33:19 -07:00
|
|
|
wpi::StringRef GetDescription(wpi::SmallVectorImpl<char>& buf) const;
|
2016-09-05 12:00:04 -07:00
|
|
|
|
2016-11-18 10:20:56 -08:00
|
|
|
void Enable();
|
|
|
|
|
void Disable();
|
|
|
|
|
void SetEnabled(bool enabled);
|
2016-10-26 23:31:48 -07:00
|
|
|
|
2016-09-08 23:52:23 -07:00
|
|
|
void SetSource(std::shared_ptr<SourceImpl> source);
|
|
|
|
|
|
2016-09-05 12:00:04 -07:00
|
|
|
std::shared_ptr<SourceImpl> GetSource() const {
|
2017-11-13 09:51:26 -08:00
|
|
|
std::lock_guard<wpi::mutex> lock(m_mutex);
|
2016-09-05 12:00:04 -07:00
|
|
|
return m_source;
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-26 23:31:48 -07:00
|
|
|
std::string GetError() const;
|
2018-04-29 23:33:19 -07:00
|
|
|
wpi::StringRef GetError(wpi::SmallVectorImpl<char>& buf) const;
|
2016-10-26 23:31:48 -07:00
|
|
|
|
2019-01-11 20:33:05 -08:00
|
|
|
bool SetConfigJson(wpi::StringRef config, CS_Status* status);
|
|
|
|
|
virtual bool SetConfigJson(const wpi::json& config, CS_Status* status);
|
|
|
|
|
std::string GetConfigJson(CS_Status* status);
|
|
|
|
|
virtual wpi::json GetConfigJsonObject(CS_Status* status);
|
|
|
|
|
|
2016-10-26 23:31:48 -07:00
|
|
|
protected:
|
2018-07-27 22:12:30 -07:00
|
|
|
// PropertyContainer implementation
|
|
|
|
|
void NotifyPropertyCreated(int propIndex, PropertyImpl& prop) override;
|
|
|
|
|
void UpdatePropertyValue(int property, bool setString, int value,
|
2018-07-29 12:53:41 -07:00
|
|
|
const wpi::Twine& valueStr) override;
|
2016-11-11 00:01:58 -08:00
|
|
|
|
2018-07-27 22:12:30 -07:00
|
|
|
virtual void SetSourceImpl(std::shared_ptr<SourceImpl> source);
|
2016-10-26 23:31:48 -07:00
|
|
|
|
2018-10-31 20:22:58 -07:00
|
|
|
protected:
|
|
|
|
|
wpi::Logger& m_logger;
|
|
|
|
|
Notifier& m_notifier;
|
|
|
|
|
Telemetry& m_telemetry;
|
|
|
|
|
|
2016-09-05 12:00:04 -07:00
|
|
|
private:
|
|
|
|
|
std::string m_name;
|
2016-10-26 23:31:48 -07:00
|
|
|
std::string m_description;
|
2016-09-05 12:00:04 -07:00
|
|
|
std::shared_ptr<SourceImpl> m_source;
|
2016-10-13 00:13:18 -07:00
|
|
|
int m_enabledCount{0};
|
2016-09-05 12:00:04 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace cs
|
|
|
|
|
|
2017-08-25 17:48:06 -07:00
|
|
|
#endif // CSCORE_SINKIMPL_H_
|