knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
ConjunctiveBroadcaster.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_ANSWER_COMBINER_H_
7 #define KNOWROB_ANSWER_COMBINER_H_
8 
9 #include <mutex>
10 #include "TokenBroadcaster.h"
11 #include "Answer.h"
12 #include "AnswerNo.h"
13 
14 namespace knowrob {
19  class ConjunctiveBroadcaster : public TokenBroadcaster {
20  public:
21  explicit ConjunctiveBroadcaster(bool ignoreInconsistentAnswers = true);
22 
23  protected:
24  // maps channel id to a set of answers in the buffer.
25  // a container is used for the answers that removes duplicates.
26  using AnswerMap = std::map<uint32_t, std::map<size_t, AnswerPtr>>;
27 
29  std::mutex buffer_mutex_;
31  bool hasSolution_;
32  std::vector<AnswerNoPtr> negativeAnswers_;
33 
34  // Override TokenBroadcaster
35  void push(Channel &channel, const TokenPtr &tok) override;
36 
37  void genCombinations(uint32_t pushedChannelID, AnswerMap::iterator it, AnswerPtr &combinedResult);
38  };
39 }
40 
41 #endif //KNOWROB_ANSWER_COMBINER_H_
ConjunctiveBroadcaster(bool ignoreInconsistentAnswers=true)
void genCombinations(uint32_t pushedChannelID, AnswerMap::iterator it, AnswerPtr &combinedResult)
void push(Channel &channel, const TokenPtr &tok) override
std::map< uint32_t, std::map< size_t, AnswerPtr > > AnswerMap
std::vector< AnswerNoPtr > negativeAnswers_
std::shared_ptr< const Token > TokenPtr
Definition: Token.h:74
std::shared_ptr< const Answer > AnswerPtr
Definition: Answer.h:129