| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#ifndef ATOMICDECOMPOSER_H |
| 21 |
#define ATOMICDECOMPOSER_H |
| 22 |
|
| 23 |
#include <ostream> |
| 24 |
|
| 25 |
#include "tOntologyAtom.h" |
| 26 |
#include "tSignature.h" |
| 27 |
#include "Modularity.h" |
| 28 |
|
| 29 |
class ProgressIndicatorInterface; |
| 30 |
|
| 31 |
|
| 32 |
class AOStructure |
| 33 |
{ |
| 34 |
public: |
| 35 |
|
| 36 |
typedef std::vector<TOntologyAtom*> AtomVec; |
| 37 |
|
| 38 |
typedef AtomVec::iterator iterator; |
| 39 |
|
| 40 |
protected: |
| 41 |
|
| 42 |
AtomVec Atoms; |
| 43 |
|
| 44 |
public: |
| 45 |
|
| 46 |
~AOStructure() |
| 47 |
{ |
| 48 |
for ( TOntologyAtom* atom : Atoms ) |
| 49 |
delete atom; |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
TOntologyAtom* newAtom ( void ) |
| 54 |
{ |
| 55 |
TOntologyAtom* ret = new TOntologyAtom(); |
| 56 |
ret->setId(Atoms.size()); |
| 57 |
Atoms.push_back(ret); |
| 58 |
return ret; |
| 59 |
} |
| 60 |
|
| 61 |
void reduceGraph ( void ) |
| 62 |
{ |
| 63 |
TOntologyAtom::AtomSet checked; |
| 64 |
for ( TOntologyAtom* atom : Atoms ) |
| 65 |
atom->getAllDepAtoms(checked); |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
iterator begin ( void ) { return Atoms.begin(); } |
| 70 |
|
| 71 |
iterator end ( void ) { return Atoms.end(); } |
| 72 |
|
| 73 |
TOntologyAtom* operator[] ( unsigned int index ) { return Atoms[index]; } |
| 74 |
|
| 75 |
const TOntologyAtom* operator[] ( unsigned int index ) const { return Atoms[index]; } |
| 76 |
|
| 77 |
size_t size ( void ) const { return Atoms.size(); } |
| 78 |
}; |
| 79 |
|
| 80 |
|
| 81 |
class AtomicDecomposer |
| 82 |
{ |
| 83 |
protected: |
| 84 |
|
| 85 |
AOStructure* AOS = nullptr; |
| 86 |
|
| 87 |
TModularizer* pModularizer = nullptr; |
| 88 |
|
| 89 |
AxiomVec Tautologies; |
| 90 |
|
| 91 |
ProgressIndicatorInterface* PI = nullptr; |
| 92 |
|
| 93 |
TOntologyAtom* rootAtom = nullptr; |
| 94 |
|
| 95 |
ModuleType type; |
| 96 |
|
| 97 |
protected: |
| 98 |
|
| 99 |
void removeTautologies ( TOntology* O ); |
| 100 |
|
| 101 |
void restoreTautologies ( void ) |
| 102 |
{ |
| 103 |
for ( TDLAxiom* axiom : Tautologies ) |
| 104 |
axiom->setUsed(true); |
| 105 |
} |
| 106 |
|
| 107 |
TOntologyAtom* buildModule ( const TSignature& sig, TOntologyAtom* parent ); |
| 108 |
|
| 109 |
TOntologyAtom* createAtom ( TDLAxiom* ax, TOntologyAtom* parent ); |
| 110 |
|
| 111 |
public: |
| 112 |
|
| 113 |
explicit AtomicDecomposer ( TModularizer* m ) : pModularizer(m) {} |
| 114 |
|
| 115 |
~AtomicDecomposer(); |
| 116 |
|
| 117 |
|
| 118 |
AOStructure* getAOS ( TOntology* O, ModuleType type ); |
| 119 |
|
| 120 |
const AOStructure* getAOS ( void ) const { return AOS; } |
| 121 |
|
| 122 |
|
| 123 |
void setProgressIndicator ( ProgressIndicatorInterface* pi ) { PI = pi; } |
| 124 |
|
| 125 |
unsigned long long getLocCheckNumber(void) const { return pModularizer->getNChecks(); } |
| 126 |
}; |
| 127 |
|
| 128 |
#endif |