knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
GraphTransformation.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_GRAPH_TRANSFORMATION_H
7 #define KNOWROB_GRAPH_TRANSFORMATION_H
8 
9 #include <functional>
10 #include <boost/property_tree/ptree.hpp>
11 #include "knowrob/semweb/TripleContainer.h"
12 #include "knowrob/semweb/OntologySource.h"
13 
14 namespace knowrob {
22  class GraphTransformation {
23  public:
24  GraphTransformation() = default;
25 
26  virtual ~GraphTransformation() = default;
27 
34  void setOrigin(std::string_view origin) { origin_ = origin; }
35 
40  auto origin() const { return origin_; }
41 
47  void apply(OntologySource &ontologySource, const TripleHandler &callback);
48 
54  virtual bool configure(const boost::property_tree::ptree &config) = 0;
55 
61  static std::shared_ptr<GraphTransformation> create(const boost::property_tree::ptree &config);
62 
63  protected:
65  std::shared_ptr<GraphTransformation> nextTransformation_;
67 
69 
70  void finalizeNext();
71 
76  void setNext(const std::shared_ptr<GraphTransformation> &next) { nextTransformation_ = next; }
77 
82  void setNext(const TripleHandler &next) { next_ = next; }
83 
88  void pushOutputTriples(const TripleContainerPtr &triples);
89 
94  virtual void pushInputTriples(const TripleContainerPtr &triples) = 0;
95 
99  virtual void initializeTransformation() = 0;
100 
104  virtual void finalizeTransformation() = 0;
105  };
106 
107 } // knowrob
108 
109 #endif //KNOWROB_GRAPH_TRANSFORMATION_H
void setNext(const TripleHandler &next)
void setNext(const std::shared_ptr< GraphTransformation > &next)
std::shared_ptr< GraphTransformation > nextTransformation_
void pushOutputTriples(const TripleContainerPtr &triples)
virtual bool configure(const boost::property_tree::ptree &config)=0
static std::shared_ptr< GraphTransformation > create(const boost::property_tree::ptree &config)
void apply(OntologySource &ontologySource, const TripleHandler &callback)
virtual void pushInputTriples(const TripleContainerPtr &triples)=0
virtual void finalizeTransformation()=0
virtual ~GraphTransformation()=default
virtual void initializeTransformation()=0
void setOrigin(std::string_view origin)
TermRule & string()
Definition: terms.cpp:63
std::shared_ptr< TripleContainer > TripleContainerPtr
std::function< void(const TripleContainerPtr &)> TripleHandler