WPILibC++  unspecified
SinkImpl.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2016-2017 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #ifndef CSCORE_SINKIMPL_H_
9 #define CSCORE_SINKIMPL_H_
10 
11 #include <memory>
12 #include <mutex>
13 #include <string>
14 
15 #include <llvm/StringRef.h>
16 
17 #include "SourceImpl.h"
18 
19 namespace cs {
20 
21 class Frame;
22 
23 class SinkImpl {
24  public:
25  explicit SinkImpl(llvm::StringRef name);
26  virtual ~SinkImpl();
27  SinkImpl(const SinkImpl& queue) = delete;
28  SinkImpl& operator=(const SinkImpl& queue) = delete;
29 
30  llvm::StringRef GetName() const { return m_name; }
31 
32  void SetDescription(llvm::StringRef description);
33  llvm::StringRef GetDescription(llvm::SmallVectorImpl<char>& buf) const;
34 
35  void Enable();
36  void Disable();
37  void SetEnabled(bool enabled);
38 
39  void SetSource(std::shared_ptr<SourceImpl> source);
40 
41  std::shared_ptr<SourceImpl> GetSource() const {
42  std::lock_guard<std::mutex> lock(m_mutex);
43  return m_source;
44  }
45 
46  std::string GetError() const;
47  llvm::StringRef GetError(llvm::SmallVectorImpl<char>& buf) const;
48 
49  protected:
50  virtual void SetSourceImpl(std::shared_ptr<SourceImpl> source);
51 
52  mutable std::mutex m_mutex;
53 
54  private:
55  std::string m_name;
56  std::string m_description;
57  std::shared_ptr<SourceImpl> m_source;
58  int m_enabledCount{0};
59 };
60 
61 } // namespace cs
62 
63 #endif // CSCORE_SINKIMPL_H_
Definition: SinkImpl.h:19
Definition: SinkImpl.h:23
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:42