| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#ifndef TONTOLOGYATOM_H |
| 21 |
#define TONTOLOGYATOM_H |
| 22 |
|
| 23 |
#include <set> |
| 24 |
|
| 25 |
#include "globaldef.h" |
| 26 |
#include "tDLAxiom.h" |
| 27 |
|
| 28 |
|
| 29 |
class TOntologyAtom |
| 30 |
{ |
| 31 |
protected: |
| 32 |
|
| 33 |
struct AtomLess |
| 34 |
{ |
| 35 |
bool operator()(const TOntologyAtom* a1, const TOntologyAtom* a2) const |
| 36 |
{ return a1->getId() < a2->getId(); } |
| 37 |
}; |
| 38 |
|
| 39 |
public: |
| 40 |
|
| 41 |
typedef AxiomVec AxiomSet; |
| 42 |
|
| 43 |
typedef std::set<TOntologyAtom*, AtomLess> AtomSet; |
| 44 |
|
| 45 |
protected: |
| 46 |
|
| 47 |
AxiomSet AtomAxioms; |
| 48 |
|
| 49 |
AxiomSet ModuleAxioms; |
| 50 |
|
| 51 |
AtomSet DepAtoms; |
| 52 |
|
| 53 |
AtomSet AllDepAtoms; |
| 54 |
|
| 55 |
size_t Id = 0; |
| 56 |
|
| 57 |
protected: |
| 58 |
|
| 59 |
void filterDep ( void ) |
| 60 |
{ |
| 61 |
for ( TOntologyAtom* atom : AllDepAtoms ) |
| 62 |
DepAtoms.erase(atom); |
| 63 |
} |
| 64 |
|
| 65 |
void buildAllDepAtoms ( AtomSet& checked ) |
| 66 |
{ |
| 67 |
|
| 68 |
for ( TOntologyAtom* atom : DepAtoms ) |
| 69 |
{ |
| 70 |
const AtomSet& Dep = atom->getAllDepAtoms(checked); |
| 71 |
AllDepAtoms.insert ( Dep.begin(), Dep.end() ); |
| 72 |
} |
| 73 |
|
| 74 |
filterDep(); |
| 75 |
|
| 76 |
AllDepAtoms.insert ( DepAtoms.begin(), DepAtoms.end() ); |
| 77 |
|
| 78 |
checked.insert(this); |
| 79 |
} |
| 80 |
|
| 81 |
public: |
| 82 |
|
| 83 |
void setModule ( const AxiomSet& module ) { ModuleAxioms = module; } |
| 84 |
|
| 85 |
void addAxiom ( TDLAxiom* ax ) |
| 86 |
{ |
| 87 |
AtomAxioms.push_back(ax); |
| 88 |
ax->setAtom(this); |
| 89 |
} |
| 90 |
|
| 91 |
void addDepAtom ( TOntologyAtom* atom ) |
| 92 |
{ |
| 93 |
if ( likely(atom != nullptr) && atom != this ) |
| 94 |
DepAtoms.insert(atom); |
| 95 |
} |
| 96 |
|
| 97 |
const AtomSet& getAllDepAtoms ( AtomSet& checked ) |
| 98 |
{ |
| 99 |
if ( checked.count(this) == 0 ) |
| 100 |
buildAllDepAtoms(checked); |
| 101 |
return AllDepAtoms; |
| 102 |
} |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
const AxiomSet& getAtomAxioms ( void ) const { return AtomAxioms; } |
| 108 |
|
| 109 |
const AxiomSet& getModule ( void ) const { return ModuleAxioms; } |
| 110 |
|
| 111 |
const AtomSet& getDepAtoms ( void ) const { return DepAtoms; } |
| 112 |
|
| 113 |
|
| 114 |
size_t getId() const { return Id; } |
| 115 |
|
| 116 |
void setId ( size_t id ) { Id = id; } |
| 117 |
}; |
| 118 |
|
| 119 |
#endif |