Debian Codegraph @

Kernel/tSignature.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 TSIGNATURE_H
21 #define TSIGNATURE_Hcxx . . $ `Kernel/tSignature.h:21:9`!
22
23 #include <set>
24 #include <algorithm>
25 #include <iterator>
26
27 #include "tDLExpression.h"cxx . . $ `<file>/Kernel/tDLExpression.h`/
28
29 /// class to hold the signature of a module
30 class TSignaturecxx . . $ TSignature#
31 {
32 public: // types
33 /// set of entities as a base underlying type os a signature
34 typedef stdcxx . . $ std/::setcxx . . $ std/set#<const TNamedEntitycxx . . $ TNamedEntity#*> BaseTypecxx . . $ TSignature#BaseType#;
35 /// RO iterator over a set of entities
36 typedef BaseTypecxx . . $ TSignature#BaseType#::const_iteratorcxx . . $ std/set#const_iterator# iteratorcxx . . $ TSignature#iterator#;
37
38 protected: // members
39 /// set to keep all the elements in signature
40 BaseTypecxx . . $ TSignature#BaseType# Setcxx . . $ TSignature#Set.;
41 /// true if concept TOP-locality; false if concept BOTTOM-locality
42 bool topCLocalitycxx . . $ TSignature#topCLocality. = false;
43 /// true if role TOP-locality; false if role BOTTOM-locality
44 bool topRLocalitycxx . . $ TSignature#topRLocality. = false;
45
46 protected: // methods
47 /// @return true if *THIS \subseteq SIG (\subset if IMPROPER = false )
48 bool subsetcxx . . $ TSignature#subset(5ad63fac213bd309). ( const TSignaturecxx . . $ TSignature#& sig, bool improper ) const
49 {
50 iteratorcxx . . $ TSignature#iterator# p = Setcxx . . $ TSignature#Set..begincxx . . $ std/set#begin(a1617ab40ea76896).(), p_end = Setcxx . . $ TSignature#Set..endcxx . . $ std/set#end(a1617ab40ea76896).(), q = sig.Setcxx . . $ TSignature#Set..begincxx . . $ std/set#begin(a1617ab40ea76896).(), q_end = sig.Setcxx . . $ TSignature#Set..endcxx . . $ std/set#end(a1617ab40ea76896).();
51 bool proper = false;
52 while ( p !=cxx . . $ std/`operator!=`(7e1308a0738ea758). p_end && q !=cxx . . $ std/`operator!=`(7e1308a0738ea758). q_end )
53 {
54 if ( *cxx . . $ std/_Rb_tree_const_iterator#`operator*`(ea465e50d690edfe).p < *cxx . . $ std/_Rb_tree_const_iterator#`operator*`(ea465e50d690edfe).q ) // something in THIS doesn't exist in SIG
55 return false;
56 if ( *cxx . . $ std/_Rb_tree_const_iterator#`operator*`(ea465e50d690edfe).q < *cxx . . $ std/_Rb_tree_const_iterator#`operator*`(ea465e50d690edfe).p )
57 ++cxx . . $ std/_Rb_tree_const_iterator#operator++(998dce1072ed46d4).q, proper = true;
58 else
59 ++cxx . . $ std/_Rb_tree_const_iterator#operator++(998dce1072ed46d4).p, ++cxx . . $ std/_Rb_tree_const_iterator#operator++(998dce1072ed46d4).q;
60 }
61 if ( p !=cxx . . $ std/`operator!=`(7e1308a0738ea758). p_end ) // extra stuff in THIS
62 return false;
63 // here THIS is empty
64 if ( q !=cxx . . $ std/`operator!=`(7e1308a0738ea758). q_end ) // there are extra elements in SIG
65 return improper;
66 // both are done; the answer depends on flags
67 return improper ? true : proper;
68 }
69
70 public: // interface
71 // add names to signature
72
73 /// add pointer to named object to signature
74 void addcxx . . $ TSignature#add(70f9d3c046cd5911). ( const TNamedEntitycxx . . $ TNamedEntity#* p ) { Setcxx . . $ TSignature#Set..insertcxx . . $ std/set#insert(411a10a755068dfe).(p); }
75 /// add set of named entities to signature
76 void addcxx . . $ TSignature#add(ff73ca49864ce7be). ( const BaseTypecxx . . $ TSignature#BaseType#& aSet ) { Setcxx . . $ TSignature#Set..insertcxx . . $ std/set#insert(50ef72ff69bc573d). ( aSet.begincxx . . $ std/set#begin(a1617ab40ea76896).(), aSet.endcxx . . $ std/set#end(a1617ab40ea76896).() ); }
77 /// add another signature to a given one
78 void addcxx . . $ TSignature#add(7393b46d99f9f765). ( const TSignaturecxx . . $ TSignature#& Sig ) { addcxx . . $ TSignature#add(ff73ca49864ce7be).(Sig.Setcxx . . $ TSignature#Set.); }
79 /// remove given element from a signature
80 void removecxx . . $ TSignature#remove(70f9d3c046cd5911). ( const TNamedEntitycxx . . $ TNamedEntity#* p ) { Setcxx . . $ TSignature#Set..erasecxx . . $ std/set#erase(3a53bfe100edb289).(p); }
81 /// set new locality polarity
82 void setLocalitycxx . . $ TSignature#setLocality(b0b38cda41d4ede4). ( bool topC, bool topR ) { topCLocalitycxx . . $ TSignature#topCLocality. = topC; topRLocalitycxx . . $ TSignature#topRLocality. = topR; }
83 /// set new locality polarity
84 void setLocalitycxx . . $ TSignature#setLocality(b45ddcbc8423892c). ( bool top ) { setLocalitycxx . . $ TSignature#setLocality(b0b38cda41d4ede4). ( top, top ); }
85
86 // comparison
87
88 /// check whether 2 signatures are the same
89 bool operatorcxx . . $ TSignature#`operator==`(43d48a6c9e0dae9c). == ( const TSignaturecxx . . $ TSignature#& sig ) const { return Setcxx . . $ TSignature#Set. ==cxx . . $ std/`operator==`(c27708345ce5fd4e). sig.Setcxx . . $ TSignature#Set.; }
90 /// check whether 2 signatures are different
91 bool operatorcxx . . $ TSignature#`operator!=`(43d48a6c9e0dae9c). != ( const TSignaturecxx . . $ TSignature#& sig ) const { return Setcxx . . $ TSignature#Set. !=cxx . . $ std/`operator!=`(c27708345ce5fd4e). sig.Setcxx . . $ TSignature#Set.; }
92 /// @return true if *THIS \subset SIG
93 bool operatorcxx . . $ TSignature#`operator<`(43d48a6c9e0dae9c). < ( const TSignaturecxx . . $ TSignature#& sig ) const { return subsetcxx . . $ TSignature#subset(5ad63fac213bd309). ( sig, /*improper=*/false ); }
94 /// @return true if *THIS \subseteq SIG
95 bool operatorcxx . . $ TSignature#`operator<=`(43d48a6c9e0dae9c). <= ( const TSignaturecxx . . $ TSignature#& sig ) const { return subsetcxx . . $ TSignature#subset(5ad63fac213bd309). ( sig, /*improper=*/true ); }
96 /// @return true if SIG \subset *THIS
97 bool operatorcxx . . $ TSignature#`operator>`(43d48a6c9e0dae9c). > ( const TSignaturecxx . . $ TSignature#& sig ) const { return sig.subsetcxx . . $ TSignature#subset(5ad63fac213bd309). ( *this, /*improper=*/false ); }
98 /// @return true if SIG \subseteq *THIS
99 bool operatorcxx . . $ TSignature#`operator>=`(43d48a6c9e0dae9c). >= ( const TSignaturecxx . . $ TSignature#& sig ) const { return sig.subsetcxx . . $ TSignature#subset(5ad63fac213bd309). ( *this, /*improper=*/true ); }
100 /// @return true iff signature contains given element
101 bool containscxx . . $ TSignature#contains(d552066cd41c9e94). ( const TNamedEntitycxx . . $ TNamedEntity#* p ) const { return Setcxx . . $ TSignature#Set..countcxx . . $ std/set#count(a9c5b6ffd713dfa6).(p) > 0; }
102 /// @return true iff signature contains given element
103 bool containscxx . . $ TSignature#contains(64b4860e9cff6d89). ( const TDLExpressioncxx . . $ TDLExpression#* p ) const
104 {
105 if ( const TNamedEntitycxx . . $ TNamedEntity#* e = dynamic_cast<const TNamedEntitycxx . . $ TNamedEntity#*>(p) )
106 return containscxx . . $ TSignature#contains(d552066cd41c9e94).(e);
107 if ( const TDLObjectRoleInversecxx . . $ TDLObjectRoleInverse#* inv = dynamic_cast<const TDLObjectRoleInversecxx . . $ TDLObjectRoleInverse#*>(p) )
108 return containscxx . . $ TSignature#contains(64b4860e9cff6d89).(inv->getORcxx . . $ TObjectRoleArg#getOR(b0a963b5b1b1e1ae).());
109
110 return false;
111 }
112 /// @return size of the signature
113 size_t sizecxx . . $ TSignature#size(fe4d2d262d4164a8). ( void ) const { return Setcxx . . $ TSignature#Set..sizecxx . . $ std/set#size(68cb71549629d77b).(); }
114 /// clear the signature
115 void clearcxx . . $ TSignature#clear(49f6e7a06ebc5aa8). ( void ) { Setcxx . . $ TSignature#Set..clearcxx . . $ std/set#clear(49f6e7a06ebc5aa8).(); }
116
117 /// RO access to the elements of signature
118 iteratorcxx . . $ TSignature#iterator# begincxx . . $ TSignature#begin(e7f351f2dad9f44a). ( void ) const { return Setcxx . . $ TSignature#Set..begincxx . . $ std/set#begin(a1617ab40ea76896).(); }
119 /// RO access to the elements of signature
120 iteratorcxx . . $ TSignature#iterator# endcxx . . $ TSignature#end(e7f351f2dad9f44a). ( void ) const { return Setcxx . . $ TSignature#Set..endcxx . . $ std/set#end(a1617ab40ea76896).(); }
121
122 /// @return true iff concepts are treated as TOPs
123 bool topCLocalcxx . . $ TSignature#topCLocal(50ce9a9e25b4a850). ( void ) const { return topCLocalitycxx . . $ TSignature#topCLocality.; }
124 /// @return true iff concepts are treated as BOTTOMs
125 bool botCLocalcxx . . $ TSignature#botCLocal(50ce9a9e25b4a850). ( void ) const { return !topCLocalitycxx . . $ TSignature#topCLocality.; }
126 /// @return true iff roles are treated as TOPs
127 bool topRLocalcxx . . $ TSignature#topRLocal(50ce9a9e25b4a850). ( void ) const { return topRLocalitycxx . . $ TSignature#topRLocality.; }
128 /// @return true iff roles are treated as BOTTOMs
129 bool botRLocalcxx . . $ TSignature#botRLocal(50ce9a9e25b4a850). ( void ) const { return !topRLocalitycxx . . $ TSignature#topRLocality.; }
130 }; // TSignature
131
132 inline TSignaturecxx . . $ TSignature#::BaseTypecxx . . $ TSignature#BaseType#
133 intersectcxx . . $ intersect(22e0bdf079ecb149). ( const TSignaturecxx . . $ TSignature#& s1, const TSignaturecxx . . $ TSignature#& s2 )
134 {
135 TSignaturecxx . . $ TSignature#::BaseTypecxx . . $ TSignature#BaseType# retcxx . . $ std/set#set(49f6e7a06ebc5aa8).;
136 set_intersectioncxx . . $ std/set_intersection(385b6b6ffcd23ab9).(s1.begincxx . . $ TSignature#begin(e7f351f2dad9f44a).(), s1.endcxx . . $ TSignature#end(e7f351f2dad9f44a).(), s2.begincxx . . $ TSignature#begin(e7f351f2dad9f44a).(), s2.endcxx . . $ TSignature#end(e7f351f2dad9f44a).(), insertercxx . . $ std/inserter(cc902069f641a146).(ret, ret.begincxx . . $ std/set#begin(a1617ab40ea76896).()));
137 return retcxx . . $ std/set#set(f3bfeaebad815056).;
138 }
139
140 #endif