| 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 TRELATED_H |
| 21 | #define TRELATED_H |
| 22 | |
| 23 | #include "tIndividual.h" |
| 24 | #include "tRole.h" |
| 25 | |
| 26 | /// class for represent individual relation <a,b>:R |
| 27 | class TRelated |
| 28 | { |
| 29 | public: // members |
| 30 | TIndividual* a = nullptr; |
| 31 | TIndividual* b = nullptr; |
| 32 | TRole* R = nullptr; |
| 33 | |
| 34 | public: // interface |
| 35 | /// empty c'tor |
| 36 | TRelated() = default; |
| 37 | /// init c'tor |
| 38 | TRelated ( TIndividual* a_, TIndividual* b_, TRole* R_ ) : a(a_), b(b_), R(R_) {} |
| 39 | /// copy c'tor |
| 40 | TRelated ( const TRelated& ) = default; |
| 41 | /// assignment |
| 42 | TRelated& operator = ( const TRelated& ) = default; |
| 43 | |
| 44 | /// simplify structure wrt synonyms |
| 45 | void simplify ( void ) |
| 46 | { |
| 47 | R = resolveSynonym(R); |
| 48 | a = resolveSynonym(a); |
| 49 | b = resolveSynonym(b); |
| 50 | a->addRelated(this); |
| 51 | } |
| 52 | /// get access to role wrt the FROM direction |
| 53 | TRole* getRole ( void ) const { return R; } |
| 54 | }; // TRelated |
| 55 | |
| 56 | // TIndividual RELATED-dependent method' implementation |
| 57 | inline void |
| 58 | TIndividual :: updateToldFromRelated ( void ) |
| 59 | { |
| 60 | RoleSSet RolesProcessed; |
| 61 | updateTold ( RelatedIndex.begin(), RelatedIndex.end(), RolesProcessed ); |
| 62 | } |
| 63 | |
| 64 | #endif |