Debian Codegraph @

Source/Reasoner/Kernel/Cache/CComputedConsequencesCache.h

raw
1 /*
2 * Copyright (C) 2013-2015, 2019 by the Konclude Developer Team.
3 *
4 * This file is part of the reasoning system Konclude.
5 * For details and support, see <http://konclude.com/>.
6 *
7 * Konclude is free software: you can redistribute it and/or modify
8 * it under the terms of version 3 of the GNU Lesser General Public
9 * License (LGPLv3) as published by the Free Software Foundation.
10 *
11 * Konclude is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU (Lesser) General Public License for more details.
15 *
16 * You should have received a copy of the GNU (Lesser) General Public
17 * License along with Konclude. If not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21 #ifndef KONCLUDE_REASONER_KERNEL_CACHE_CCOMPUTEDCONSEQUENCESCACHE_H
22 #define KONCLUDE_REASONER_KERNEL_CACHE_CCOMPUTEDCONSEQUENCESCACHE_H
23
24 // Libraries includes
25 #include <QHash>
26 #include <QMutex>
27 #include <QSemaphore>
28
29 // Namespace includes
30 #include "CacheSettings.h"
31 #include "CSatisfiableCache.h"
32 #include "CComputedConsequencesCacheEntry.h"
33 #include "CComputedConsequencesCacheContext.h"
34 #include "CComputedConsequencesCacheReader.h"
35 #include "CComputedConsequencesCacheWriteTypesData.h"
36 #include "CSaturationNodeCacheUpdater.h"
37 #include "CCacheStatistics.h"
38
39
40 // Other includes
41 #include "Concurrent/CThread.h"
42
43 #include "Config/CConfiguration.h"
44 #include "Config/CConfigDataReader.h"
45
46 #include "Reasoner/Kernel/Cache/Events/CWriteComputedConcequencesCacheEntryEvent.h"
47
48 #include "Utilities/Memory/CObjectMemoryPoolAllocator.h"
49 #include "Utilities/Memory/CObjectParameterizingAllocator.h"
50 #include "Utilities/Memory/CMemoryPoolContainerAllocationManager.h"
51
52 #include "Context/CContextBase.h"
53
54
55 // Logger includes
56 #include "Logger/CLogger.h"
57
58
59 //#define KONCLUCE_SATISFIBALE_EXPANDER_CACHE_DIRECT_WRITING
60
61
62 namespace Konclude {
63
64 using namespace Config;
65 using namespace Concurrent;
66 using namespace Context;
67 using namespace Utilities::Memory;
68
69 namespace Reasoner {
70
71 namespace Kernel {
72
73 namespace Cache {
74
75 using namespace Events;
76
77 /*!
78 *
79 * \class CComputedConsequencesCache
80 * \author Andreas Steigmiller
81 * \version 0.1
82 * \brief TODO
83 *
84 */
85 class CComputedConsequencesCache : public CThread, public CSatisfiableCache {
86 // public methods
87 public:
88 //! Constructor
89 CComputedConsequencesCache(CConfiguration* config = nullptr, QString threadIdentifierName = "Saturation-Node-Associated-Expansion-Cache", CWatchDog *watchDogThread = 0);
90
91 //! Destructor
92 virtual ~CComputedConsequencesCache();
93
94 CComputedConsequencesCacheReader* createCacheReader();
95 CComputedConsequencesCacheWriter* createCacheWriter();
96
97
98 CComputedConsequencesCache* writeCacheData(CComputedConsequencesCacheWriteData* writeData, CMemoryPool* memoryPools);
99
100 CCacheStatistics* getCacheStatistics();
101
102 // protected methods
103 protected:
104 CComputedConsequencesCache* installWriteCacheData(CComputedConsequencesCacheWriteData* writeData, CComputedConsequencesCacheContext* context);
105
106 CComputedConsequencesCache* addTypesExpansionData(CComputedConsequencesCacheWriteTypesData* cccwtd, CComputedConsequencesCacheContext* context);
107
108
109 CComputedConsequencesTypesCacheEntry* getComputedTypesCacheEntryForNode(CIndividual* individual, CComputedConsequencesCacheContext* context, bool create = true);
110
111
112
113 virtual bool processCustomsEvents(QEvent::Type type, CCustomEvent *event);
114
115 // protected variables
116 protected:
117 CComputedConsequencesCacheEntry* mEntryLinker;
118
119 cint64 mConfAllowedNonDetExpansionCount;
120
121
122 CComputedConsequencesCacheReader* mReaderLinker;
123 QMutex mReaderSyncMutex;
124
125 CCacheStatistics mCacheStat;
126 CComputedConsequencesCacheContext mContext;
127
128 // private methods
129 private:
130
131 // private variables
132 private:
133
134 };
135
136 }; // end namespace Cache
137
138 }; // end namespace Kernel
139
140 }; // end namespace Reasoner
141
142 }; // end namespace Konclude
143
144 #endif // KONCLUDE_REASONER_KERNEL_CACHE_CCOMPUTEDCONSEQUENCESCACHE_H