Debian Codegraph @

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

raw symbols SCIP
1 /* This file is part of the FaCT++ DL reasoner
2 Copyright (C) 2015-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 TAXGATHERINGWALKER_H
21 #define TAXGATHERINGWALKER_H
22
23 #include "WalkerInterface.h"
24 #include "taxVertex.h"
25
26 /// taxonomy walkers that gathers all the relevant nodes
27 class TaxGatheringWalker : public WalkerInterface
28 {
29 protected: // members
30 /// vertices that satisfy the condition
31 std::vector<const TaxonomyVertex*> found;
32
33 protected: // methods
34 /// check whether actor is applicable to the ENTRY
35 virtual bool applicable ( const ClassifiableEntry* entry ) const = 0;
36 /// @return true iff current entry is visible
37 bool tryEntry ( const ClassifiableEntry* p ) const { return !p->isSystem() && applicable(p); }
38 /// @return true if at least one entry of a vertex V is visible
39 bool tryVertex ( const TaxonomyVertex& v ) const
40 {
41 if ( tryEntry(v.getPrimer()) )
42 return true;
43 for ( const auto& synonym: v.synonyms() )
44 if ( tryEntry(synonym) )
45 return true;
46 return false;
47 }
48
49 public: // interface
50 /// clear found
51 virtual void clear ( void ) { found.clear(); }
52
53 /// taxonomy walking method.
54 /// @return true if node was processed
55 /// @return false if node can not be processed in current settings
56 bool apply ( const TaxonomyVertex& v ) override
57 {
58 if ( tryVertex(v) )
59 {
60 found.push_back(&v);
61 return true;
62 }
63 return false;
64 }
65 }; // TaxGatheringWalker
66
67 #endif