Debian Codegraph @

Kernel/modelCacheSingleton.h

raw symbols SCIP
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_H
22
23 #include "modelCacheConst.h"
24 #include "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 modelCacheSingleton: public modelCacheInterface
31 {
32 protected: // members
33 /// the singleton itself
34 BipolarPointer Singleton;
35
36 protected: // methods
37 /// log a particular implementation of a cache entry
38 void logCacheEntryImpl ( void ) const override { LL << "\nSingleton cache: element " << getValue(); }
39
40 public: // interface
41 /// c'tor: no nominals can be here
42 explicit modelCacheSingleton ( BipolarPointer bp )
43 : modelCacheInterface{/*flagNominals=*/false}
44 , Singleton{bp}
45 {}
46 /// copy c'tor
47 modelCacheSingleton ( const modelCacheSingleton& m )
48 : modelCacheInterface{m.hasNominalNode}
49 , Singleton{m.Singleton}
50 {}
51
52 /// Check if the model contains clash
53 modelCacheState getState ( void ) const override { return csValid; }
54 /// access to internal value
55 BipolarPointer getValue ( void ) const { return Singleton; }
56
57 // mergeable part
58
59 /// check whether two caches can be merged; @return state of "merged" model
60 modelCacheState canMerge ( const 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 modelCacheConst*>(cache) )
64 return cacheConst->getState();
65 // check another singleton: can be clash
66 if ( auto cacheSingleton = dynamic_cast<const modelCacheSingleton*>(cache) )
67 return cacheSingleton->getValue() == inverse(getValue()) ? csInvalid : csValid;
68 // more complex cache: ask them to check
69 return cache->canMerge(this);
70 }
71 }; // modelCacheSingleton
72
73 #endif