| 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 MODELCACHESINGLETON_H |
| 21 | #define MODELCACHESINGLETON_Hcxx . . $ `Kernel/modelCacheSingleton.h:21:9`! |
| 22 | |
| 23 | #include "modelCacheConst.h"cxx . . $ `<file>/Kernel/modelCacheConst.h`/ |
| 24 | #include "BiPointer.h"cxx . . $ `<file>/Kernel/BiPointer.h`/ |
| 25 | |
| 26 | /** Model caching implementation for singleton models. |
| 27 | Such models contains only one [negated] concept in completion tree. |
| 28 | Reduced set of operations, but very efficient. |
| 29 | */ |
| 30 | class modelCacheSingletoncxx . . $ modelCacheSingleton#: public modelCacheInterfacecxx . . $ modelCacheInterface# |
| 31 | { |
| 32 | protected: // members |
| 33 | /// the singleton itself |
| 34 | BipolarPointercxx . . $ BipolarPointer# Singletoncxx . . $ modelCacheSingleton#Singleton.; |
| 35 | |
| 36 | protected: // methods |
| 37 | /// log a particular implementation of a cache entry |
| 38 | void logCacheEntryImplcxx . . $ modelCacheSingleton#logCacheEntryImpl(83f5f38750778ac8). ( void ) const override { LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\nSingleton cache: element " <<cxx . . $ std/basic_ostream#`operator<<`(23b6575433a77e57). getValuecxx . . $ modelCacheSingleton#getValue(455f465bc33b4cdf).(); } |
| 39 | |
| 40 | public: // interface |
| 41 | /// c'tor: no nominals can be here |
| 42 | explicit modelCacheSingletoncxx . . $ modelCacheSingleton#modelCacheSingleton(d4f767463ce0a6b3). ( BipolarPointercxx . . $ BipolarPointer# bp ) |
| 43 | : modelCacheInterfacecxx . . $ modelCacheInterface#modelCacheInterface(b45ddcbc8423892c).{/*flagNominals=*/false} |
| 44 | , Singletoncxx . . $ modelCacheSingleton#Singleton.{bp} |
| 45 | {} |
| 46 | /// copy c'tor |
| 47 | modelCacheSingletoncxx . . $ modelCacheSingleton#modelCacheSingleton(71d7139b2d674975). ( const modelCacheSingletoncxx . . $ modelCacheSingleton#& m ) |
| 48 | : modelCacheInterfacecxx . . $ modelCacheInterface#modelCacheInterface(b45ddcbc8423892c).{m.hasNominalNodecxx . . $ modelCacheInterface#hasNominalNode.} |
| 49 | , Singletoncxx . . $ modelCacheSingleton#Singleton.{m.Singletoncxx . . $ modelCacheSingleton#Singleton.} |
| 50 | {} |
| 51 | |
| 52 | /// Check if the model contains clash |
| 53 | modelCacheStatecxx . . $ modelCacheState# getStatecxx . . $ modelCacheSingleton#getState(2c070a27c5715e50). ( void ) const override { return csValidcxx . . $ csValid.; } |
| 54 | /// access to internal value |
| 55 | BipolarPointercxx . . $ BipolarPointer# getValuecxx . . $ modelCacheSingleton#getValue(455f465bc33b4cdf). ( void ) const { return Singletoncxx . . $ modelCacheSingleton#Singleton.; } |
| 56 | |
| 57 | // mergeable part |
| 58 | |
| 59 | /// check whether two caches can be merged; @return state of "merged" model |
| 60 | modelCacheStatecxx . . $ modelCacheState# canMergecxx . . $ modelCacheSingleton#canMerge(be618e219bff59e1). ( const modelCacheInterfacecxx . . $ modelCacheInterface#* cache ) const override |
| 61 | { |
| 62 | // TOP/BOTTOM: the current node can't add anything to the result |
| 63 | if ( auto cacheConst = dynamic_cast<const modelCacheConstcxx . . $ modelCacheConst#*>(cache) ) |
| 64 | return cacheConst->getStatecxx . . $ modelCacheConst#getState(2c070a27c5715e50).(); |
| 65 | // check another singleton: can be clash |
| 66 | if ( auto cacheSingleton = dynamic_cast<const modelCacheSingletoncxx . . $ modelCacheSingleton#*>(cache) ) |
| 67 | return cacheSingleton->getValuecxx . . $ modelCacheSingleton#getValue(455f465bc33b4cdf).() == inversecxx . . $ inverse(7864480464b09eea).(getValuecxx . . $ modelCacheSingleton#getValue(455f465bc33b4cdf).()) ? csInvalidcxx . . $ csInvalid. : csValidcxx . . $ csValid.; |
| 68 | // more complex cache: ask them to check |
| 69 | return cache->canMergecxx . . $ modelCacheInterface#canMerge(be618e219bff59e1).(this); |
| 70 | } |
| 71 | }; // modelCacheSingleton |
| 72 | |
| 73 | #endif |