| 1 | /* This file is part of the FaCT++ DL reasoner |
| 2 | Copyright (C) 2011-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 LOCALITYCHECKER_H |
| 21 | #define LOCALITYCHECKER_Hcxx . . $ `Kernel/LocalityChecker.h:21:9`! |
| 22 | |
| 23 | #include "tSignature.h"cxx . . $ `<file>/Kernel/tSignature.h`/ |
| 24 | #include "ModuleMethod.h"cxx . . $ `<file>/Kernel/ModuleMethod.h`/ |
| 25 | #include "tDLAxiom.h"cxx . . $ `<file>/Kernel/tDLAxiom.h`/ |
| 26 | |
| 27 | /// helper class to set signature and locality class |
| 28 | class SigAccessorcxx . . $ SigAccessor# |
| 29 | { |
| 30 | protected: // members |
| 31 | /// signature of a module |
| 32 | const TSignaturecxx . . $ TSignature#* sigcxx . . $ SigAccessor#sig.; |
| 33 | |
| 34 | public: // interface |
| 35 | /// init c'tor |
| 36 | explicit SigAccessorcxx . . $ SigAccessor#SigAccessor(63821116a1afc694). ( const TSignaturecxx . . $ TSignature#* s ) : sigcxx . . $ SigAccessor#sig.(s) {} |
| 37 | /// empty d'tor |
| 38 | virtual ~cxx . . $ SigAccessor#`~SigAccessor`(49f6e7a06ebc5aa8).SigAccessorcxx . . $ SigAccessor#() = default; |
| 39 | |
| 40 | // locality flags |
| 41 | |
| 42 | /// @return true iff concepts not in the signature are treated as TOPs |
| 43 | bool topCLocalcxx . . $ SigAccessor#topCLocal(50ce9a9e25b4a850). ( void ) const { return sigcxx . . $ SigAccessor#sig.->topCLocalcxx . . $ TSignature#topCLocal(50ce9a9e25b4a850).(); } |
| 44 | /// @return true iff concepts not in the signature are treated as BOTTOMs |
| 45 | bool botCLocalcxx . . $ SigAccessor#botCLocal(50ce9a9e25b4a850). ( void ) const { return !topCLocalcxx . . $ SigAccessor#topCLocal(50ce9a9e25b4a850).(); } |
| 46 | /// @return true iff roles not in the signature are treated as TOPs |
| 47 | bool topRLocalcxx . . $ SigAccessor#topRLocal(50ce9a9e25b4a850). ( void ) const { return sigcxx . . $ SigAccessor#sig.->topRLocalcxx . . $ TSignature#topRLocal(50ce9a9e25b4a850).(); } |
| 48 | /// @return true iff roles not in the signature are treated as BOTTOMs |
| 49 | bool botRLocalcxx . . $ SigAccessor#botRLocal(50ce9a9e25b4a850). ( void ) const { return !topRLocalcxx . . $ SigAccessor#topRLocal(50ce9a9e25b4a850).(); } |
| 50 | |
| 51 | // signature-based calls |
| 52 | /// @return the signature |
| 53 | const TSignaturecxx . . $ TSignature#* getSignaturecxx . . $ SigAccessor#getSignature(2fd32eeecbb0ed7e). ( void ) const { return sigcxx . . $ SigAccessor#sig.; } |
| 54 | /// @return true iff SIGnature does NOT contain given entity |
| 55 | bool nccxx . . $ SigAccessor#nc(d552066cd41c9e94). ( const TNamedEntitycxx . . $ TNamedEntity#* entity ) const { return !sigcxx . . $ SigAccessor#sig.->containscxx . . $ TSignature#contains(d552066cd41c9e94).(entity); } |
| 56 | }; // SigAccessor |
| 57 | |
| 58 | /// base class for checking locality of a DL axiom |
| 59 | class LocalityCheckercxx . . $ LocalityChecker#: protected SigAccessorcxx . . $ SigAccessor#, public DLAxiomVisitorcxx . . $ DLAxiomVisitor# |
| 60 | { |
| 61 | protected: // members |
| 62 | /// remember the axiom locality value here |
| 63 | bool isLocalcxx . . $ LocalityChecker#isLocal. = true; |
| 64 | |
| 65 | public: // interface |
| 66 | /// init c'tor |
| 67 | explicit LocalityCheckercxx . . $ LocalityChecker#LocalityChecker(63821116a1afc694). ( const TSignaturecxx . . $ TSignature#* s ) : SigAccessorcxx . . $ SigAccessor#SigAccessor(63821116a1afc694).(s) {} |
| 68 | |
| 69 | /// @return true iff an AXIOM is local wrt signature |
| 70 | bool localcxx . . $ LocalityChecker#local(c12ce7eacb2f7daa). ( const TDLAxiomcxx . . $ TDLAxiom#* axiom ) |
| 71 | { |
| 72 | axiom->acceptcxx . . $ TDLAxiom#accept(9e2d550937cc1fea).(*this); |
| 73 | return isLocalcxx . . $ LocalityChecker#isLocal.; |
| 74 | } |
| 75 | /// fake method to match the semantic checker's interface |
| 76 | virtual void preprocessOntologycxx . . $ LocalityChecker#preprocessOntology(b963b3dd7533a896). ( const AxiomVeccxx . . $ AxiomVec#& ) {} |
| 77 | /// set a new value of a signature (without changing a locality parameters) |
| 78 | void setSignatureValuecxx . . $ LocalityChecker#setSignatureValue(7393b46d99f9f765). ( const TSignaturecxx . . $ TSignature#& Sig ) |
| 79 | { |
| 80 | TSignaturecxx . . $ TSignature#* curSig = const_cast<TSignaturecxx . . $ TSignature#*>(sigcxx . . $ SigAccessor#sig.); |
| 81 | // bool topC = topCLocal(), topR = topRLocal(); |
| 82 | *curSig =cxx . . $ TSignature#`operator=`(6f74423c3ed79251). Sig; |
| 83 | // curSig->setLocality ( topC, topR ); |
| 84 | } |
| 85 | }; // LocalityChecker |
| 86 | |
| 87 | /// @return a locality checker corresponding to a given method |
| 88 | extern LocalityCheckercxx . . $ LocalityChecker#* createLocalityCheckercxx . . $ createLocalityChecker(e4e24d5bf7d7495f). ( ModuleMethodcxx . . $ ModuleMethod# moduleMethod, TSignaturecxx . . $ TSignature#* pSig ); |
| 89 | |
| 90 | #endif |