| 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 TROLE_H |
| 21 | #define TROLE_Hcxx . . $ `Kernel/tRole.h:21:9`! |
| 22 | |
| 23 | #include <set> |
| 24 | #include <vector> |
| 25 | |
| 26 | #include "globaldef.h"cxx . . $ `<file>/Kernel/globaldef.h`/ // sorted reasoning |
| 27 | #include "BiPointer.h"cxx . . $ `<file>/Kernel/BiPointer.h`/ |
| 28 | #include "dltree.h"cxx . . $ `<file>/Kernel/dltree.h`/ |
| 29 | #include "taxNamEntry.h"cxx . . $ `<file>/Kernel/taxNamEntry.h`/ |
| 30 | #include "tLabeller.h"cxx . . $ `<file>/Kernel/tLabeller.h`/ |
| 31 | #include "RAutomaton.h"cxx . . $ `<file>/Kernel/RAutomaton.h`/ |
| 32 | #include "eFPPNonSimpleRole.h"cxx . . $ `<file>/Kernel/eFPPNonSimpleRole.h`/ |
| 33 | #include "eFPPCycleInRIA.h"cxx . . $ `<file>/Kernel/eFPPCycleInRIA.h`/ |
| 34 | |
| 35 | #ifdef RKG_USE_SORTED_REASONINGcxx . . $ `Kernel/globaldef.h:40:9`! |
| 36 | # include "mergeableLabel.h"cxx . . $ `<file>/Kernel/mergeableLabel.h`/ |
| 37 | #endif |
| 38 | |
| 39 | class TBoxcxx . . $ TBox#; |
| 40 | class RoleMastercxx . . $ RoleMaster#; |
| 41 | class Taxonomycxx . . $ Taxonomy#; |
| 42 | class SaveLoadManagercxx . . $ SaveLoadManager#; |
| 43 | |
| 44 | /// Define class with all information about DL role |
| 45 | class TRolecxx . . $ TRole#: public ClassifiableEntrycxx . . $ ClassifiableEntry# |
| 46 | { |
| 47 | friend class RoleMastercxx . . $ RoleMaster#; |
| 48 | |
| 49 | protected: // types |
| 50 | /// Class for values that can change wrt ontology |
| 51 | class TKnownValuecxx . . $ TRole#TKnownValue# |
| 52 | { |
| 53 | protected: // members |
| 54 | /// flag value |
| 55 | bool valuecxx . . $ TRole#TKnownValue#value.; |
| 56 | /// whether flag set or not |
| 57 | bool knowncxx . . $ TRole#TKnownValue#known. = false; |
| 58 | |
| 59 | public: // interface |
| 60 | /// init c'tor |
| 61 | explicit TKnownValuecxx . . $ TRole#TKnownValue#TKnownValue(b45ddcbc8423892c). ( bool val = false ) : valuecxx . . $ TRole#TKnownValue#value.(val) {} |
| 62 | |
| 63 | /// @return true iff the value is known to be set |
| 64 | bool isKnowncxx . . $ TRole#TKnownValue#isKnown(50ce9a9e25b4a850). ( void ) const { return knowncxx . . $ TRole#TKnownValue#known.; } |
| 65 | /// @return the value |
| 66 | bool getValuecxx . . $ TRole#TKnownValue#getValue(50ce9a9e25b4a850). ( void ) const { return valuecxx . . $ TRole#TKnownValue#value.; } |
| 67 | /// set the value; it is now known |
| 68 | void setValuecxx . . $ TRole#TKnownValue#setValue(b45ddcbc8423892c). ( bool val ) { valuecxx . . $ TRole#TKnownValue#value. = val; knowncxx . . $ TRole#TKnownValue#known. = true; } |
| 69 | }; // TKnownValue |
| 70 | |
| 71 | public: // types |
| 72 | /// vector of roles |
| 73 | typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<TRolecxx . . $ TRole#*> TRoleVeccxx . . $ TRole#TRoleVec#; |
| 74 | /// set of roles |
| 75 | typedef stdcxx . . $ std/::setcxx . . $ std/set#<TRolecxx . . $ TRole#*> TRoleSetcxx . . $ TRole#TRoleSet#; |
| 76 | /// bitmap for roles |
| 77 | typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<bool> TRoleBitMapcxx . . $ TRole#TRoleBitMap#; |
| 78 | |
| 79 | protected: // members |
| 80 | /// role that are inverse of given one |
| 81 | TRolecxx . . $ TRole#* Inversecxx . . $ TRole#Inverse. = nullptr; |
| 82 | |
| 83 | /// Domain of role as a concept description; default NULL |
| 84 | DLTreecxx . . $ DLTree#* pDomaincxx . . $ TRole#pDomain. = nullptr; |
| 85 | /// Domain of role as a concept description; default NULL |
| 86 | DLTreecxx . . $ DLTree#* pSpecialDomaincxx . . $ TRole#pSpecialDomain. = nullptr; |
| 87 | /// Domain of role as a pointer to DAG entry |
| 88 | BipolarPointercxx . . $ BipolarPointer# bpDomaincxx . . $ TRole#bpDomain. = bpINVALIDcxx . . $ bpINVALID.; |
| 89 | /// domain in the form AR.Range for the complex roles |
| 90 | BipolarPointercxx . . $ BipolarPointer# bpSpecialDomaincxx . . $ TRole#bpSpecialDomain. = bpINVALIDcxx . . $ bpINVALID.; |
| 91 | |
| 92 | /// pointer to role's functional definition DAG entry (or just TOP) |
| 93 | BipolarPointercxx . . $ BipolarPointer# Functionalcxx . . $ TRole#Functional. = bpINVALIDcxx . . $ bpINVALID.; |
| 94 | |
| 95 | /// is role relevant to current query |
| 96 | TLabellercxx . . $ TLabeller#::LabelTypecxx . . $ TLabeller#LabelType# relcxx . . $ TRole#rel. = 0; |
| 97 | |
| 98 | #ifdef RKG_USE_SORTED_REASONINGcxx . . $ `Kernel/globaldef.h:40:9`! |
| 99 | /// label of a domain (inverse role is used for a range label) |
| 100 | mergeableLabelcxx . . $ mergeableLabel# domLabelcxx . . $ TRole#domLabel.; |
| 101 | #endif |
| 102 | |
| 103 | // for later filling |
| 104 | // FIXME!! const was removed for Relevance setting |
| 105 | TRoleVeccxx . . $ TRole#TRoleVec# Ancestorcxx . . $ TRole#Ancestor., Descendantcxx . . $ TRole#Descendant.; |
| 106 | /// set of the most functional super-roles |
| 107 | TRoleVeccxx . . $ TRole#TRoleVec# TopFunccxx . . $ TRole#TopFunc.; |
| 108 | /// set of the roles that are disjoint with a given one |
| 109 | TRoleSetcxx . . $ TRole#TRoleSet# Disjointcxx . . $ TRole#Disjoint.; |
| 110 | /// all compositions in the form R1*R2*\ldots*Rn [= R |
| 111 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<TRoleVeccxx . . $ TRole#TRoleVec#> subCompositionscxx . . $ TRole#subCompositions.; |
| 112 | |
| 113 | /// bit-vector of all parents |
| 114 | TRoleBitMapcxx . . $ TRole#TRoleBitMap# AncMapcxx . . $ TRole#AncMap.; |
| 115 | /// bit-vector of all roles disjoint with current |
| 116 | TRoleBitMapcxx . . $ TRole#TRoleBitMap# DJRolescxx . . $ TRole#DJRoles.; |
| 117 | |
| 118 | /// automaton for role |
| 119 | RoleAutomatoncxx . . $ RoleAutomaton# Acxx . . $ TRole#A.; |
| 120 | |
| 121 | /// value for functionality |
| 122 | TKnownValuecxx . . $ TRole#TKnownValue# Functionalitycxx . . $ TRole#Functionality.; |
| 123 | /// value for symmetry |
| 124 | TKnownValuecxx . . $ TRole#TKnownValue# Symmetrycxx . . $ TRole#Symmetry.; |
| 125 | /// value for asymmetricity |
| 126 | TKnownValuecxx . . $ TRole#TKnownValue# Asymmetrycxx . . $ TRole#Asymmetry.; |
| 127 | /// value for transitivity |
| 128 | TKnownValuecxx . . $ TRole#TKnownValue# Transitivitycxx . . $ TRole#Transitivity.; |
| 129 | /// value for reflexivity |
| 130 | TKnownValuecxx . . $ TRole#TKnownValue# Reflexivitycxx . . $ TRole#Reflexivity.; |
| 131 | /// value for reflexivity |
| 132 | TKnownValuecxx . . $ TRole#TKnownValue# Irreflexivitycxx . . $ TRole#Irreflexivity.; |
| 133 | /// flag to show that this role needs special R&D processing |
| 134 | bool SpecialDomaincxx . . $ TRole#SpecialDomain. = false; |
| 135 | |
| 136 | protected: // methods |
| 137 | // support for Anc/Desc filling and such |
| 138 | |
| 139 | /// check if the role is REALLY topmost-functional (internal-use only) |
| 140 | bool isRealTopFunccxx . . $ TRole#isRealTopFunc(50ce9a9e25b4a850). ( void ) const; |
| 141 | /// set up TopFunc member properly (internal-use only) |
| 142 | void initTopFunccxx . . $ TRole#initTopFunc(49f6e7a06ebc5aa8). ( void ); |
| 143 | /// init map of all disjoint roles |
| 144 | void initDJMapcxx . . $ TRole#initDJMap(49f6e7a06ebc5aa8). ( void ); |
| 145 | |
| 146 | /// eliminate told role cycle, carrying aux arrays of processed roles and synonyms |
| 147 | TRolecxx . . $ TRole#* eliminateToldCyclescxx . . $ TRole#eliminateToldCycles(da3b35d3ecb922e7). ( TRoleSetcxx . . $ TRole#TRoleSet#& RInProcess, TRoleVeccxx . . $ TRole#TRoleVec#& ToldSynonyms ); |
| 148 | |
| 149 | // support for automaton construction |
| 150 | |
| 151 | /// complete role automaton; keep track of processed roles in RINPROCESS |
| 152 | void completeAutomatoncxx . . $ TRole#completeAutomaton(3cce881a86f6be27). ( TRoleSetcxx . . $ TRole#TRoleSet#& RInProcess ); |
| 153 | /// replace RoR [= R with Trans(R), replace synonyms in RS |
| 154 | void preprocessCompositioncxx . . $ TRole#preprocessComposition(9f78be017486fe7b). ( TRoleVeccxx . . $ TRole#TRoleVec#& RS ); |
| 155 | /// add transition to automaton with the role |
| 156 | void addTrivialTransitioncxx . . $ TRole#addTrivialTransition(67b1ad1f11addbc2). ( const TRolecxx . . $ TRole#* r ) |
| 157 | { Acxx . . $ TRole#A..addTransitionSafecxx . . $ RoleAutomaton#addTransitionSafe(ee5932827597e1f9). ( Acxx . . $ TRole#A..initialcxx . . $ RoleAutomaton#initial(ddd8539a2fcdd4ce).(), RATransitioncxx . . $ RATransition#RATransition(6d11a3757d356e3a). ( Acxx . . $ TRole#A..finalcxx . . $ RoleAutomaton#final(ddd8539a2fcdd4ce).(), r ) ); } |
| 158 | /// add automaton of a sub-role to a given one |
| 159 | void addSubRoleAutomatoncxx . . $ TRole#addSubRoleAutomaton(67b1ad1f11addbc2). ( const TRolecxx . . $ TRole#* R ) |
| 160 | { |
| 161 | if ( this != R ) // non-trivial addition |
| 162 | Acxx . . $ TRole#A..addRAcxx . . $ RoleAutomaton#addRA(12494a229a69a5c3).(R->getAutomatoncxx . . $ TRole#getAutomaton(63b0d77ccf579a4).()); |
| 163 | } |
| 164 | /// get an automaton by a (possibly synonymical) role |
| 165 | const RoleAutomatoncxx . . $ RoleAutomaton#& completeAutomatonByRolecxx . . $ TRole#completeAutomatonByRole(e4ba9dab185a60c5). ( TRolecxx . . $ TRole#* R, TRoleSetcxx . . $ TRole#TRoleSet#& RInProcess ) const |
| 166 | { |
| 167 | fpp_assertcxx . . $ EFPPAssertion#EFPPAssertion(85c52e162fed56f9). ( !R->isSynonym() ); // no synonyms here |
| 168 | fpp_assertcxx . . $ EFPPAssertion# ( R != this ); // no case ...*S*... [= S |
| 169 | R->completeAutomatoncxx . . $ TRole#completeAutomaton(3cce881a86f6be27).(RInProcess); |
| 170 | return R->getAutomatoncxx . . $ TRole#getAutomaton(63b0d77ccf579a4).(); |
| 171 | } |
| 172 | /// add automaton for a role composition; simplify composition |
| 173 | void addSubCompositionAutomatoncxx . . $ TRole#addSubCompositionAutomaton(4f4bf62c685b677). ( TRoleVeccxx . . $ TRole#TRoleVec#& RS, TRoleSetcxx . . $ TRole#TRoleSet#& RInProcess ); |
| 174 | |
| 175 | /// check (and correct) case whether R != S for R [= S |
| 176 | void checkHierarchicalDisjointcxx . . $ TRole#checkHierarchicalDisjoint(3d6e099a537f0595). ( TRolecxx . . $ TRole#* R ); |
| 177 | /// check whether there is a sub-property with special domain; propagate this |
| 178 | void checkSpecialDomaincxx . . $ TRole#checkSpecialDomain(49f6e7a06ebc5aa8). ( void ) |
| 179 | { |
| 180 | if ( hasSpecialDomaincxx . . $ TRole#hasSpecialDomain(50ce9a9e25b4a850).() ) |
| 181 | return; |
| 182 | for ( const auto& sub: Descendantcxx . . $ TRole#Descendant. ) |
| 183 | if ( sub->hasSpecialDomaincxx . . $ TRole#hasSpecialDomain(50ce9a9e25b4a850).() ) |
| 184 | { |
| 185 | SpecialDomaincxx . . $ TRole#SpecialDomain. = true; |
| 186 | return; |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | public: // interface |
| 191 | /// no empty c'tor |
| 192 | TRolecxx . . $ TRole#TRole(49f6e7a06ebc5aa8). () = delete; |
| 193 | /// no copy c'tor |
| 194 | TRolecxx . . $ TRole#TRole(352a2cdc972bb3f5). ( const TRolecxx . . $ TRole#& ) = delete; |
| 195 | /// no assignment |
| 196 | TRolecxx . . $ TRole#& operatorcxx . . $ TRole#`operator=`(ab9f39ee1fac2c95). = ( const TRolecxx . . $ TRole#& ) = delete; |
| 197 | /// the only c'tor |
| 198 | explicit TRolecxx . . $ TRole#TRole(9c546c94e5fcce4e). ( const stdcxx . . $ std/::stringcxx . . $ std/string#& name ); |
| 199 | /// d'tor |
| 200 | ~cxx . . $ TRole#`~TRole`(49f6e7a06ebc5aa8).TRolecxx . . $ TRole#() override; |
| 201 | |
| 202 | /// get (unsigned) unique index of the role |
| 203 | unsigned int getIndexcxx . . $ TRole#getIndex(ddd8539a2fcdd4ce). ( void ) const |
| 204 | { |
| 205 | int i = 2*getIdcxx . . $ TNamedEntry#getId(455f465bc33b4cdf).(); |
| 206 | return i > 0 |
| 207 | ? (unsigned int)i |
| 208 | : (unsigned int)(1-i); |
| 209 | } |
| 210 | |
| 211 | // access to role hierarchy |
| 212 | |
| 213 | /// get RO access to all super-roles |
| 214 | const TRoleVeccxx . . $ TRole#TRoleVec#& ancestorscxx . . $ TRole#ancestors(5c1fd3e4e1fb59f2). ( void ) const { return Ancestorcxx . . $ TRole#Ancestor.; } |
| 215 | /// get RO access to all sub-roles |
| 216 | const TRoleVeccxx . . $ TRole#TRoleVec#& descendantscxx . . $ TRole#descendants(5c1fd3e4e1fb59f2). ( void ) const { return Descendantcxx . . $ TRole#Descendant.; } |
| 217 | /// get RO access to the func super-roles w/o func parents |
| 218 | const TRoleVeccxx . . $ TRole#TRoleVec#& topfuncscxx . . $ TRole#topfuncs(5c1fd3e4e1fb59f2). ( void ) const { return TopFunccxx . . $ TRole#TopFunc.; } |
| 219 | |
| 220 | // synonym operations |
| 221 | |
| 222 | /// copy role information (like transitivity, functionality, R&D etc) to synonym |
| 223 | void addFeaturesToSynonymcxx . . $ TRole#addFeaturesToSynonym(49f6e7a06ebc5aa8). ( void ); |
| 224 | |
| 225 | // inverse of the role |
| 226 | |
| 227 | /// get inverse of given role (non-const version) |
| 228 | TRolecxx . . $ TRole#* inversecxx . . $ TRole#inverse(6cda9dc08d29302e). ( void ) { fpp_assertcxx . . $ TRole#Inverse. (Inverse != nullptr); return resolveSynonymcxx . . $ resolveSynonym(98ea26de6545f0ca).(Inversecxx . . $ TRole#Inverse.); } |
| 229 | /// get inverse of given role (const version) |
| 230 | const TRolecxx . . $ TRole#* inversecxx . . $ TRole#inverse(69f26110a94b259f). ( void ) const { fpp_assertcxx . . $ EFPPAssertion# (Inverse != nullptr); return resolveSynonymcxx . . $ resolveSynonym(98ea26de6545f0ca).(Inversecxx . . $ TRole#Inverse.); } |
| 231 | /// get real inverse of a role (RO) |
| 232 | const TRolecxx . . $ TRole#* realInversecxx . . $ TRole#realInverse(69f26110a94b259f). ( void ) const { fpp_assertcxx . . $ EFPPAssertion# (Inverse != nullptr); return Inversecxx . . $ TRole#Inverse.; } |
| 233 | /// set inverse to given role |
| 234 | void setInversecxx . . $ TRole#setInverse(3d6e099a537f0595). ( TRolecxx . . $ TRole#* p ) { fpp_assertcxx . . $ EFPPAssertion# (Inverse == nullptr); Inversecxx . . $ TRole#Inverse. = p; } |
| 235 | |
| 236 | // different flags |
| 237 | |
| 238 | /// distinguish data- and non-data role |
| 239 | FPP_ADD_FLAGcxx . . $ `Kernel/flags.h:64:9`!(DataRole,0x10); |
| 240 | |
| 241 | // simple |
| 242 | |
| 243 | // @return true iff the role is simple |
| 244 | bool isSimplecxx . . $ TRole#isSimple(50ce9a9e25b4a850). ( void ) const { return Acxx . . $ TRole#A..isSimplecxx . . $ RoleAutomaton#isSimple(50ce9a9e25b4a850).(); } |
| 245 | |
| 246 | // functionality |
| 247 | |
| 248 | /// test if role is functional (ie, have some functional ancestors) |
| 249 | bool isFunctionalcxx . . $ TRole#isFunctional(50ce9a9e25b4a850). ( void ) const { return Functionalitycxx . . $ TRole#Functionality..getValuecxx . . $ TRole#TKnownValue#getValue(50ce9a9e25b4a850).(); } |
| 250 | /// check whether the functionality of a role is known |
| 251 | bool isFunctionalityKnowncxx . . $ TRole#isFunctionalityKnown(50ce9a9e25b4a850). ( void ) const { return Functionalitycxx . . $ TRole#Functionality..isKnowncxx . . $ TRole#TKnownValue#isKnown(50ce9a9e25b4a850).(); } |
| 252 | /// check if the role is topmost-functional (ie, has no functional ancestors). |
| 253 | bool isTopFunccxx . . $ TRole#isTopFunc(50ce9a9e25b4a850). ( void ) const |
| 254 | { // check for emptiness is here due to case where a role is determined to be a functional |
| 255 | return !TopFunccxx . . $ TRole#TopFunc..emptycxx . . $ std/vector#empty(50ce9a9e25b4a850).() && *cxx . . $ __gnu_cxx/__normal_iterator#`operator*`(c076846f881f3e7e).TopFunccxx . . $ TRole#TopFunc..begincxx . . $ std/vector#begin(359ca5030082c9f).() == this; |
| 256 | } |
| 257 | /// set role functionality value |
| 258 | void setFunctionalcxx . . $ TRole#setFunctional(b45ddcbc8423892c). ( bool value ) { Functionalitycxx . . $ TRole#Functionality..setValuecxx . . $ TRole#TKnownValue#setValue(b45ddcbc8423892c).(value); } |
| 259 | /// mark role (topmost) functional |
| 260 | void setFunctionalcxx . . $ TRole#setFunctional(49f6e7a06ebc5aa8). ( void ) |
| 261 | { |
| 262 | if ( TopFunccxx . . $ TRole#TopFunc..emptycxx . . $ std/vector#empty(50ce9a9e25b4a850).() ) |
| 263 | TopFunccxx . . $ TRole#TopFunc..push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(this); |
| 264 | setFunctionalcxx . . $ TRole#setFunctional(b45ddcbc8423892c).(true); |
| 265 | } |
| 266 | /// set functional attribute to given value (functional DAG vertex) |
| 267 | void setFunctionalcxx . . $ TRole#setFunctional(d4f767463ce0a6b3). ( BipolarPointercxx . . $ BipolarPointer# fNode ) { Functionalcxx . . $ TRole#Functional. = fNode; } |
| 268 | /// get the Functional DAG vertex |
| 269 | BipolarPointercxx . . $ BipolarPointer# getFunctionalcxx . . $ TRole#getFunctional(455f465bc33b4cdf). ( void ) const { return Functionalcxx . . $ TRole#Functional.; } |
| 270 | |
| 271 | // transitivity |
| 272 | |
| 273 | /// check whether the role is transitive |
| 274 | bool isTransitivecxx . . $ TRole#isTransitive(50ce9a9e25b4a850). ( void ) const { return Transitivitycxx . . $ TRole#Transitivity..getValuecxx . . $ TRole#TKnownValue#getValue(50ce9a9e25b4a850).(); } |
| 275 | /// check whether the transitivity of a role is known |
| 276 | bool isTransitivityKnowncxx . . $ TRole#isTransitivityKnown(50ce9a9e25b4a850). ( void ) const { return Transitivitycxx . . $ TRole#Transitivity..isKnowncxx . . $ TRole#TKnownValue#isKnown(50ce9a9e25b4a850).(); } |
| 277 | /// set the transitivity of both role and it's inverse |
| 278 | void setTransitivecxx . . $ TRole#setTransitive(b45ddcbc8423892c). ( bool value = true ) { Transitivitycxx . . $ TRole#Transitivity..setValuecxx . . $ TRole#TKnownValue#setValue(b45ddcbc8423892c).(value); inversecxx . . $ TRole#inverse(6cda9dc08d29302e).()->Transitivitycxx . . $ TRole#Transitivity..setValuecxx . . $ TRole#TKnownValue#setValue(b45ddcbc8423892c).(value); } |
| 279 | |
| 280 | // symmetry |
| 281 | |
| 282 | /// check whether the role is symmetric |
| 283 | bool isSymmetriccxx . . $ TRole#isSymmetric(50ce9a9e25b4a850). ( void ) const { return Symmetrycxx . . $ TRole#Symmetry..getValuecxx . . $ TRole#TKnownValue#getValue(50ce9a9e25b4a850).(); } |
| 284 | /// check whether the symmetry of a role is known |
| 285 | bool isSymmetryKnowncxx . . $ TRole#isSymmetryKnown(50ce9a9e25b4a850). ( void ) const { return Symmetrycxx . . $ TRole#Symmetry..isKnowncxx . . $ TRole#TKnownValue#isKnown(50ce9a9e25b4a850).(); } |
| 286 | /// set the symmetry of both role and it's inverse |
| 287 | void setSymmetriccxx . . $ TRole#setSymmetric(b45ddcbc8423892c). ( bool value = true ) { Symmetrycxx . . $ TRole#Symmetry..setValuecxx . . $ TRole#TKnownValue#setValue(b45ddcbc8423892c).(value); inversecxx . . $ TRole#inverse(6cda9dc08d29302e).()->Symmetrycxx . . $ TRole#Symmetry..setValuecxx . . $ TRole#TKnownValue#setValue(b45ddcbc8423892c).(value); } |
| 288 | |
| 289 | // asymmetry |
| 290 | |
| 291 | /// check whether the role is asymmetric |
| 292 | bool isAsymmetriccxx . . $ TRole#isAsymmetric(50ce9a9e25b4a850). ( void ) const { return Asymmetrycxx . . $ TRole#Asymmetry..getValuecxx . . $ TRole#TKnownValue#getValue(50ce9a9e25b4a850).(); } |
| 293 | /// check whether the asymmetry of a role is known |
| 294 | bool isAsymmetryKnowncxx . . $ TRole#isAsymmetryKnown(50ce9a9e25b4a850). ( void ) const { return Asymmetrycxx . . $ TRole#Asymmetry..isKnowncxx . . $ TRole#TKnownValue#isKnown(50ce9a9e25b4a850).(); } |
| 295 | /// set the asymmetry of both role and it's inverse |
| 296 | void setAsymmetriccxx . . $ TRole#setAsymmetric(b45ddcbc8423892c). ( bool value = true ) { Asymmetrycxx . . $ TRole#Asymmetry..setValuecxx . . $ TRole#TKnownValue#setValue(b45ddcbc8423892c).(value); inversecxx . . $ TRole#inverse(6cda9dc08d29302e).()->Asymmetrycxx . . $ TRole#Asymmetry..setValuecxx . . $ TRole#TKnownValue#setValue(b45ddcbc8423892c).(value); } |
| 297 | |
| 298 | // reflexivity |
| 299 | |
| 300 | /// check whether the role is reflexive |
| 301 | bool isReflexivecxx . . $ TRole#isReflexive(50ce9a9e25b4a850). ( void ) const { return Reflexivitycxx . . $ TRole#Reflexivity..getValuecxx . . $ TRole#TKnownValue#getValue(50ce9a9e25b4a850).(); } |
| 302 | /// check whether the reflexivity of a role is known |
| 303 | bool isReflexivityKnowncxx . . $ TRole#isReflexivityKnown(50ce9a9e25b4a850). ( void ) const { return Reflexivitycxx . . $ TRole#Reflexivity..isKnowncxx . . $ TRole#TKnownValue#isKnown(50ce9a9e25b4a850).(); } |
| 304 | /// set the reflexivity of both role and it's inverse |
| 305 | void setReflexivecxx . . $ TRole#setReflexive(b45ddcbc8423892c). ( bool value = true ) { Reflexivitycxx . . $ TRole#Reflexivity..setValuecxx . . $ TRole#TKnownValue#setValue(b45ddcbc8423892c).(value); inversecxx . . $ TRole#inverse(6cda9dc08d29302e).()->Reflexivitycxx . . $ TRole#Reflexivity..setValuecxx . . $ TRole#TKnownValue#setValue(b45ddcbc8423892c).(value); } |
| 306 | |
| 307 | // irreflexivity |
| 308 | |
| 309 | /// check whether the role is irreflexive |
| 310 | bool isIrreflexivecxx . . $ TRole#isIrreflexive(50ce9a9e25b4a850). ( void ) const { return Irreflexivitycxx . . $ TRole#Irreflexivity..getValuecxx . . $ TRole#TKnownValue#getValue(50ce9a9e25b4a850).(); } |
| 311 | /// check whether the irreflexivity of a role is known |
| 312 | bool isIrreflexivityKnowncxx . . $ TRole#isIrreflexivityKnown(50ce9a9e25b4a850). ( void ) const { return Irreflexivitycxx . . $ TRole#Irreflexivity..isKnowncxx . . $ TRole#TKnownValue#isKnown(50ce9a9e25b4a850).(); } |
| 313 | /// set the irreflexivity of both role and it's inverse |
| 314 | void setIrreflexivecxx . . $ TRole#setIrreflexive(b45ddcbc8423892c). ( bool value = true ) { Irreflexivitycxx . . $ TRole#Irreflexivity..setValuecxx . . $ TRole#TKnownValue#setValue(b45ddcbc8423892c).(value); inversecxx . . $ TRole#inverse(6cda9dc08d29302e).()->Irreflexivitycxx . . $ TRole#Irreflexivity..setValuecxx . . $ TRole#TKnownValue#setValue(b45ddcbc8423892c).(value); } |
| 315 | |
| 316 | // relevance |
| 317 | |
| 318 | /// is given role relevant to given Labeller's state |
| 319 | bool isRelevantcxx . . $ TRole#isRelevant(cb76649e174af24). ( const TLabellercxx . . $ TLabeller#& lab ) const { return lab.isLabelledcxx . . $ TLabeller#isLabelled(7ba91045e28e2316).(relcxx . . $ TRole#rel.); } |
| 320 | /// make given role relevant to given Labeller's state |
| 321 | void setRelevantcxx . . $ TRole#setRelevant(9ce72ecab6fc8b2b). ( const TLabellercxx . . $ TLabeller#& lab ) { lab.setcxx . . $ TLabeller#set(702af1567bd3bb3c).(relcxx . . $ TRole#rel.); } |
| 322 | |
| 323 | #ifdef RKG_USE_SORTED_REASONINGcxx . . $ `Kernel/globaldef.h:40:9`! |
| 324 | // Sorted reasoning interface |
| 325 | |
| 326 | /// get label of the role's domain |
| 327 | mergeableLabelcxx . . $ mergeableLabel#& getDomainLabelcxx . . $ TRole#getDomainLabel(e1d2169d387f9f72). ( void ) { return domLabelcxx . . $ TRole#domLabel.; } |
| 328 | /// get label of the role's range |
| 329 | mergeableLabelcxx . . $ mergeableLabel#& getRangeLabelcxx . . $ TRole#getRangeLabel(e1d2169d387f9f72). ( void ) { return inversecxx . . $ TRole#inverse(6cda9dc08d29302e).()->getDomainLabelcxx . . $ TRole#getDomainLabel(e1d2169d387f9f72).(); } |
| 330 | /// merge label of given role and all its super-roles |
| 331 | void mergeSupersDomaincxx . . $ TRole#mergeSupersDomain(49f6e7a06ebc5aa8). ( void ); |
| 332 | #endif |
| 333 | |
| 334 | // domain and range |
| 335 | |
| 336 | /// add p to domain of the role |
| 337 | void setDomaincxx . . $ TRole#setDomain(edf821a2fc5509f9). ( DLTreecxx . . $ DLTree#* p ) |
| 338 | { |
| 339 | if ( equalTreescxx . . $ equalTrees(d3c03bdc42525896). ( pDomaincxx . . $ TRole#pDomain., p ) ) // not just a CName |
| 340 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(p); // usual case when you have a name for inverse role |
| 341 | else if ( isFunctionalExprcxx . . $ isFunctionalExpr(45db1909c25d601a). ( p, this ) ) |
| 342 | { |
| 343 | setFunctionalcxx . . $ TRole#setFunctional(49f6e7a06ebc5aa8).(); |
| 344 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(p); // functional restriction in the role domain means the role is functional |
| 345 | } |
| 346 | else |
| 347 | pDomaincxx . . $ TRole#pDomain. = createSNFReducedAndcxx . . $ createSNFReducedAnd(f2877343b7b69ea7). ( pDomaincxx . . $ TRole#pDomain., p ); |
| 348 | } |
| 349 | /// add p to range of the role |
| 350 | void setRangecxx . . $ TRole#setRange(edf821a2fc5509f9). ( DLTreecxx . . $ DLTree#* p ) { inversecxx . . $ TRole#inverse(6cda9dc08d29302e).()->setDomaincxx . . $ TRole#setDomain(edf821a2fc5509f9).(p); } |
| 351 | |
| 352 | /// get domain-as-a-tree of the role |
| 353 | DLTreecxx . . $ DLTree#* getTDomaincxx . . $ TRole#getTDomain(7ba0ba2d2b26f6a8). ( void ) const { return pDomaincxx . . $ TRole#pDomain.; } |
| 354 | /// get range-as-a-tree of the role |
| 355 | DLTreecxx . . $ DLTree#* getTRangecxx . . $ TRole#getTRange(7ba0ba2d2b26f6a8). ( void ) const { return inversecxx . . $ TRole#inverse(69f26110a94b259f).()->pDomaincxx . . $ TRole#pDomain.; } |
| 356 | |
| 357 | /// get special-domain-as-a-tree |
| 358 | DLTreecxx . . $ DLTree#* getTSpecialDomaincxx . . $ TRole#getTSpecialDomain(aa22cc08b69ae2ef). ( void ) { return pSpecialDomaincxx . . $ TRole#pSpecialDomain.; } |
| 359 | |
| 360 | /// merge to Domain all domains from super-roles |
| 361 | void collectDomainFromSuperscxx . . $ TRole#collectDomainFromSupers(49f6e7a06ebc5aa8). ( void ) |
| 362 | { |
| 363 | for ( const auto& sup: ancestorscxx . . $ TRole#ancestors(5c1fd3e4e1fb59f2).() ) |
| 364 | setDomaincxx . . $ TRole#setDomain(edf821a2fc5509f9). ( clonecxx . . $ clone(ec41a33c52a5614b).(sup->getTDomaincxx . . $ TRole#getTDomain(7ba0ba2d2b26f6a8).()) ); |
| 365 | } |
| 366 | |
| 367 | /// set domain-as-a-bipointer to a role |
| 368 | void setBPDomaincxx . . $ TRole#setBPDomain(d4f767463ce0a6b3). ( BipolarPointercxx . . $ BipolarPointer# p ) { bpDomaincxx . . $ TRole#bpDomain. = p; } |
| 369 | /// get domain-as-a-bipointer of the role |
| 370 | BipolarPointercxx . . $ BipolarPointer# getBPDomaincxx . . $ TRole#getBPDomain(455f465bc33b4cdf). ( void ) const { return bpDomaincxx . . $ TRole#bpDomain.; } |
| 371 | /// get range-as-a-bipointer of the role |
| 372 | BipolarPointercxx . . $ BipolarPointer# getBPRangecxx . . $ TRole#getBPRange(455f465bc33b4cdf). ( void ) const { return inversecxx . . $ TRole#inverse(69f26110a94b259f).()->bpDomaincxx . . $ TRole#bpDomain.; } |
| 373 | /// @return true iff role has a special domain |
| 374 | bool hasSpecialDomaincxx . . $ TRole#hasSpecialDomain(50ce9a9e25b4a850). ( void ) const { return SpecialDomaincxx . . $ TRole#SpecialDomain.; } |
| 375 | /// init special domain; call this only after *ALL* the domains are known |
| 376 | void initSpecialDomaincxx . . $ TRole#initSpecialDomain(49f6e7a06ebc5aa8). ( void ) |
| 377 | { |
| 378 | if ( !hasSpecialDomaincxx . . $ TRole#hasSpecialDomain(50ce9a9e25b4a850).() || getTRangecxx . . $ TRole#getTRange(7ba0ba2d2b26f6a8).() == nullptr ) |
| 379 | pSpecialDomaincxx . . $ TRole#pSpecialDomain. = createTopcxx . . $ createTop(aa22cc08b69ae2ef).(); |
| 380 | else |
| 381 | pSpecialDomaincxx . . $ TRole#pSpecialDomain. = createSNFForallcxx . . $ createSNFForall(f2877343b7b69ea7). ( createRolecxx . . $ createRole(6ab896d6f1aa3781).(this), clonecxx . . $ clone(ec41a33c52a5614b).(getTRangecxx . . $ TRole#getTRange(7ba0ba2d2b26f6a8).()) ); |
| 382 | } |
| 383 | /// set the special domain value |
| 384 | void setSpecialDomaincxx . . $ TRole#setSpecialDomain(d4f767463ce0a6b3). ( BipolarPointercxx . . $ BipolarPointer# bp ) { bpSpecialDomaincxx . . $ TRole#bpSpecialDomain. = bp; } |
| 385 | /// get special domain value |
| 386 | BipolarPointercxx . . $ BipolarPointer# getSpecialDomaincxx . . $ TRole#getSpecialDomain(455f465bc33b4cdf). ( void ) const { return bpSpecialDomaincxx . . $ TRole#bpSpecialDomain.; } |
| 387 | /// get special range value |
| 388 | BipolarPointercxx . . $ BipolarPointer# getSpecialRangecxx . . $ TRole#getSpecialRange(455f465bc33b4cdf). ( void ) const { return inversecxx . . $ TRole#inverse(69f26110a94b259f).()->bpSpecialDomaincxx . . $ TRole#bpSpecialDomain.; } |
| 389 | |
| 390 | // disjoint roles |
| 391 | |
| 392 | /// set R and THIS as a disjoint; use it after Anc/Desc are determined |
| 393 | void addDisjointRolecxx . . $ TRole#addDisjointRole(3d6e099a537f0595). ( TRolecxx . . $ TRole#* R ) |
| 394 | { |
| 395 | Disjointcxx . . $ TRole#Disjoint..insertcxx . . $ std/set#insert(411a10a755068dfe).(R); |
| 396 | for ( auto& sub: R->descendantscxx . . $ TRole#descendants(5c1fd3e4e1fb59f2).() ) |
| 397 | { |
| 398 | Disjointcxx . . $ TRole#Disjoint..insertcxx . . $ std/set#insert(411a10a755068dfe).(sub); |
| 399 | sub->Disjointcxx . . $ TRole#Disjoint..insertcxx . . $ std/set#insert(10916b2dbd511ba8).(this); |
| 400 | } |
| 401 | } |
| 402 | /// check (and correct) case whether R != S for R [= S |
| 403 | void checkHierarchicalDisjointcxx . . $ TRole#checkHierarchicalDisjoint(49f6e7a06ebc5aa8). ( void ) |
| 404 | { |
| 405 | checkHierarchicalDisjointcxx . . $ TRole#checkHierarchicalDisjoint(3d6e099a537f0595).(this); |
| 406 | if ( isReflexivecxx . . $ TRole#isReflexive(50ce9a9e25b4a850).() ) // for reflexive roles check for R^- is necessary |
| 407 | checkHierarchicalDisjointcxx . . $ TRole#checkHierarchicalDisjoint(3d6e099a537f0595).(inversecxx . . $ TRole#inverse(6cda9dc08d29302e).()); |
| 408 | } |
| 409 | /// check whether a role is disjoint with anything |
| 410 | bool isDisjointcxx . . $ TRole#isDisjoint(50ce9a9e25b4a850). ( void ) const { return !Disjointcxx . . $ TRole#Disjoint..emptycxx . . $ std/set#empty(50ce9a9e25b4a850).(); } |
| 411 | /// check whether a role is disjoint with R |
| 412 | bool isDisjointcxx . . $ TRole#isDisjoint(81d69a9c8508a392). ( const TRolecxx . . $ TRole#* r ) const { return DJRolescxx . . $ TRole#DJRoles.[cxx . . $ std/vector#`operator[]`(2ff7c7de1baa6d0a).r->getIndexcxx . . $ TRole#getIndex(ddd8539a2fcdd4ce).()]; } |
| 413 | |
| 414 | // role relations checking |
| 415 | |
| 416 | /// two roles are the same iff thy are synonyms of the same role |
| 417 | bool operatorcxx . . $ TRole#`operator==`(f855a32f4b5dce26). == ( const TRolecxx . . $ TRole#& r ) const { return this == &r; } |
| 418 | /// check if role is a strict sub-role of R |
| 419 | bool operatorcxx . . $ TRole#`operator<`(f855a32f4b5dce26). < ( const TRolecxx . . $ TRole#& r ) const { return (isDataRolecxx . . $ TRole#isDataRole(50ce9a9e25b4a850).() == r.isDataRolecxx . . $ TRole#isDataRole(50ce9a9e25b4a850).()) && AncMapcxx . . $ TRole#AncMap.[cxx . . $ std/vector#`operator[]`(2ff7c7de1baa6d0a).r.getIndexcxx . . $ TRole#getIndex(ddd8539a2fcdd4ce).()]; } |
| 420 | /// check if role is a non-strict sub-role of R |
| 421 | bool operatorcxx . . $ TRole#`operator<=`(f855a32f4b5dce26). <= ( const TRolecxx . . $ TRole#& r ) const { return (*this ==cxx . . $ TRole#`operator==`(f855a32f4b5dce26). r) || (*this <cxx . . $ TRole#`operator<`(f855a32f4b5dce26). r); } |
| 422 | /// check if role is a strict super-role of R |
| 423 | bool operatorcxx . . $ TRole#`operator>`(f855a32f4b5dce26). > ( const TRolecxx . . $ TRole#& r ) const { return r <cxx . . $ TRole#`operator<`(f855a32f4b5dce26). *this; } |
| 424 | /// check if role is a non-strict super-role of R |
| 425 | bool operatorcxx . . $ TRole#`operator>=`(f855a32f4b5dce26). >= ( const TRolecxx . . $ TRole#& r ) const { return (*this ==cxx . . $ TRole#`operator==`(f855a32f4b5dce26). r) || (*this >cxx . . $ TRole#`operator>`(f855a32f4b5dce26). r); } |
| 426 | |
| 427 | /// fills BITMAP with the role's ancestors |
| 428 | void addAncestorsToBitMapcxx . . $ TRole#addAncestorsToBitMap(872a9bef1b2f4afb). ( TRoleBitMapcxx . . $ TRole#TRoleBitMap#& bitmap ) const |
| 429 | { |
| 430 | fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( !bitmap.empty() ); // use only after the size is known |
| 431 | for ( const auto& sup: ancestorscxx . . $ TRole#ancestors(5c1fd3e4e1fb59f2).() ) |
| 432 | bitmap[cxx . . $ std/vector#`operator[]`(1450282ea0befc17).sup->getIndexcxx . . $ TRole#getIndex(ddd8539a2fcdd4ce).()] =cxx . . $ std/_Bit_reference#`operator=`(2b7708a91196d621). true; |
| 433 | } |
| 434 | |
| 435 | // automaton construction |
| 436 | |
| 437 | /// add composition to a role |
| 438 | void addCompositioncxx . . $ TRole#addComposition(f4bd9ed7cc6f2913). ( const DLTreecxx . . $ DLTree#* tree ) |
| 439 | { |
| 440 | TRoleVeccxx . . $ TRole#TRoleVec# RScxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 441 | fillsCompositioncxx . . $ TRole#fillsComposition(5530ca12088eea1). ( RS, tree ); |
| 442 | subCompositionscxx . . $ TRole#subCompositions..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(RS); |
| 443 | } |
| 444 | /// get access to a RA for the role |
| 445 | const RoleAutomatoncxx . . $ RoleAutomaton#& getAutomatoncxx . . $ TRole#getAutomaton(63b0d77ccf579a4). ( void ) const { return Acxx . . $ TRole#A.; } |
| 446 | |
| 447 | // completing internal constructions |
| 448 | |
| 449 | /// eliminate told role cycle |
| 450 | TRolecxx . . $ TRole#* eliminateToldCyclescxx . . $ TRole#eliminateToldCycles(6cda9dc08d29302e). ( void ) |
| 451 | { |
| 452 | TRoleSetcxx . . $ TRole#TRoleSet# RInProcesscxx . . $ std/set#set(49f6e7a06ebc5aa8).; |
| 453 | TRoleVeccxx . . $ TRole#TRoleVec# ToldSynonymscxx . . $ std/vector#vector(49f6e7a06ebc5aa8).; |
| 454 | return eliminateToldCyclescxx . . $ TRole#eliminateToldCycles(da3b35d3ecb922e7). ( RInProcess, ToldSynonyms ); |
| 455 | } |
| 456 | /// init ancestors and descendants using Taxonomy |
| 457 | void initADbyTaxonomycxx . . $ TRole#initADbyTaxonomy(739d502f68d79167). ( Taxonomycxx . . $ Taxonomy#* pTax, size_tcxx . . $ size_t# ADMapSize ); |
| 458 | /// init other fields that requires Anc/Desc for all roles |
| 459 | void postProcesscxx . . $ TRole#postProcess(49f6e7a06ebc5aa8). ( void ); |
| 460 | /// fills role composition by given TREE |
| 461 | void fillsCompositioncxx . . $ TRole#fillsComposition(5530ca12088eea1). ( TRoleVeccxx . . $ TRole#TRoleVec#& Composition, const DLTreecxx . . $ DLTree#* tree ) const; |
| 462 | /// complete role automaton |
| 463 | void completeAutomatoncxx . . $ TRole#completeAutomaton(2c44cd906ae4e829). ( size_tcxx . . $ std/size_t# nRoles ) |
| 464 | { |
| 465 | TRoleSetcxx . . $ TRole#TRoleSet# RInProcesscxx . . $ std/set#set(49f6e7a06ebc5aa8).; |
| 466 | completeAutomatoncxx . . $ TRole#completeAutomaton(3cce881a86f6be27).(RInProcess); |
| 467 | Acxx . . $ TRole#A..setupcxx . . $ RoleAutomaton#setup(62a5225ebb2f873). ( nRoles, isDataRolecxx . . $ TRole#isDataRole(50ce9a9e25b4a850).() ); |
| 468 | } |
| 469 | /// check whether role description is consistent |
| 470 | void consistentcxx . . $ TRole#consistent(83f5f38750778ac8). ( void ) const |
| 471 | { |
| 472 | if ( isSimplecxx . . $ TRole#isSimple(50ce9a9e25b4a850).() ) // all simple roles are consistent |
| 473 | return; |
| 474 | if ( isFunctionalcxx . . $ TRole#isFunctional(50ce9a9e25b4a850).() ) // non-simple role can not be functional |
| 475 | throw EFPPNonSimpleRolecxx . . $ EFPPNonSimpleRole#(getNamecxx . . $ TNamedEntry#getName(a9f41ea0e82d88cf).()); |
| 476 | if ( isDataRolecxx . . $ TRole#isDataRole(50ce9a9e25b4a850).() ) // data role can not be non-simple |
| 477 | throw EFPPNonSimpleRolecxx . . $ EFPPNonSimpleRole#(getNamecxx . . $ TNamedEntry#getName(a9f41ea0e82d88cf).()); |
| 478 | if ( isDisjointcxx . . $ TRole#isDisjoint(50ce9a9e25b4a850).() ) // non-simple role can not be disjoint with any role |
| 479 | throw EFPPNonSimpleRolecxx . . $ EFPPNonSimpleRole#EFPPNonSimpleRole(9c546c94e5fcce4e).(getNamecxx . . $ TNamedEntry#getName(a9f41ea0e82d88cf).()); |
| 480 | } |
| 481 | |
| 482 | // output |
| 483 | |
| 484 | /// print role to given stream |
| 485 | void Printcxx . . $ TRole#Print(490063bd7e6d8d5d). ( stdcxx . . $ std/::ostreamcxx . . $ std/ostream#& o ) const override; |
| 486 | |
| 487 | // save/load interface; implementation is in SaveLoad.cpp |
| 488 | |
| 489 | /// save entry |
| 490 | void Savecxx . . $ TRole#Save(aaac402dd6f8bcf7). ( SaveLoadManagercxx . . $ SaveLoadManager#& m ) const override; |
| 491 | /// load entry |
| 492 | void Loadcxx . . $ TRole#Load(da67b8e43f9c9b96). ( SaveLoadManagercxx . . $ SaveLoadManager#& m ) override; |
| 493 | }; // TRole |
| 494 | |
| 495 | /// @return R or -R for T in the form (inv ... (inv R)...) |
| 496 | inline |
| 497 | TRolecxx . . $ TRole#* |
| 498 | resolveRoleHelpercxx . . $ resolveRoleHelper(c256d257f6e22050). ( const DLTreecxx . . $ DLTree#* t ) |
| 499 | { |
| 500 | if ( t == nullptr ) // empty tree -- error |
| 501 | throw EFaCTPlusPluscxx . . $ EFaCTPlusPlus#("Role expression expected"); |
| 502 | switch ( t->Elementcxx . . $ TsTTree#Element(ea465e50d690edfe).().getTokencxx . . $ TLexeme#getToken(d71a1020745f3953).() ) |
| 503 | { |
| 504 | case RNAMEcxx . . $ RNAME.: // role name |
| 505 | case DNAMEcxx . . $ DNAME.: // data role name |
| 506 | return static_cast<TRolecxx . . $ TRole#*>(t->Elementcxx . . $ TsTTree#Element(ea465e50d690edfe).().getNEcxx . . $ TLexeme#getNE(28c03b9fd3c689f8).()); |
| 507 | case INVcxx . . $ INV.: // inversion |
| 508 | return resolveRoleHelpercxx . . $ resolveRoleHelper(c256d257f6e22050).(t->Leftcxx . . $ TsTTree#Left(f4b2f47551fb31d7).())->inversecxx . . $ TRole#inverse(6cda9dc08d29302e).(); |
| 509 | default: // error |
| 510 | throw EFaCTPlusPluscxx . . $ EFaCTPlusPlus#("Invalid role expression"); |
| 511 | } |
| 512 | } |
| 513 | |
| 514 | /// @return R or -R for T in the form (inv ... (inv R)...); remove synonyms |
| 515 | inline TRolecxx . . $ TRole#* resolveRolecxx . . $ resolveRole(c256d257f6e22050). ( const DLTreecxx . . $ DLTree#* t ) { return resolveSynonymcxx . . $ resolveSynonym(98ea26de6545f0ca).(resolveRoleHelpercxx . . $ resolveRoleHelper(c256d257f6e22050).(t)); } |
| 516 | |
| 517 | //-------------------------------------------------- |
| 518 | // TRole implementation |
| 519 | //-------------------------------------------------- |
| 520 | inline TRolecxx . . $ TRole# :: TRolecxx . . $ TRole#TRole(9c546c94e5fcce4e). ( const stdcxx . . $ std/::stringcxx . . $ std/string#& name ) |
| 521 | : ClassifiableEntrycxx . . $ ClassifiableEntry#(name) |
| 522 | { |
| 523 | setCompletelyDefinedcxx . . $ ClassifiableEntry#setCompletelyDefined(b45ddcbc8423892c). (true); // role hierarchy is completely defined by it's parents |
| 524 | addTrivialTransitioncxx . . $ TRole#addTrivialTransition(67b1ad1f11addbc2). (this); |
| 525 | } |
| 526 | |
| 527 | inline TRolecxx . . $ TRole# :: ~cxx . . $ TRole#`~TRole`(49f6e7a06ebc5aa8).TRolecxx . . $ TRole#() |
| 528 | { |
| 529 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(pDomaincxx . . $ TRole#pDomain.); |
| 530 | deleteTreecxx . . $ deleteTree(c5beffd064a5e5b2).(pSpecialDomaincxx . . $ TRole#pSpecialDomain.); |
| 531 | if ( Inversecxx . . $ TRole#Inverse. != nullptr && Inversecxx . . $ TRole#Inverse. != this ) |
| 532 | { |
| 533 | Inversecxx . . $ TRole#Inverse.->Inversecxx . . $ TRole#Inverse. = nullptr; |
| 534 | delete Inversecxx . . $ TRole#Inverse.; |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | //-------------------------------------------------- |
| 539 | // RAStateTransitions implementation depending on TRole |
| 540 | //-------------------------------------------------- |
| 541 | |
| 542 | /// check whether one of the transitions accept R |
| 543 | inline bool |
| 544 | RAStateTransitionscxx . . $ RAStateTransitions# :: recognisecxx . . $ RAStateTransitions#recognise(81d69a9c8508a392). ( const TRolecxx . . $ TRole#* R ) const { return R != nullptr && R->isDataRolecxx . . $ TRole#isDataRole(50ce9a9e25b4a850).() == DataRolecxx . . $ RAStateTransitions#DataRole. && ApplicableRolescxx . . $ RAStateTransitions#ApplicableRoles..incxx . . $ TFastSet#in(8877ebe272b9620d).(R->getIndexcxx . . $ TRole#getIndex(ddd8539a2fcdd4ce).()); } |
| 545 | |
| 546 | #endif |