knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
TokenBroadcaster.h
Go to the documentation of this file.
1 /*
2  * This file is part of KnowRob, please consult
3  * https://github.com/knowrob/knowrob for license details.
4  */
5 
6 #ifndef KNOWROB_TOKEN_BROADCASTER_H_
7 #define KNOWROB_TOKEN_BROADCASTER_H_
8 
9 #include <memory>
10 #include <list>
11 #include <knowrob/queries/TokenStream.h>
12 
13 namespace knowrob {
17  class TokenBroadcaster : public TokenStream {
18  public:
20 
21  ~TokenBroadcaster() override;
22 
28  void addSubscriber(const std::shared_ptr<Channel> &subscriber);
29 
34  void removeSubscriber(const std::shared_ptr<Channel> &subscriber);
35 
36  protected:
37  std::list<std::shared_ptr<Channel>> subscribers_;
38  std::mutex mtx_;
39 
40  // Override QueryResultStream
41  void push(const TokenPtr &tok) override;
42 
43  virtual void pushToBroadcast(const TokenPtr &tok);
44  };
45 
46  void operator>>(const std::shared_ptr<TokenBroadcaster> &a,
47  const std::shared_ptr<TokenStream> &b);
48 }
49 
50 #endif //KNOWROB_TOKEN_BROADCASTER_H_
void removeSubscriber(const std::shared_ptr< Channel > &subscriber)
std::list< std::shared_ptr< Channel > > subscribers_
void addSubscriber(const std::shared_ptr< Channel > &subscriber)
void push(const TokenPtr &tok) override
virtual void pushToBroadcast(const TokenPtr &tok)
std::shared_ptr< const Token > TokenPtr
Definition: Token.h:74
void operator>>(const std::shared_ptr< TokenBroadcaster > &a, const std::shared_ptr< TokenStream > &b)