#include <Class.h>
|
| Class (std::string_view iri) |
|
| Class (const IRIAtomPtr &iri) |
|
void | addDirectParent (const std::shared_ptr< Class > &directParent, std::optional< std::string_view > graph) |
|
void | removeDirectParent (const std::shared_ptr< Class > &directParent, std::optional< std::string_view > graph) |
|
const auto & | directParents () const |
|
bool | isDirectSubClassOf (const std::shared_ptr< Class > &directParent) |
|
bool | isSubClassOf (const std::shared_ptr< Class > &parent, bool includeSelf=true) |
|
void | forallParents (const ClassVisitor &visitor, bool includeSelf=true, bool skipDuplicates=true) |
|
void | forallChildren (const ClassTupleVisitor &visitor, bool skipDuplicates=true) |
|
void | detach () |
|
| Class (std::string_view iri) |
|
| Class (const IRIAtomPtr &iri) |
|
void | addDirectParent (const std::shared_ptr< Class > &directParent, std::optional< std::string_view > graph) |
|
void | removeDirectParent (const std::shared_ptr< Class > &directParent, std::optional< std::string_view > graph) |
|
const auto & | directParents () const |
|
bool | isDirectSubClassOf (const std::shared_ptr< Class > &directParent) |
|
bool | isSubClassOf (const std::shared_ptr< Class > &parent, bool includeSelf=true) |
|
void | forallParents (const ClassVisitor &visitor, bool includeSelf=true, bool skipDuplicates=true) |
|
void | forallChildren (const ClassTupleVisitor &visitor, bool skipDuplicates=true) |
|
void | detach () |
|
| Resource (std::string_view iri) |
|
| Resource (const IRIAtomPtr &iri) |
|
auto | iri () const |
|
auto | iriAtom () const |
|
std::string_view | name () const |
|
std::string_view | ns (bool includeDelimiter=false) const |
|
| Resource (std::string_view iri) |
|
| Resource (const IRIAtomPtr &iri) |
|
auto | iri () const |
|
auto | iriAtom () const |
|
std::string_view | name () const |
|
std::string_view | ns (bool includeDelimiter=false) const |
|
A RDF class.
Definition at line 26 of file Class.h.
◆ Class() [1/4]
Class::Class |
( |
std::string_view |
iri | ) |
|
|
explicit |
- Parameters
-
Definition at line 15 of file Class.cpp.
Resource(std::string_view iri)
◆ Class() [2/4]
◆ Class() [3/4]
knowrob::semweb::Class::Class |
( |
std::string_view |
iri | ) |
|
|
explicit |
◆ Class() [4/4]
knowrob::semweb::Class::Class |
( |
const IRIAtomPtr & |
iri | ) |
|
|
explicit |
◆ addDirectParent() [1/2]
void Class::addDirectParent |
( |
const std::shared_ptr< Class > & |
directParent, |
|
|
std::optional< std::string_view > |
graph |
|
) |
| |
- Parameters
-
directParent | a direct super class. |
graph | the graph where the relation is defined. |
Definition at line 25 of file Class.cpp.
30 pair->second.insert(graphAtom);
34 directParent->directChildren_.insert(shared_from_this());
std::map< std::shared_ptr< Class >, std::set< AtomPtr, AtomComparator >, ClassComparator > directParents_
static AtomPtr graph_atom(std::optional< std::string_view > graph)
◆ addDirectParent() [2/2]
void knowrob::semweb::Class::addDirectParent |
( |
const std::shared_ptr< Class > & |
directParent, |
|
|
std::optional< std::string_view > |
graph |
|
) |
| |
- Parameters
-
directParent | a direct super class. |
graph | the graph where the relation is defined. |
◆ detach() [1/2]
Detach this class from its children and parents.
Definition at line 138 of file Class.cpp.
std::set< std::shared_ptr< Class >, ClassComparator > directChildren_
◆ detach() [2/2]
void knowrob::semweb::Class::detach |
( |
| ) |
|
Detach this class from its children and parents.
◆ directParents() [1/2]
const auto& knowrob::semweb::Class::directParents |
( |
| ) |
const |
|
inline |
- Returns
- all direct super classes of this class.
Definition at line 53 of file Class.h.
◆ directParents() [2/2]
const auto& knowrob::semweb::Class::directParents |
( |
| ) |
const |
|
inline |
- Returns
- all direct super classes of this class.
Definition at line 53 of file Class.h.
◆ forallChildren() [1/2]
void Class::forallChildren |
( |
const ClassTupleVisitor & |
visitor, |
|
|
bool |
skipDuplicates = true |
|
) |
| |
- Parameters
-
visitor | a function that is called for each child in the class hierarchy. |
skipDuplicates | if true, the method calls the visitor only once for each class. |
Definition at line 113 of file Class.cpp.
114 std::queue<std::pair<Class *, Class *>> queue_;
115 std::set<std::string_view> visited_;
121 while (!queue_.empty()) {
122 auto pair = queue_.front();
123 auto front_child = pair.first;
124 auto front_parent = pair.second;
127 visitor(*front_child, *front_parent);
129 if (skipDuplicates) visited_.insert(front_child->iri());
131 for (
auto &directChild: front_child->directChildren_) {
132 if (skipDuplicates && visited_.count(directChild->iri()) > 0)
continue;
133 queue_.emplace(directChild.get(), front_child);
◆ forallChildren() [2/2]
void knowrob::semweb::Class::forallChildren |
( |
const ClassTupleVisitor & |
visitor, |
|
|
bool |
skipDuplicates = true |
|
) |
| |
- Parameters
-
visitor | a function that is called for each child in the class hierarchy. |
skipDuplicates | if true, the method calls the visitor only once for each class. |
◆ forallParents() [1/2]
void Class::forallParents |
( |
const ClassVisitor & |
visitor, |
|
|
bool |
includeSelf = true , |
|
|
bool |
skipDuplicates = true |
|
) |
| |
- Parameters
-
visitor | a function that is called for each parent in the class hierarchy. |
includeSelf | if true, the method calls the visitor for this class. |
skipDuplicates | if true, the method calls the visitor only once for each class. |
Definition at line 87 of file Class.cpp.
90 std::queue<Class *> queue_;
91 std::set<std::string_view> visited_;
94 if (includeSelf) queue_.push(
this);
98 while (!queue_.empty()) {
99 auto front = queue_.front();
104 if (skipDuplicates) visited_.insert(front->iri());
106 for (
auto &directParent: front->directParents_) {
107 if (skipDuplicates && visited_.count(directParent.first->iri()) > 0)
continue;
108 queue_.push(directParent.first.get());
◆ forallParents() [2/2]
void knowrob::semweb::Class::forallParents |
( |
const ClassVisitor & |
visitor, |
|
|
bool |
includeSelf = true , |
|
|
bool |
skipDuplicates = true |
|
) |
| |
- Parameters
-
visitor | a function that is called for each parent in the class hierarchy. |
includeSelf | if true, the method calls the visitor for this class. |
skipDuplicates | if true, the method calls the visitor only once for each class. |
◆ isDirectSubClassOf() [1/2]
bool Class::isDirectSubClassOf |
( |
const std::shared_ptr< Class > & |
directParent | ) |
|
- Parameters
-
directParent | a direct super class. |
- Returns
- true if directParent is a direct super class of this class.
Definition at line 57 of file Class.cpp.
◆ isDirectSubClassOf() [2/2]
bool knowrob::semweb::Class::isDirectSubClassOf |
( |
const std::shared_ptr< Class > & |
directParent | ) |
|
- Parameters
-
directParent | a direct super class. |
- Returns
- true if directParent is a direct super class of this class.
◆ isSubClassOf() [1/2]
bool Class::isSubClassOf |
( |
const std::shared_ptr< Class > & |
parent, |
|
|
bool |
includeSelf = true |
|
) |
| |
- Parameters
-
parent | a super class. |
includeSelf | if true, the method returns true if this class is the same |
- Returns
- true if this class is a sub class of parent.
Definition at line 61 of file Class.cpp.
62 std::queue<Class *> queue_;
63 std::set<std::string_view> visited_;
65 if (includeSelf &&
this == parent.get())
return true;
69 while (!queue_.empty()) {
70 auto front = queue_.front();
74 if (front->directParents_.count(parent) > 0)
return true;
76 visited_.insert(front->iri());
78 for (
auto &directParent: front->directParents_) {
79 if (visited_.count(directParent.first->iri()) > 0)
continue;
80 queue_.push(directParent.first.get());
◆ isSubClassOf() [2/2]
bool knowrob::semweb::Class::isSubClassOf |
( |
const std::shared_ptr< Class > & |
parent, |
|
|
bool |
includeSelf = true |
|
) |
| |
- Parameters
-
parent | a super class. |
includeSelf | if true, the method returns true if this class is the same |
- Returns
- true if this class is a sub class of parent.
◆ removeDirectParent() [1/2]
void Class::removeDirectParent |
( |
const std::shared_ptr< Class > & |
directParent, |
|
|
std::optional< std::string_view > |
graph |
|
) |
| |
- Parameters
-
directParent | a direct super class. |
graph | the graph where the relation is defined. |
Definition at line 38 of file Class.cpp.
43 for (
auto it = pair->second.begin(); it != pair->second.end(); it++) {
44 if ((*it)->stringForm() == v_graph) {
45 pair->second.erase(it);
50 if (pair->second.empty()) {
52 directParent->directChildren_.erase(shared_from_this());
static constexpr std::string_view ORIGIN_SESSION
◆ removeDirectParent() [2/2]
void knowrob::semweb::Class::removeDirectParent |
( |
const std::shared_ptr< Class > & |
directParent, |
|
|
std::optional< std::string_view > |
graph |
|
) |
| |
- Parameters
-
directParent | a direct super class. |
graph | the graph where the relation is defined. |
◆ directChildren_
◆ directParents_
The documentation for this class was generated from the following files:
- build/_CPack_Packages/Linux/DEB/knowrob-2.1.0-Linux/usr/include/knowrob/semweb/Class.h
- src/semweb/Class.cpp