knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
knowrob::AnswerMerger Class Reference

#include <AnswerMerger.h>

Inheritance diagram for knowrob::AnswerMerger:
Collaboration diagram for knowrob::AnswerMerger:

Public Member Functions

 AnswerMerger (AnswerPtr partialResult)
 
TokenPtr transform (const TokenPtr &tok) override
 
 AnswerMerger (AnswerPtr partialResult)
 
TokenPtr transform (const TokenPtr &tok) override
 
- Public Member Functions inherited from knowrob::AnswerTransformer
 AnswerTransformer ()
 
 AnswerTransformer ()
 
- Public Member Functions inherited from knowrob::TokenBroadcaster
 TokenBroadcaster ()
 
 ~TokenBroadcaster () override
 
void addSubscriber (const std::shared_ptr< Channel > &subscriber)
 
void removeSubscriber (const std::shared_ptr< Channel > &subscriber)
 
 TokenBroadcaster ()
 
 ~TokenBroadcaster () override
 
void addSubscriber (const std::shared_ptr< Channel > &subscriber)
 
void removeSubscriber (const std::shared_ptr< Channel > &subscriber)
 
- Public Member Functions inherited from knowrob::TokenStream
 TokenStream ()
 
virtual ~TokenStream ()
 
 TokenStream (const TokenStream &)=delete
 
virtual void close ()
 
bool isOpened () const
 
 TokenStream ()
 
virtual ~TokenStream ()
 
 TokenStream (const TokenStream &)=delete
 
virtual void close ()
 
bool isOpened () const
 

Protected Attributes

const AnswerPtr partialResult_
 
- Protected Attributes inherited from knowrob::TokenBroadcaster
std::list< std::shared_ptr< Channel > > subscribers_
 
std::mutex mtx_
 
- Protected Attributes inherited from knowrob::TokenStream
std::list< std::shared_ptr< Channel > > channels_
 
std::atomic< bool > isOpened_
 
std::mutex channel_mutex_
 

Additional Inherited Members

- Protected Member Functions inherited from knowrob::AnswerTransformer
void push (const TokenPtr &tok) override
 
void push (const TokenPtr &tok) override
 
- Protected Member Functions inherited from knowrob::TokenBroadcaster
virtual void pushToBroadcast (const TokenPtr &tok)
 
void push (const TokenPtr &tok) override
 
virtual void pushToBroadcast (const TokenPtr &tok)
 
- Protected Member Functions inherited from knowrob::TokenStream
virtual void push (Channel &channel, const TokenPtr &tok)
 
virtual void push (Channel &channel, const TokenPtr &tok)
 

Detailed Description

A transformer that merges two partial answers.

Definition at line 16 of file AnswerMerger.h.

Constructor & Destructor Documentation

◆ AnswerMerger() [1/2]

AnswerMerger::AnswerMerger ( AnswerPtr  partialResult)
explicit

Definition at line 12 of file AnswerMerger.cpp.

14  partialResult_(std::move(partialResult)) {}
const AnswerPtr partialResult_
Definition: AnswerMerger.h:24

◆ AnswerMerger() [2/2]

knowrob::AnswerMerger::AnswerMerger ( AnswerPtr  partialResult)
explicit

Member Function Documentation

◆ transform() [1/2]

TokenPtr AnswerMerger::transform ( const TokenPtr tok)
overridevirtual

Transform a token.

Parameters
tokthe token to transform.
Returns
the transformed token.

Implements knowrob::AnswerTransformer.

Definition at line 16 of file AnswerMerger.cpp.

16  {
17  if (tok->tokenType() == TokenType::ANSWER_TOKEN) {
18  auto answer = std::static_pointer_cast<const Answer>(tok);
19  return mergeAnswers(partialResult_, answer, true);
20  } else {
21  return tok;
22  }
23 }
AnswerPtr mergeAnswers(const AnswerPtr &a, const AnswerPtr &b, bool ignoreInconsistencies)
Definition: Answer.cpp:112

◆ transform() [2/2]

TokenPtr knowrob::AnswerMerger::transform ( const TokenPtr tok)
overridevirtual

Transform a token.

Parameters
tokthe token to transform.
Returns
the transformed token.

Implements knowrob::AnswerTransformer.

Member Data Documentation

◆ partialResult_

const AnswerPtr knowrob::AnswerMerger::partialResult_
protected

Definition at line 24 of file AnswerMerger.h.


The documentation for this class was generated from the following files: