| 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 MODELCACHEINTERFACE_H |
| 21 | #define MODELCACHEINTERFACE_Hcxx . . $ `Kernel/modelCacheInterface.h:21:9`! |
| 22 | |
| 23 | #include "globaldef.h"cxx . . $ `<file>/Kernel/globaldef.h`/ |
| 24 | #include "logging.h"cxx . . $ `<file>/Kernel/logging.h`/ |
| 25 | |
| 26 | /// status of model cache or merge operation |
| 27 | enum modelCacheStatecxx . . $ modelCacheState# |
| 28 | { |
| 29 | csInvalidcxx . . $ csInvalid., ///> clash in model/merging fails because of direct contradiction; |
| 30 | csValidcxx . . $ csValid., ///> valid model/success in merging; |
| 31 | csFailedcxx . . $ csFailed., ///> incorrect model/merging fails because of incompleteness of procedure; |
| 32 | csUnknowncxx . . $ csUnknown. ///> untested model cache. |
| 33 | }; |
| 34 | |
| 35 | /// create united status for 2 given statuses |
| 36 | inline modelCacheStatecxx . . $ modelCacheState# mergeStatuscxx . . $ mergeStatus(eb6c078af0bc04eb). ( modelCacheStatecxx . . $ modelCacheState# s1, modelCacheStatecxx . . $ modelCacheState# s2 ) |
| 37 | { |
| 38 | // if one of caches is definitely UNSAT, then merge will be the same |
| 39 | if ( s1 == csInvalidcxx . . $ csInvalid. || s2 == csInvalidcxx . . $ csInvalid. ) |
| 40 | return csInvalidcxx . . $ csInvalid.; |
| 41 | // if one of caches is unsure then result will be the same |
| 42 | if ( s1 == csFailedcxx . . $ csFailed. || s2 == csFailedcxx . . $ csFailed. ) |
| 43 | return csFailedcxx . . $ csFailed.; |
| 44 | // if one of caches is not inited, than result would be the same |
| 45 | if ( s1 == csUnknowncxx . . $ csUnknown. || s2 == csUnknowncxx . . $ csUnknown. ) |
| 46 | return csUnknowncxx . . $ csUnknown.; |
| 47 | else // valid+valid = valid |
| 48 | return csValidcxx . . $ csValid.; |
| 49 | } |
| 50 | |
| 51 | /// interface for general model caching. |
| 52 | class modelCacheInterfacecxx . . $ modelCacheInterface# |
| 53 | { |
| 54 | protected: // members |
| 55 | /// flag to show that model contains nominals |
| 56 | bool hasNominalNodecxx . . $ modelCacheInterface#hasNominalNode.; |
| 57 | |
| 58 | protected: // methods |
| 59 | /// log a particular implementation of a cache entry |
| 60 | virtual void logCacheEntryImplcxx . . $ modelCacheInterface#logCacheEntryImpl(83f5f38750778ac8). ( void ) const = 0; |
| 61 | |
| 62 | public: // interface |
| 63 | /// Create cache model with given presence of nominals |
| 64 | explicit modelCacheInterfacecxx . . $ modelCacheInterface#modelCacheInterface(b45ddcbc8423892c). ( bool flagNominals ) : hasNominalNodecxx . . $ modelCacheInterface#hasNominalNode.{flagNominals} {} |
| 65 | /// empty d'tor |
| 66 | virtual ~cxx . . $ modelCacheInterface#`~modelCacheInterface`(49f6e7a06ebc5aa8).modelCacheInterfacecxx . . $ modelCacheInterface#() = default; |
| 67 | |
| 68 | /// check whether both models have nominals; in this case, merge is impossible |
| 69 | bool hasNominalClashcxx . . $ modelCacheInterface#hasNominalClash(93d0908592e17c06). ( const modelCacheInterfacecxx . . $ modelCacheInterface#* p ) const |
| 70 | { return hasNominalNodecxx . . $ modelCacheInterface#hasNominalNode. && p->hasNominalNodecxx . . $ modelCacheInterface#hasNominalNode.; } |
| 71 | /// update knowledge about nominals in the model after merging |
| 72 | void updateNominalStatuscxx . . $ modelCacheInterface#updateNominalStatus(5cc94ca22787ebea). ( const modelCacheInterfacecxx . . $ modelCacheInterface#* p ) { hasNominalNodecxx . . $ modelCacheInterface#hasNominalNode. |= p->hasNominalNodecxx . . $ modelCacheInterface#hasNominalNode.; } |
| 73 | |
| 74 | // mergeable part |
| 75 | |
| 76 | /// Check the model cache internal state. |
| 77 | virtual modelCacheStatecxx . . $ modelCacheState# getStatecxx . . $ modelCacheInterface#getState(2c070a27c5715e50). ( void ) const = 0; |
| 78 | /// check whether two caches can be merged; @return state of "merged" model |
| 79 | virtual modelCacheStatecxx . . $ modelCacheState# canMergecxx . . $ modelCacheInterface#canMerge(be618e219bff59e1). ( const modelCacheInterfacecxx . . $ modelCacheInterface#* p ) const = 0; |
| 80 | |
| 81 | /// get type of cache (deep or shallow) |
| 82 | virtual bool shallowCachecxx . . $ modelCacheInterface#shallowCache(50ce9a9e25b4a850). ( void ) const { return true; } |
| 83 | /// log this cache entry (with given level) |
| 84 | void logCacheEntrycxx . . $ modelCacheInterface#logCacheEntry(b64ca9271699b390). ( unsigned int level ) const |
| 85 | { |
| 86 | if ( LLMcxx . . $ LLM..isWritablecxx . . $ LeveLogger#isWritable(8de63fdb265b07c1).(level) ) |
| 87 | logCacheEntryImplcxx . . $ modelCacheInterface#logCacheEntryImpl(83f5f38750778ac8).(); |
| 88 | } |
| 89 | }; // modelCacheInterface |
| 90 | |
| 91 | #endif |