| 1 | /* This file is part of the FaCT++ DL reasoner |
| 2 | Copyright (C) 2007-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 MODELCACHECONST_H |
| 21 | #define MODELCACHECONST_Hcxx . . $ `Kernel/modelCacheConst.h:21:9`! |
| 22 | |
| 23 | #include "modelCacheInterface.h"cxx . . $ `<file>/Kernel/modelCacheInterface.h`/ |
| 24 | #include "BiPointer.h"cxx . . $ `<file>/Kernel/BiPointer.h`/ |
| 25 | #include "fpp_assert.h"cxx . . $ `<file>/Kernel/fpp_assert.h`/ |
| 26 | |
| 27 | /// Model caching implementation for TOP/BOTTOM nodes. |
| 28 | class modelCacheConstcxx . . $ modelCacheConst#: public modelCacheInterfacecxx . . $ modelCacheInterface# |
| 29 | { |
| 30 | protected: // members |
| 31 | /// the const itself |
| 32 | bool isTopcxx . . $ modelCacheConst#isTop.; |
| 33 | |
| 34 | protected: // methods |
| 35 | /// log a particular implementation of a cache entry |
| 36 | void logCacheEntryImplcxx . . $ modelCacheConst#logCacheEntryImpl(83f5f38750778ac8). ( void ) const override |
| 37 | { LLcxx . . $ LL. <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). "\nConst cache: element " <<cxx . . $ std/`operator<<`(efaf8c13fc75f3c7). (isTopcxx . . $ modelCacheConst#isTop. ? "TOP" : "BOTTOM"); } |
| 38 | |
| 39 | public: |
| 40 | /// c'tor: no nominals can be here |
| 41 | explicit modelCacheConstcxx . . $ modelCacheConst#modelCacheConst(b45ddcbc8423892c). ( bool top ) |
| 42 | : modelCacheInterfacecxx . . $ modelCacheInterface#modelCacheInterface(b45ddcbc8423892c).{/*flagNominals=*/false} |
| 43 | , isTopcxx . . $ modelCacheConst#isTop.{top} |
| 44 | {} |
| 45 | /// copy c'tor |
| 46 | modelCacheConstcxx . . $ modelCacheConst#modelCacheConst(adf65eae8c11e5df). ( const modelCacheConstcxx . . $ modelCacheConst#& m ) |
| 47 | : modelCacheInterfacecxx . . $ modelCacheInterface#{m.hasNominalNodecxx . . $ modelCacheInterface#hasNominalNode.} |
| 48 | , isTopcxx . . $ modelCacheConst#isTop.{m.isTopcxx . . $ modelCacheConst#isTop.} |
| 49 | {} |
| 50 | |
| 51 | /// Check if the model contains clash |
| 52 | modelCacheStatecxx . . $ modelCacheState# getStatecxx . . $ modelCacheConst#getState(2c070a27c5715e50). ( void ) const override { return isTopcxx . . $ modelCacheConst#isTop. ? csValidcxx . . $ csValid. : csInvalidcxx . . $ csInvalid.; } |
| 53 | /// get the value of the constant |
| 54 | bool getConstcxx . . $ modelCacheConst#getConst(50ce9a9e25b4a850). ( void ) const { return isTopcxx . . $ modelCacheConst#isTop.; } |
| 55 | |
| 56 | // mergeable part |
| 57 | |
| 58 | /// check whether two caches can be merged; @return state of "merged" model |
| 59 | modelCacheStatecxx . . $ modelCacheState# canMergecxx . . $ modelCacheConst#canMerge(be618e219bff59e1). ( const modelCacheInterfacecxx . . $ modelCacheInterface#* cache ) const override |
| 60 | { |
| 61 | if ( auto cacheConst = dynamic_cast<const modelCacheConstcxx . . $ modelCacheConst#*>(cache) ) |
| 62 | return isTopcxx . . $ modelCacheConst#isTop. && cacheConst->isTopcxx . . $ modelCacheConst#isTop. ? csValidcxx . . $ csValid. : csInvalidcxx . . $ csInvalid.; |
| 63 | else |
| 64 | return cache->canMergecxx . . $ modelCacheInterface#canMerge(be618e219bff59e1).(this); |
| 65 | } |
| 66 | }; // modelCacheConst |
| 67 | |
| 68 | // create const cache by BP; BP should be either bpTOP or bpBOTTOM |
| 69 | inline |
| 70 | modelCacheConstcxx . . $ modelCacheConst#* createConstCachecxx . . $ createConstCache(b04ec3060c58d05c). ( BipolarPointercxx . . $ BipolarPointer# bp ) |
| 71 | { |
| 72 | fpp_assertcxx . . $ `Kernel/fpp_assert.h:46:10`! ( bp == bpTOP || bp == bpBOTTOM ); |
| 73 | return new modelCacheConstcxx . . $ modelCacheConst#{bp==bpTOPcxx . . $ bpTOP.}; |
| 74 | } |
| 75 | |
| 76 | #endif |