knowrob  2.1.0
A Knowledge Base System for Cognition-enabled Robots
knowrob::PrologTests< ReasonerType, BackendType > Class Template Reference

#include <PrologTests.h>

Inheritance diagram for knowrob::PrologTests< ReasonerType, BackendType >:
Collaboration diagram for knowrob::PrologTests< ReasonerType, BackendType >:

Static Protected Member Functions

static std::shared_ptr< BackendType > createBackend (const std::string &name, const std::shared_ptr< KnowledgeBase > &kb)
 
static std::shared_ptr< ReasonerType > createReasoner (const std::string &name, const std::shared_ptr< KnowledgeBase > &kb, const std::shared_ptr< BackendType > &db)
 
static void SetUpTestSuite ()
 
static void TearDownTestSuite ()
 
static void runTests (const std::string &t)
 
static std::shared_ptr< ReasonerType > reasoner ()
 
static std::shared_ptr< BackendType > createBackend (const std::string &name, const std::shared_ptr< KnowledgeBase > &kb)
 
static std::shared_ptr< ReasonerType > createReasoner (const std::string &name, const std::shared_ptr< KnowledgeBase > &kb, const std::shared_ptr< BackendType > &db)
 
static void SetUpTestSuite ()
 
static void TearDownTestSuite ()
 
static void runTests (const std::string &t)
 
static std::shared_ptr< ReasonerType > reasoner ()
 
- Static Protected Member Functions inherited from knowrob::PrologTestsBase
static void runPrologTests (const std::shared_ptr< knowrob::PrologReasoner > &reasoner, const std::string &target)
 
static void runPrologTests (const std::shared_ptr< knowrob::PrologReasoner > &reasoner, const std::string &target)
 

Static Protected Attributes

static std::shared_ptr< ReasonerType > reasoner_
 
static std::shared_ptr< KnowledgeBasekb_
 
static std::shared_ptr< BackendType > db_
 

Detailed Description

template<class ReasonerType, class BackendType>
class knowrob::PrologTests< ReasonerType, BackendType >

Definition at line 28 of file PrologTests.h.

Member Function Documentation

◆ createBackend() [1/2]

template<class ReasonerType , class BackendType >
static std::shared_ptr<BackendType> knowrob::PrologTests< ReasonerType, BackendType >::createBackend ( const std::string &  name,
const std::shared_ptr< KnowledgeBase > &  kb 
)
inlinestaticprotected

Definition at line 34 of file PrologTests.h.

34  {
35  auto db = std::make_shared<BackendType>();
36  kb->backendManager()->addPlugin(name, PluginLanguage::CPP, db);
37  db->initializeBackend(knowrob::PropertyTree());
38  return db;
39  }

◆ createBackend() [2/2]

template<class ReasonerType , class BackendType >
static std::shared_ptr<BackendType> knowrob::PrologTests< ReasonerType, BackendType >::createBackend ( const std::string &  name,
const std::shared_ptr< KnowledgeBase > &  kb 
)
inlinestaticprotected

Definition at line 34 of file PrologTests.h.

34  {
35  auto db = std::make_shared<BackendType>();
36  kb->backendManager()->addPlugin(name, PluginLanguage::CPP, db);
37  db->initializeBackend(knowrob::PropertyTree());
38  return db;
39  }

◆ createReasoner() [1/2]

template<class ReasonerType , class BackendType >
static std::shared_ptr<ReasonerType> knowrob::PrologTests< ReasonerType, BackendType >::createReasoner ( const std::string &  name,
const std::shared_ptr< KnowledgeBase > &  kb,
const std::shared_ptr< BackendType > &  db 
)
inlinestaticprotected

Definition at line 41 of file PrologTests.h.

41  {
42  auto r = std::make_shared<ReasonerType>();
43  kb->reasonerManager()->addPlugin(name, PluginLanguage::CPP, r);
44  r->setStorage(db);
45  r->initializeReasoner(knowrob::PropertyTree());
46  return r;
47  }

◆ createReasoner() [2/2]

template<class ReasonerType , class BackendType >
static std::shared_ptr<ReasonerType> knowrob::PrologTests< ReasonerType, BackendType >::createReasoner ( const std::string &  name,
const std::shared_ptr< KnowledgeBase > &  kb,
const std::shared_ptr< BackendType > &  db 
)
inlinestaticprotected

Definition at line 41 of file PrologTests.h.

41  {
42  auto r = std::make_shared<ReasonerType>();
43  kb->reasonerManager()->addPlugin(name, PluginLanguage::CPP, r);
44  r->setStorage(db);
45  r->initializeReasoner(knowrob::PropertyTree());
46  return r;
47  }

◆ reasoner() [1/2]

template<class ReasonerType , class BackendType >
static std::shared_ptr<ReasonerType> knowrob::PrologTests< ReasonerType, BackendType >::reasoner ( )
inlinestaticprotected

Definition at line 74 of file PrologTests.h.

