Debian Codegraph @

FaCT++.Python/lib/Kernel/LocalityChecker.h

raw symbols SCIP
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_H
22
23 #include "tSignature.h"
24 #include "ModuleMethod.h"
25 #include "tDLAxiom.h"
26
27 /// helper class to set signature and locality class
28 class SigAccessor
29 {
30 protected: // members
31 /// signature of a module
32 const TSignature* sig;
33
34 public: // interface
35 /// init c'tor
36 explicit SigAccessor ( const TSignature* s ) : sig(s) {}
37 /// empty d'tor
38 virtual ~SigAccessor() = default;
39
40 // locality flags
41
42 /// @return true iff concepts not in the signature are treated as TOPs
43 bool topCLocal ( void ) const { return sig->topCLocal(); }
44 /// @return true iff concepts not in the signature are treated as BOTTOMs
45 bool botCLocal ( void ) const { return !topCLocal(); }
46 /// @return true iff roles not in the signature are treated as TOPs
47 bool topRLocal ( void ) const { return sig->topRLocal(); }
48 /// @return true iff roles not in the signature are treated as BOTTOMs
49 bool botRLocal ( void ) const { return !topRLocal(); }
50
51 // signature-based calls
52 /// @return the signature
53 const TSignature* getSignature ( void ) const { return sig; }
54 /// @return true iff SIGnature does NOT contain given entity
55 bool nc ( const TNamedEntity* entity ) const { return !sig->contains(entity); }
56 }; // SigAccessor
57
58 /// base class for checking locality of a DL axiom
59 class LocalityChecker: protected SigAccessor, public DLAxiomVisitor
60 {
61 protected: // members
62 /// remember the axiom locality value here
63 bool isLocal = true;
64
65 public: // interface
66 /// init c'tor
67 explicit LocalityChecker ( const TSignature* s ) : SigAccessor(s) {}
68
69 /// @return true iff an AXIOM is local wrt signature
70 bool local ( const TDLAxiom* axiom )
71 {
72 axiom->accept(*this);
73 return isLocal;
74 }
75 /// fake method to match the semantic checker's interface
76 virtual void preprocessOntology ( const AxiomVec& ) {}
77 /// set a new value of a signature (without changing a locality parameters)
78 void setSignatureValue ( const TSignature& Sig )
79 {
80 TSignature* curSig = const_cast<TSignature*>(sig);
81 // bool topC = topCLocal(), topR = topRLocal();
82 *curSig = Sig;
83 // curSig->setLocality ( topC, topR );
84 }
85 }; // LocalityChecker
86
87 /// @return a locality checker corresponding to a given method
88 extern LocalityChecker* createLocalityChecker ( ModuleMethod moduleMethod, TSignature* pSig );
89
90 #endif