| 1 | /* This file is part of the FaCT++ DL reasoner |
| 2 | Copyright (C) 2006-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 ACTOR_H |
| 21 | #define ACTOR_Hcxx . . $ `Kernel/Actor.h:21:9`! |
| 22 | |
| 23 | #include "taxVertex.h"cxx . . $ `<file>/Kernel/taxVertex.h`/ |
| 24 | #include "TaxGatheringWalker.h"cxx . . $ `<file>/Kernel/TaxGatheringWalker.h`/ |
| 25 | |
| 26 | /// class for acting with concept taxonomy |
| 27 | class Actorcxx . . $ Actor#: public TaxGatheringWalkercxx . . $ TaxGatheringWalker# |
| 28 | { |
| 29 | public: // types |
| 30 | /// entry in an output |
| 31 | typedef ClassifiableEntrycxx . . $ ClassifiableEntry# EntryTypecxx . . $ Actor#EntryType#; |
| 32 | /// 1D vector of entries |
| 33 | typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<const EntryTypecxx . . $ Actor#EntryType#*> Array1Dcxx . . $ Actor#Array1D#; |
| 34 | /// 2D vector of entries |
| 35 | typedef stdcxx . . $ std/::vectorcxx . . $ std/vector#<Array1Dcxx . . $ Actor#Array1D#> Array2Dcxx . . $ Actor#Array2D#; |
| 36 | |
| 37 | protected: // members |
| 38 | /// flag to look at concept-like or role-like entities |
| 39 | bool isRolecxx . . $ Actor#isRole. = false; |
| 40 | /// flag to look at concepts or object roles |
| 41 | bool isStandardcxx . . $ Actor#isStandard. = true; |
| 42 | |
| 43 | protected: // methods |
| 44 | /// check whether actor is applicable to the ENTRY |
| 45 | bool applicablecxx . . $ Actor#applicable(c2bbfa133def1eb7). ( const EntryTypecxx . . $ Actor#EntryType#* entry ) const override; |
| 46 | /// fills an array with all suitable data from the vertex |
| 47 | void fillArraycxx . . $ Actor#fillArray(992b4c6f18dee1c4). ( const TaxonomyVertexcxx . . $ TaxonomyVertex#& v, Array1Dcxx . . $ Actor#Array1D#& array ) const |
| 48 | { |
| 49 | if ( tryEntrycxx . . $ TaxGatheringWalker#tryEntry(c2bbfa133def1eb7).(v.getPrimercxx . . $ TaxonomyVertex#getPrimer(257357278432d96a).()) ) |
| 50 | array.push_backcxx . . $ std/vector#push_back(fe7a8a4d1eddb70).(v.getPrimercxx . . $ TaxonomyVertex#getPrimer(257357278432d96a).()); |
| 51 | for ( const auto& synonym: v.synonymscxx . . $ TaxonomyVertex#synonyms(c783afb9bc916663).() ) |
| 52 | if ( tryEntrycxx . . $ TaxGatheringWalker#tryEntry(c2bbfa133def1eb7).(synonym) ) |
| 53 | array.push_backcxx . . $ std/vector#push_back(77d9f17553126ecb).(synonym); |
| 54 | } |
| 55 | |
| 56 | public: // interface |
| 57 | /// empty c'tor |
| 58 | Actorcxx . . $ Actor#Actor(49f6e7a06ebc5aa8).() = default; |
| 59 | |
| 60 | // flags setup |
| 61 | |
| 62 | /// set the actor to look for classes |
| 63 | void needConceptscxx . . $ Actor#needConcepts(49f6e7a06ebc5aa8). ( void ) { isRolecxx . . $ Actor#isRole. = false; isStandardcxx . . $ Actor#isStandard. = true; } |
| 64 | /// set the actor to look for individuals |
| 65 | void needIndividualscxx . . $ Actor#needIndividuals(49f6e7a06ebc5aa8). ( void ) { isRolecxx . . $ Actor#isRole. = false; isStandardcxx . . $ Actor#isStandard. = false; } |
| 66 | /// set the actor to look for object properties |
| 67 | void needObjectRolescxx . . $ Actor#needObjectRoles(49f6e7a06ebc5aa8). ( void ) { isRolecxx . . $ Actor#isRole. = true; isStandardcxx . . $ Actor#isStandard. = true; } |
| 68 | /// set the actor to look for individuals |
| 69 | void needDataRolescxx . . $ Actor#needDataRoles(49f6e7a06ebc5aa8). ( void ) { isRolecxx . . $ Actor#isRole. = true; isStandardcxx . . $ Actor#isStandard. = false; } |
| 70 | |
| 71 | // fill structures according to what's in the taxonomy |
| 72 | |
| 73 | /// return data as a 1D-array |
| 74 | void getFoundDatacxx . . $ Actor#getFoundData(7301126fd2b39f45). ( Array1Dcxx . . $ Actor#Array1D#& array ) const |
| 75 | { |
| 76 | array.clearcxx . . $ std/vector#clear(49f6e7a06ebc5aa8).(); |
| 77 | for ( size_tcxx . . $ size_t# i = 0; i < foundcxx . . $ TaxGatheringWalker#found..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).(); i++ ) |
| 78 | fillArraycxx . . $ Actor#fillArray(992b4c6f18dee1c4). ( *foundcxx . . $ TaxGatheringWalker#found.[cxx . . $ std/vector#`operator[]`(b61e45a10b63f40a).i], array ); |
| 79 | } |
| 80 | /// return data as a 2D-array |
| 81 | void getFoundDatacxx . . $ Actor#getFoundData(93f0fa1f8e74edea). ( Array2Dcxx . . $ Actor#Array2D#& array ) const |
| 82 | { |
| 83 | array.clearcxx . . $ std/vector#clear(49f6e7a06ebc5aa8).(); |
| 84 | array.resizecxx . . $ std/vector#resize(2c44cd906ae4e829).(foundcxx . . $ TaxGatheringWalker#found..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).()); |
| 85 | for ( size_tcxx . . $ size_t# i = 0; i < foundcxx . . $ TaxGatheringWalker#found..sizecxx . . $ std/vector#size(fe4d2d262d4164a8).(); i++ ) |
| 86 | fillArraycxx . . $ Actor#fillArray(992b4c6f18dee1c4). ( *foundcxx . . $ TaxGatheringWalker#found.[cxx . . $ std/vector#`operator[]`(b61e45a10b63f40a).i], array[cxx . . $ std/vector#`operator[]`(428bb168810b9e52).i] ); |
| 87 | } |
| 88 | }; // Actor |
| 89 | |
| 90 | #endif |