Debian Codegraph @

Kernel/taxNamEntry.h

raw symbols SCIP
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 TAXNAMENTRY_H
21 #define TAXNAMENTRY_Hcxx . . $ `Kernel/taxNamEntry.h:21:9`!
22
23 #include <vector>
24
25 #include "fpp_assert.h"cxx . . $ `<file>/Kernel/fpp_assert.h`/
26 #include "tNamedEntry.h"cxx . . $ `<file>/Kernel/tNamedEntry.h`/
27 #include "globaldef.h"cxx . . $ `<file>/Kernel/globaldef.h`/
28
29 class TaxonomyVertexcxx . . $ TaxonomyVertex#;
30
31 class ClassifiableEntrycxx . . $ ClassifiableEntry# : public TNamedEntrycxx . . $ TNamedEntry#
32 {
33 public: // type definitions
34 /// type for the set of told subsumers
35 typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<ClassifiableEntrycxx . . $ ClassifiableEntry#*> linkSetcxx . . $ ClassifiableEntry#linkSet#;
36 /// told subsumers RW iterator
37 typedef linkSetcxx . . $ ClassifiableEntry#linkSet#::iteratorcxx . . $ std/vector#iterator# iteratorcxx . . $ ClassifiableEntry#iterator#;
38 /// told subsumers RO iterator
39 typedef linkSetcxx . . $ ClassifiableEntry#linkSet#::const_iteratorcxx . . $ std/vector#const_iterator# const_iteratorcxx . . $ ClassifiableEntry#const_iterator#;
40
41 protected: // members
42 /// link to taxonomy entry for current entry
43 TaxonomyVertexcxx . . $ TaxonomyVertex#* taxVertexcxx . . $ ClassifiableEntry#taxVertex. = nullptr;
44 /// links to 'told subsumers' (entries that are direct super-entries for current)
45 linkSetcxx . . $ ClassifiableEntry#linkSet# toldSubsumerscxx . . $ ClassifiableEntry#toldSubsumers.;
46 /// pointer to synonym (entry which contains whole information the same as current)
47 ClassifiableEntrycxx . . $ ClassifiableEntry#* pSynonymcxx . . $ ClassifiableEntry#pSynonym. = nullptr;
48 /// index as a vertex in the SubsumptionMap/model cache
49 unsigned int Indexcxx . . $ ClassifiableEntry#Index. = 0;
50
51 public: // interface
52 /// C'tor
53 explicit ClassifiableEntrycxx . . $ ClassifiableEntry#ClassifiableEntry(9c546c94e5fcce4e). ( const stdcxx . . $ std/::stringcxx . . $ std/string#& name ) : TNamedEntrycxx . . $ TNamedEntry#TNamedEntry(9c546c94e5fcce4e).(name) {}
54 /// no copy c'tor
55 ClassifiableEntrycxx . . $ ClassifiableEntry#ClassifiableEntry(2bad4e6d36c97c7c). ( const ClassifiableEntrycxx . . $ ClassifiableEntry#& ) = delete;
56 /// no assignment
57 ClassifiableEntrycxx . . $ ClassifiableEntry#& operatorcxx . . $ ClassifiableEntry#`operator=`(90034bce4b18efab). = ( const ClassifiableEntrycxx . . $ ClassifiableEntry#& ) = delete;
58
59 // taxonomy entry access
60
61 /// is current entry classified
62 bool isClassifiedcxx . . $ ClassifiableEntry#isClassified(50ce9a9e25b4a850). ( void ) const { return ( taxVertexcxx . . $ ClassifiableEntry#taxVertex. != nullptr ); }
63 /// set up given entry
64 void setTaxVertexcxx . . $ ClassifiableEntry#setTaxVertex(ea5ea6ad7488bb8a). ( TaxonomyVertexcxx . . $ TaxonomyVertex#* vertex ) { taxVertexcxx . . $ ClassifiableEntry#taxVertex. = vertex; }
65 /// get taxonomy vertex of the entry
66 TaxonomyVertexcxx . . $ TaxonomyVertex#* getTaxVertexcxx . . $ ClassifiableEntry#getTaxVertex(16f9ca5fa66f7d36). ( void ) const { return taxVertexcxx . . $ ClassifiableEntry#taxVertex.; }
67
68 // completely defined interface
69
70 /// register a Completely Defined flag
71 FPP_ADD_FLAGcxx . . $ ClassifiableEntry#isCompletelyDefined(50ce9a9e25b4a850).(CompletelyDefined,0x2);
72 /// register a non-classifiable flag
73 FPP_ADD_FLAGcxx . . $ Flags#clearFlag(cb2f890c2fdad230).(NonClassifiable,0x4);
74
75 // told subsumers interface
76
77 /// RW access to the told subsumers
78 linkSetcxx . . $ ClassifiableEntry#linkSet#& toldcxx . . $ ClassifiableEntry#told(e7230ad44187fae2). ( void ) { return toldSubsumerscxx . . $ ClassifiableEntry#toldSubsumers.; }
79 /// RO access to the told subsumers
80 const linkSetcxx . . $ ClassifiableEntry#linkSet#& toldcxx . . $ ClassifiableEntry#told(a87ab321af60e1aa). ( void ) const { return toldSubsumerscxx . . $ ClassifiableEntry#toldSubsumers.; }
81
82 /// check whether the entry has any TS
83 bool hasToldSubsumerscxx . . $ ClassifiableEntry#hasToldSubsumers(50ce9a9e25b4a850). ( void ) const { return !toldSubsumerscxx . . $ ClassifiableEntry#toldSubsumers..emptycxx . . $ std/vector#empty(50ce9a9e25b4a850).(); }
84 /// add told subsumer of entry (duplications possible)
85 void addParentcxx . . $ ClassifiableEntry#addParent(866fbb357e35bef0). ( ClassifiableEntrycxx . . $ ClassifiableEntry#* parent ) { toldSubsumerscxx . . $ ClassifiableEntry#toldSubsumers..push_backcxx . . $ std/vector#push_back(77d9f17553126ecb). (parent); }
86 /// add told subsumer if doesn't already recorded
87 void addParentIfNewcxx . . $ ClassifiableEntry#addParentIfNew(866fbb357e35bef0). ( ClassifiableEntrycxx . . $ ClassifiableEntry#* parent );
88 /// add all parents (with duplicates) from given container to current node
89 template <typename Container>
90 void addParentscxx . . $ ClassifiableEntry#addParents(77d9f17553126ecb). ( const Container& parents )
91 {
92 for ( auto& parent: parents )
93 addParentIfNewcxx . . $ ClassifiableEntry#addParentIfNew(866fbb357e35bef0).(parent);
94 }
95
96 // index interface
97
98 /// get the index value
99 unsigned int indexcxx . . $ ClassifiableEntry#index(ddd8539a2fcdd4ce). ( void ) const { return Indexcxx . . $ ClassifiableEntry#Index.; }
100 /// set the index value
101 void setIndexcxx . . $ ClassifiableEntry#setIndex(cb2f890c2fdad230). ( unsigned int ind ) { Indexcxx . . $ ClassifiableEntry#Index. = ind; }
102
103 // synonym interface
104
105 /// check if current entry is a synonym
106 bool isSynonymcxx . . $ ClassifiableEntry#isSynonym(50ce9a9e25b4a850). ( void ) const { return (pSynonymcxx . . $ ClassifiableEntry#pSynonym. != nullptr); }
107 /// get synonym of current entry
108 ClassifiableEntrycxx . . $ ClassifiableEntry#* getSynonymcxx . . $ ClassifiableEntry#getSynonym(106bdcbfaabaf9a3). ( void ) const { return pSynonymcxx . . $ ClassifiableEntry#pSynonym.; }
109 /// make sure that synonym's representative is not a synonym itself
110 void canonicaliseSynonymcxx . . $ ClassifiableEntry#canonicaliseSynonym(49f6e7a06ebc5aa8). ( void );
111 /// add entry's synonym
112 void setSynonymcxx . . $ ClassifiableEntry#setSynonym(866fbb357e35bef0). ( ClassifiableEntrycxx . . $ ClassifiableEntry#* syn )
113 {
114 fpp_assertcxx . . $ ClassifiableEntry#pSynonym. ( pSynonym == nullptr ); // do it only once
115 pSynonymcxx . . $ ClassifiableEntry#pSynonym. = syn;
116 canonicaliseSynonymcxx . . $ ClassifiableEntry#canonicaliseSynonym(49f6e7a06ebc5aa8).();
117 }
118
119 /// if two synonyms are in 'told' list, merge them
120 void removeSynonymsFromParentscxx . . $ ClassifiableEntry#removeSynonymsFromParents(49f6e7a06ebc5aa8). ( void )
121 {
122 linkSetcxx . . $ ClassifiableEntry#linkSet# copycxx . . $ std/vector#vector(49f6e7a06ebc5aa8).;
123 copy.swapcxx . . $ std/vector#swap(a8be04fc17cbdf49).(toldSubsumerscxx . . $ ClassifiableEntry#toldSubsumers.);
124 addParentscxx . . $ ClassifiableEntry#addParents(77d9f17553126ecb).(copy);
125 }
126 }; // ClassifiableEntry
127
128 /// general RW resolving synonym operator
129 template <typename T>
130 inline T*
131 resolveSynonymcxx . . $ resolveSynonym(98ea26de6545f0ca). ( T* p )
132 {
133 return !p ? nullptr : p->isSynonym() ? resolveSynonymcxx . . $ resolveSynonym(98ea26de6545f0ca).(static_cast<T*>(p->getSynonym())) : p;
134 }
135
136 /// general RO resolving synonym operator
137 template <typename T>
138 inline const T*
139 resolveSynonymcxx . . $ resolveSynonym(bd9f52c6ae4be57a). ( const T* p )
140 {
141 return !p ? nullptr : p->isSynonym() ? resolveSynonymcxx . . $ resolveSynonym(98ea26de6545f0ca).(static_cast<const T*>(p->getSynonym())) : p;
142 }
143
144 /// make sure that synonym's representative is not a synonym itself
145 inline void
146 ClassifiableEntrycxx . . $ ClassifiableEntry# :: canonicaliseSynonymcxx . . $ ClassifiableEntry#canonicaliseSynonym(49f6e7a06ebc5aa8). ( void )
147 {
148 fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`!(isSynonym());
149 pSynonymcxx . . $ ClassifiableEntry#pSynonym. = resolveSynonymcxx . . $ resolveSynonym(98ea26de6545f0ca).(pSynonymcxx . . $ ClassifiableEntry#pSynonym.);
150 }
151
152
153 inline void
154 ClassifiableEntrycxx . . $ ClassifiableEntry# :: addParentIfNewcxx . . $ ClassifiableEntry#addParentIfNew(866fbb357e35bef0). ( ClassifiableEntrycxx . . $ ClassifiableEntry#* parent )
155 {
156 // resolve synonyms
157 parent = resolveSynonymcxx . . $ resolveSynonym(98ea26de6545f0ca).(parent);
158
159 // node can not be its own parent
160 if ( parent == this )
161 return;
162
163 // check if such entry already exists
164 for ( const auto& p: toldcxx . . $ ClassifiableEntry#told(e7230ad44187fae2).() )
165 if ( parent == p )
166 return;
167
168 addParentcxx . . $ ClassifiableEntry#addParent(866fbb357e35bef0).(parent);
169 }
170
171 #endif // TAXNAMENTRY_H