74  {
75  if(!reasoner_) {
76  std::stringstream ss;
77  ss << "prolog_";
78  insertUnique(ss);
79 
81  db_ = createBackend(ss.str(), kb_);
82  reasoner_ = createReasoner(ss.str(), kb_, db_);
83 
84  kb_->loadCommon();
85  kb_->init();
86  }
87  return reasoner_;
88  }
static std::shared_ptr< KnowledgeBase > create()
static std::shared_ptr< BackendType > db_
Definition: PrologTests.h:32
static std::shared_ptr< BackendType > createBackend(const std::string &name, const std::shared_ptr< KnowledgeBase > &kb)
Definition: PrologTests.h:34
static std::shared_ptr< ReasonerType > reasoner_
Definition: PrologTests.h:30
static std::shared_ptr< KnowledgeBase > kb_
Definition: PrologTests.h:31
static std::shared_ptr< ReasonerType > createReasoner(const std::string &name, const std::shared_ptr< KnowledgeBase > &kb, const std::shared_ptr< BackendType > &db)
Definition: PrologTests.h:41
void insertUnique(std::ostream &os)
Definition: knowrob.cpp:44

◆ reasoner() [2/2]

template<class ReasonerType , class BackendType >
static std::shared_ptr<ReasonerType> knowrob::PrologTests< ReasonerType, BackendType >::reasoner ( )
inlinestaticprotected

Definition at line 74 of file PrologTests.h.

74  {
75  if(!reasoner_) {
76  std::stringstream ss;
77  ss << "prolog_";
78  insertUnique(ss);
79 
81  db_ = createBackend(ss.str(), kb_);
82  reasoner_ = createReasoner(ss.str(), kb_, db_);
83 
84  kb_->loadCommon();
85  kb_->init();
86  }
87  return reasoner_;
88  }

◆ runTests() [1/2]

template<class ReasonerType , class BackendType >
static void knowrob::PrologTests< ReasonerType, BackendType >::runTests ( const std::string &  t)
inlinestaticprotected

Definition at line 66 of file PrologTests.h.

66  {
67  try {
69  } catch (std::exception &e) {
70  FAIL() << "runTests failed: " << e.what();
71  }
72  }
static void runPrologTests(const std::shared_ptr< knowrob::PrologReasoner > &reasoner, const std::string &target)
Definition: PrologTests.cpp:23
static std::shared_ptr< ReasonerType > reasoner()
Definition: PrologTests.h:74

◆ runTests() [2/2]

template<class ReasonerType , class BackendType >
static void knowrob::PrologTests< ReasonerType, BackendType >::runTests ( const std::string &  t)
inlinestaticprotected

Definition at line 66 of file PrologTests.h.

66  {
67  try {
69  } catch (std::exception &e) {
70  FAIL() << "runTests failed: " << e.what();
71  }
72  }

◆ SetUpTestSuite() [1/2]

template<class ReasonerType , class BackendType >
static void knowrob::PrologTests< ReasonerType, BackendType >::SetUpTestSuite ( )
inlinestaticprotected

Definition at line 50 of file PrologTests.h.

50  {
51  // Initialize the reasoner
52  try {
53  reasoner();
54  } catch (std::exception &e) {
55  FAIL() << "SetUpTestSuite failed: " << e.what();
56  }
57  }

◆ SetUpTestSuite() [2/2]

template<class ReasonerType , class BackendType >
static void knowrob::PrologTests< ReasonerType, BackendType >::SetUpTestSuite ( )
inlinestaticprotected

Definition at line 50 of file PrologTests.h.

50  {
51  // Initialize the reasoner
52  try {
53  reasoner();
54  } catch (std::exception &e) {
55  FAIL() << "SetUpTestSuite failed: " << e.what();
56  }
57  }

◆ TearDownTestSuite() [1/2]

template<class ReasonerType , class BackendType >
static void knowrob::PrologTests< ReasonerType, BackendType >::TearDownTestSuite ( )
inlinestaticprotected

Definition at line 60 of file PrologTests.h.

60  {
61  kb_ = nullptr;
62  db_ = nullptr;
63  reasoner_ = nullptr;
64  }

◆ TearDownTestSuite() [2/2]

template<class ReasonerType , class BackendType >
static void knowrob::PrologTests< ReasonerType, BackendType >::TearDownTestSuite ( )
inlinestaticprotected

Definition at line 60 of file PrologTests.h.

60  {
61  kb_ = nullptr;
62  db_ = nullptr;
63  reasoner_ = nullptr;
64  }

Member Data Documentation

◆ db_

template<class ReasonerType , class BackendType >
std::shared_ptr< BackendType > knowrob::PrologTests< ReasonerType, BackendType >::db_
staticprotected

Definition at line 32 of file PrologTests.h.

◆ kb_

template<class ReasonerType , class BackendType >
std::shared_ptr< KnowledgeBase > knowrob::PrologTests< ReasonerType, BackendType >::kb_
staticprotected

Definition at line 31 of file PrologTests.h.

◆ reasoner_

template<class ReasonerType , class BackendType >
std::shared_ptr< ReasonerType > knowrob::PrologTests< ReasonerType, BackendType >::reasoner_
staticprotected

Definition at line 30 of file PrologTests.h.


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