| 1 | /* This file is part of the FaCT++ DL reasoner |
| 2 | Copyright (C) 2003-2015 Dmitry Tsarkov and The University of Manchester |
| 3 | Copyright (C) 2015-2017 Dmitry Tsarkov |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Lesser General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2.1 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Lesser General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Lesser General Public |
| 16 | License along with this library; if not, write to the Free Software |
| 17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #ifndef LOGICFEATURE_H |
| 21 | #define LOGICFEATURE_Hcxx . . $ `Kernel/LogicFeature.h:21:9`! |
| 22 | |
| 23 | class TConceptcxx . . $ TConcept#; |
| 24 | class TRolecxx . . $ TRole#; |
| 25 | class DLVertexcxx . . $ DLVertex#; |
| 26 | |
| 27 | // contains class for currently used logic's features |
| 28 | class LogicFeaturescxx . . $ LogicFeatures# |
| 29 | { |
| 30 | protected: // types |
| 31 | enum lfEnumcxx . . $ LogicFeatures#lfEnum# { |
| 32 | lfInvalidcxx . . $ LogicFeatures#lfInvalid. = 0, |
| 33 | // role description |
| 34 | lfTransitiveRolescxx . . $ LogicFeatures#lfTransitiveRoles. = (1 << 0), |
| 35 | lfRolesSubsumptioncxx . . $ LogicFeatures#lfRolesSubsumption. = (1 << 1), |
| 36 | lfDirectRolescxx . . $ LogicFeatures#lfDirectRoles. = (1 << 2), |
| 37 | lfInverseRolescxx . . $ LogicFeatures#lfInverseRoles. = (1 << 3), |
| 38 | lfRangeAndDomaincxx . . $ LogicFeatures#lfRangeAndDomain. = (1 << 4), |
| 39 | lfFunctionalRolescxx . . $ LogicFeatures#lfFunctionalRoles. = (1 << 5), |
| 40 | |
| 41 | // concept description |
| 42 | lfSomeConstructorcxx . . $ LogicFeatures#lfSomeConstructor. = (1 << 6), |
| 43 | lfFConstructorcxx . . $ LogicFeatures#lfFConstructor. = (1 << 7), |
| 44 | lfNConstructorcxx . . $ LogicFeatures#lfNConstructor. = (1 << 8), |
| 45 | lfQConstructorcxx . . $ LogicFeatures#lfQConstructor. = (1 << 9), |
| 46 | lfSingletoncxx . . $ LogicFeatures#lfSingleton. = (1 << 10), |
| 47 | |
| 48 | // global description |
| 49 | lfGeneralAxiomscxx . . $ LogicFeatures#lfGeneralAxioms. = (1 << 11), |
| 50 | lfBothRolescxx . . $ LogicFeatures#lfBothRoles. = (1 << 12), |
| 51 | |
| 52 | // new constructions |
| 53 | lfSelfRefcxx . . $ LogicFeatures#lfSelfRef. = (1 << 13), |
| 54 | lfTopRolecxx . . $ LogicFeatures#lfTopRole. = (1 << 14), |
| 55 | }; |
| 56 | |
| 57 | protected: // members |
| 58 | /// all flags in one long |
| 59 | unsigned long flagscxx . . $ LogicFeatures#flags. = 0; |
| 60 | |
| 61 | protected: // methods |
| 62 | /// set any flag |
| 63 | void setXcxx . . $ LogicFeatures#setX(2c14d3af5e7762b6). ( lfEnumcxx . . $ LogicFeatures#lfEnum# val ) { flagscxx . . $ LogicFeatures#flags. |= val; } |
| 64 | /// get value of any flag |
| 65 | bool getXcxx . . $ LogicFeatures#getX(87b4a422d0c30251). ( lfEnumcxx . . $ LogicFeatures#lfEnum# val ) const { return (flagscxx . . $ LogicFeatures#flags. & val) != 0; } |
| 66 | |
| 67 | public: // interface |
| 68 | /// default c'tor |
| 69 | LogicFeaturescxx . . $ LogicFeatures#LogicFeatures(49f6e7a06ebc5aa8).() = default; |
| 70 | /// copy c'tor |
| 71 | LogicFeaturescxx . . $ LogicFeatures#LogicFeatures(b5b90b78616ed72d).(const LogicFeaturescxx . . $ LogicFeatures#&) = default; |
| 72 | /// assignment |
| 73 | LogicFeaturescxx . . $ LogicFeatures#& operatorcxx . . $ LogicFeatures#`operator=`(9c0e370cfff66a7a). = (const LogicFeaturescxx . . $ LogicFeatures#&) = default; |
| 74 | /// operator add |
| 75 | LogicFeaturescxx . . $ LogicFeatures#& operatorcxx . . $ LogicFeatures#`operator|=`(9c0e370cfff66a7a). |= ( const LogicFeaturescxx . . $ LogicFeatures#& lf ) { flagscxx . . $ LogicFeatures#flags. |= lf.flagscxx . . $ LogicFeatures#flags.; return *this; } |
| 76 | |
| 77 | // bool hasInverseRole ( void ) const { return getX(lfDirectRoles) && getX(lfInverseRoles); } |
| 78 | bool hasInverseRolecxx . . $ LogicFeatures#hasInverseRole(50ce9a9e25b4a850). ( void ) const { return getXcxx . . $ LogicFeatures#getX(87b4a422d0c30251).(lfBothRolescxx . . $ LogicFeatures#lfBothRoles.); } |
| 79 | bool hasRoleHierarchycxx . . $ LogicFeatures#hasRoleHierarchy(50ce9a9e25b4a850). ( void ) const { return getXcxx . . $ LogicFeatures#getX(87b4a422d0c30251).(lfRolesSubsumptioncxx . . $ LogicFeatures#lfRolesSubsumption.); } |
| 80 | bool hasTransitiveRolecxx . . $ LogicFeatures#hasTransitiveRole(50ce9a9e25b4a850). ( void ) const { return getXcxx . . $ LogicFeatures#getX(87b4a422d0c30251).(lfTransitiveRolescxx . . $ LogicFeatures#lfTransitiveRoles.); } |
| 81 | bool hasSomeAllcxx . . $ LogicFeatures#hasSomeAll(50ce9a9e25b4a850). ( void ) const { return getXcxx . . $ LogicFeatures#getX(87b4a422d0c30251).(lfSomeConstructorcxx . . $ LogicFeatures#lfSomeConstructor.); } |
| 82 | bool hasFunctionalRestrictioncxx . . $ LogicFeatures#hasFunctionalRestriction(50ce9a9e25b4a850). ( void ) const { return getXcxx . . $ LogicFeatures#getX(87b4a422d0c30251).(lfFConstructorcxx . . $ LogicFeatures#lfFConstructor.) || getXcxx . . $ LogicFeatures#getX(87b4a422d0c30251).(lfFunctionalRolescxx . . $ LogicFeatures#lfFunctionalRoles.); } |
| 83 | bool hasNumberRestrictioncxx . . $ LogicFeatures#hasNumberRestriction(50ce9a9e25b4a850). ( void ) const { return getXcxx . . $ LogicFeatures#getX(87b4a422d0c30251).(lfNConstructorcxx . . $ LogicFeatures#lfNConstructor.); } |
| 84 | bool hasQNumberRestrictioncxx . . $ LogicFeatures#hasQNumberRestriction(50ce9a9e25b4a850). ( void ) const { return getXcxx . . $ LogicFeatures#getX(87b4a422d0c30251).(lfQConstructorcxx . . $ LogicFeatures#lfQConstructor.); } |
| 85 | bool hasSingletonscxx . . $ LogicFeatures#hasSingletons(50ce9a9e25b4a850). ( void ) const { return getXcxx . . $ LogicFeatures#getX(87b4a422d0c30251).(lfSingletoncxx . . $ LogicFeatures#lfSingleton.); } |
| 86 | bool hasSelfRefcxx . . $ LogicFeatures#hasSelfRef(50ce9a9e25b4a850). ( void ) const { return getXcxx . . $ LogicFeatures#getX(87b4a422d0c30251).(lfSelfRefcxx . . $ LogicFeatures#lfSelfRef.); } |
| 87 | bool hasTopRolecxx . . $ LogicFeatures#hasTopRole(50ce9a9e25b4a850). ( void ) const { return getXcxx . . $ LogicFeatures#getX(87b4a422d0c30251).(lfTopRolecxx . . $ LogicFeatures#lfTopRole.); } |
| 88 | |
| 89 | // overall state |
| 90 | |
| 91 | /// check whether no flags are set |
| 92 | bool emptycxx . . $ LogicFeatures#empty(50ce9a9e25b4a850). ( void ) const { return flagscxx . . $ LogicFeatures#flags. == 0; } |
| 93 | /// get all the flags at once |
| 94 | unsigned long getAllFlagscxx . . $ LogicFeatures#getAllFlags(fe4d2d262d4164a8). ( void ) const { return flagscxx . . $ LogicFeatures#flags.; } |
| 95 | /// set all flags to a given value; @return old value of the flags |
| 96 | unsigned long setAllFlagscxx . . $ LogicFeatures#setAllFlags(ecdaa1632f49f591). ( unsigned long value ) { unsigned long old = flagscxx . . $ LogicFeatures#flags.; flagscxx . . $ LogicFeatures#flags. = value; return old; } |
| 97 | /// clear all the flags |
| 98 | void clearcxx . . $ LogicFeatures#clear(49f6e7a06ebc5aa8). ( void ) { setAllFlagscxx . . $ LogicFeatures#setAllFlags(ecdaa1632f49f591).(0); } |
| 99 | |
| 100 | // collect statistic from different things |
| 101 | |
| 102 | /// get features from given TConcept |
| 103 | void fillConceptDatacxx . . $ LogicFeatures#fillConceptData(49c8796e4511ff9d). ( const TConceptcxx . . $ TConcept#* p ); |
| 104 | /// get features from given TRole |
| 105 | void fillRoleDatacxx . . $ LogicFeatures#fillRoleData(b2320954eb62eea2). ( const TRolecxx . . $ TRole#* p, bool both ); |
| 106 | /// get features from given DAG entry with given sign |
| 107 | void fillDAGDatacxx . . $ LogicFeatures#fillDAGData(6a493ba1542d2d3b). ( const DLVertexcxx . . $ DLVertex#& v, bool pos ); |
| 108 | |
| 109 | /// build bothRoles from single Roles flags |
| 110 | void mergeRolescxx . . $ LogicFeatures#mergeRoles(49f6e7a06ebc5aa8). ( void ) |
| 111 | { |
| 112 | if ( getXcxx . . $ LogicFeatures#getX(87b4a422d0c30251).(lfDirectRolescxx . . $ LogicFeatures#lfDirectRoles.) && getXcxx . . $ LogicFeatures#getX(87b4a422d0c30251).(lfInverseRolescxx . . $ LogicFeatures#lfInverseRoles.) ) |
| 113 | setXcxx . . $ LogicFeatures#setX(2c14d3af5e7762b6).(lfBothRolescxx . . $ LogicFeatures#lfBothRoles.); |
| 114 | } |
| 115 | /// allow user to set presence of inverse roles |
| 116 | void setInverseRolescxx . . $ LogicFeatures#setInverseRoles(49f6e7a06ebc5aa8). ( void ) { setXcxx . . $ LogicFeatures#setX(2c14d3af5e7762b6).(lfBothRolescxx . . $ LogicFeatures#lfBothRoles.); } |
| 117 | |
| 118 | /// write gathered features |
| 119 | void writeStatecxx . . $ LogicFeatures#writeState(83f5f38750778ac8). ( void ) const; |
| 120 | }; // LogicFeatures |
| 121 | |
| 122 | #endif |