knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
TokenBuffer.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_BUFFER_H
7 #define KNOWROB_TOKEN_BUFFER_H
8 
9 #include "TokenBroadcaster.h"
10 #include "TokenQueue.h"
11 
12 namespace knowrob {
19  class TokenBuffer : public TokenBroadcaster {
20  public:
22 
26  void stopBuffering();
27 
32  std::shared_ptr<TokenQueue> createQueue();
33 
34  protected:
35  std::mutex bufferMutex_;
36  std::atomic<bool> isBuffering_;
37  std::list<TokenPtr> buffer_;
38 
39  // Override QueryResultStream
40  void push(const TokenPtr &tok) override;
41  };
42 
43  using TokenBufferPtr = std::shared_ptr<TokenBuffer>;
44 
45 } // knowrob
46 
47 #endif //KNOWROB_TOKEN_BUFFER_H
std::mutex bufferMutex_
Definition: TokenBuffer.h:35
void push(const TokenPtr &tok) override
std::list< TokenPtr > buffer_
Definition: TokenBuffer.h:37
std::atomic< bool > isBuffering_
Definition: TokenBuffer.h:36
std::shared_ptr< TokenQueue > createQueue()
std::shared_ptr< const Token > TokenPtr
Definition: Token.h:74
std::shared_ptr< TokenBuffer > TokenBufferPtr
Definition: TokenBuffer.h:43