| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
#ifndef LOGICFEATURE_H |
| 21 |
#define LOGICFEATURE_H |
| 22 |
|
| 23 |
class TConcept; |
| 24 |
class TRole; |
| 25 |
class DLVertex; |
| 26 |
|
| 27 |
|
| 28 |
class LogicFeatures |
| 29 |
{ |
| 30 |
protected: |
| 31 |
enum lfEnum { |
| 32 |
lfInvalid = 0, |
| 33 |
|
| 34 |
lfTransitiveRoles = (1 << 0), |
| 35 |
lfRolesSubsumption = (1 << 1), |
| 36 |
lfDirectRoles = (1 << 2), |
| 37 |
lfInverseRoles = (1 << 3), |
| 38 |
lfRangeAndDomain = (1 << 4), |
| 39 |
lfFunctionalRoles = (1 << 5), |
| 40 |
|
| 41 |
|
| 42 |
lfSomeConstructor = (1 << 6), |
| 43 |
lfFConstructor = (1 << 7), |
| 44 |
lfNConstructor = (1 << 8), |
| 45 |
lfQConstructor = (1 << 9), |
| 46 |
lfSingleton = (1 << 10), |
| 47 |
|
| 48 |
|
| 49 |
lfGeneralAxioms = (1 << 11), |
| 50 |
lfBothRoles = (1 << 12), |
| 51 |
|
| 52 |
|
| 53 |
lfSelfRef = (1 << 13), |
| 54 |
lfTopRole = (1 << 14), |
| 55 |
}; |
| 56 |
|
| 57 |
protected: |
| 58 |
|
| 59 |
unsigned long flags = 0; |
| 60 |
|
| 61 |
protected: |
| 62 |
|
| 63 |
void setX ( lfEnum val ) { flags |= val; } |
| 64 |
|
| 65 |
bool getX ( lfEnum val ) const { return (flags & val) != 0; } |
| 66 |
|
| 67 |
public: |
| 68 |
|
| 69 |
LogicFeatures() = default; |
| 70 |
|
| 71 |
LogicFeatures(const LogicFeatures&) = default; |
| 72 |
|
| 73 |
LogicFeatures& operator = (const LogicFeatures&) = default; |
| 74 |
|
| 75 |
LogicFeatures& operator |= ( const LogicFeatures& lf ) { flags |= lf.flags; return *this; } |
| 76 |
|
| 77 |
|
| 78 |
bool hasInverseRole ( void ) const { return getX(lfBothRoles); } |
| 79 |
bool hasRoleHierarchy ( void ) const { return getX(lfRolesSubsumption); } |
| 80 |
bool hasTransitiveRole ( void ) const { return getX(lfTransitiveRoles); } |
| 81 |
bool hasSomeAll ( void ) const { return getX(lfSomeConstructor); } |
| 82 |
bool hasFunctionalRestriction ( void ) const { return getX(lfFConstructor) || getX(lfFunctionalRoles); } |
| 83 |
bool hasNumberRestriction ( void ) const { return getX(lfNConstructor); } |
| 84 |
bool hasQNumberRestriction ( void ) const { return getX(lfQConstructor); } |
| 85 |
bool hasSingletons ( void ) const { return getX(lfSingleton); } |
| 86 |
bool hasSelfRef ( void ) const { return getX(lfSelfRef); } |
| 87 |
bool hasTopRole ( void ) const { return getX(lfTopRole); } |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
bool empty ( void ) const { return flags == 0; } |
| 93 |
|
| 94 |
unsigned long getAllFlags ( void ) const { return flags; } |
| 95 |
|
| 96 |
unsigned long setAllFlags ( unsigned long value ) { unsigned long old = flags; flags = value; return old; } |
| 97 |
|
| 98 |
void clear ( void ) { setAllFlags(0); } |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
void fillConceptData ( const TConcept* p ); |
| 104 |
|
| 105 |
void fillRoleData ( const TRole* p, bool both ); |
| 106 |
|
| 107 |
void fillDAGData ( const DLVertex& v, bool pos ); |
| 108 |
|
| 109 |
|
| 110 |
void mergeRoles ( void ) |
| 111 |
{ |
| 112 |
if ( getX(lfDirectRoles) && getX(lfInverseRoles) ) |
| 113 |
setX(lfBothRoles); |
| 114 |
} |
| 115 |
|
| 116 |
void setInverseRoles ( void ) { setX(lfBothRoles); } |
| 117 |
|
| 118 |
|
| 119 |
void writeState ( void ) const; |
| 120 |
}; |
| 121 |
|
| 122 |
#endif |