owlcpp  v0.3.3~
C++ library for working with OWL ontologies
 All Classes Namespaces Files Functions Macros Pages
predicate_fact.hpp
Go to the documentation of this file.
1 
6 #ifndef PREDICATE_FACT_HPP_
7 #define PREDICATE_FACT_HPP_
8 #include <string>
9 #include <cstring>
11 #include "factpp/Kernel.hpp"
13 
14 namespace owlcpp{
15 class Triple_store;
16 
19 struct Select_all : public CE_predicate {
20  bool operator()(const ClassifiableEntry*) const {return true;}
21 };
22 
25 template<bool Instance> struct Is_instance : public CE_predicate {
26  bool operator()(const ClassifiableEntry* ce) const {
27  const TConcept* c = reinterpret_cast<const TConcept*>(ce);
28  return Instance == c->isSingleton();
29  }
30 };
31 
34 template<bool super> class Super_sub : public CE_predicate {
35 public:
36  Super_sub(const TDLConceptExpression* ce, ReasoningKernel& kernel)
37  : ce_(ce), kernel_(kernel) {}
38 
39  bool operator()(const ClassifiableEntry* ce) const {
40  TExpressionManager& em = *kernel_.getExpressionManager();
41  const TDLConceptExpression* c = em.Concept(ce->getName());
42  return super ?
43  kernel_.isSubsumedBy(ce_, c) :
44  kernel_.isSubsumedBy(c, ce_);
45 // return super ?
46 // detail::is_subsumed_by(ce_, detail::get_ce(ce, kernel_), kernel_) :
47 // detail::is_subsumed_by(detail::get_ce(ce, kernel_), ce_, kernel_);
48  }
49 
50 private:
51  const TDLConceptExpression* ce_;
52  ReasoningKernel& kernel_;
53 };
54 
57 class Equivalent : public CE_predicate {
58 public:
59  Equivalent(const TDLConceptExpression* ce, ReasoningKernel& kernel)
60  : ce_(ce), kernel_(kernel) {}
61 
62  bool operator()(const ClassifiableEntry* ce) const {
63  TExpressionManager& em = *kernel_.getExpressionManager();
64  const TDLConceptExpression* c = em.Concept(ce->getName());
65  return kernel_.isEquivalent(c, ce_);
66  }
67 
68 private:
69  const TDLConceptExpression* ce_;
70  ReasoningKernel& kernel_;
71 };
72 
73 
76 template<bool IS> class Is_name : public CE_predicate {
77 public:
78  Is_name(const std::string& name) : name_(name) {}
79 
80  bool operator() (const ClassifiableEntry* ce) const {
81  return IS == (name_ == ce->getName());
82  }
83 private:
84  const std::string name_;
85 };
86 
89 template<bool IS> class Begins_with : public CE_predicate {
90 public:
91  Begins_with(const std::string& str) : str_(str) {}
92 
93  bool operator() (const ClassifiableEntry* ce) const {
94  const std::string sname(ce->getName());
95  const bool bw =
96  ( sname.size() >= str_.size() ) &&
97  ( sname.compare(0, str_.size(), str_) == 0 );
98  return IS == bw;
99  }
100 private:
101  const std::string str_;
102 };
103 
107 class Can_relate : public C_predicate {
108  Can_relate();
109  Can_relate(const Can_relate&);
110 public:
111  Can_relate(
112  const TDLObjectRoleExpression* property,
113  const TDLConceptExpression* c,
114  ReasoningKernel& kernel
115  );
116 
117  Can_relate(
118  const std::string& property,
119  const std::string& c,
120  const Triple_store& store,
121  ReasoningKernel& kernel
122  );
123 
125  bool operator()(const TDLConceptExpression* x) const {
126  return ! kernel_.isDisjoint(restriction_, x);
127  }
128 
129  ~Can_relate() {}
130 private:
131  ReasoningKernel& kernel_;
132  const TDLConceptExpression* restriction_;
133 };
134 
135 }//namespace owlcpp
136 
137 #endif /* PREDICATE_FACT_HPP_ */