| 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_CSATURATIONNODEASSOCIATEDEXPANSIONCACHE_H |
| 22 |
#define KONCLUDE_REASONER_KERNEL_CACHE_CSATURATIONNODEASSOCIATEDEXPANSIONCACHE_H |
| 23 |
|
| 24 |
// Libraries includes |
| 25 |
#include <QHash> |
| 26 |
#include <QMutex> |
| 27 |
#include <QSemaphore> |
| 28 |
|
| 29 |
// Namespace includes |
| 30 |
#include "CacheSettings.h" |
| 31 |
#include "CSaturationCache.h" |
| 32 |
#include "CSaturationNodeAssociatedExpansionCacheEntry.h" |
| 33 |
#include "CSaturationNodeAssociatedExpansionCacheContext.h" |
| 34 |
#include "CSaturationNodeAssociatedExpansionCacheReader.h" |
| 35 |
#include "CSaturationNodeAssociatedExpansionCacheUnsatisfiabilityWriteData.h" |
| 36 |
#include "CSaturationNodeAssociatedExpansionCacheExpansionWriteData.h" |
| 37 |
#include "CSaturationNodeCacheUpdater.h" |
| 38 |
#include "CCacheStatistics.h" |
| 39 |
|
| 40 |
|
| 41 |
// Other includes |
| 42 |
#include "Concurrent/CThread.h" |
| 43 |
|
| 44 |
#include "Config/CConfiguration.h" |
| 45 |
#include "Config/CConfigDataReader.h" |
| 46 |
|
| 47 |
#include "Reasoner/Kernel/Cache/Events/CWriteSaturationCacheDataEvent.h" |
| 48 |
|
| 49 |
#include "Utilities/Memory/CObjectMemoryPoolAllocator.h" |
| 50 |
#include "Utilities/Memory/CObjectParameterizingAllocator.h" |
| 51 |
#include "Utilities/Memory/CMemoryPoolContainerAllocationManager.h" |
| 52 |
|
| 53 |
#include "Context/CContextBase.h" |
| 54 |
|
| 55 |
|
| 56 |
// Logger includes |
| 57 |
#include "Logger/CLogger.h" |
| 58 |
|
| 59 |
|
| 60 |
//#define KONCLUCE_SATISFIBALE_EXPANDER_CACHE_DIRECT_WRITING |
| 61 |
|
| 62 |
|
| 63 |
namespace Konclude { |
| 64 |
|
| 65 |
using namespace Config; |
| 66 |
using namespace Concurrent; |
| 67 |
using namespace Context; |
| 68 |
using namespace Utilities::Memory; |
| 69 |
|
| 70 |
namespace Reasoner { |
| 71 |
|
| 72 |
namespace Kernel { |
| 73 |
|
| 74 |
namespace Cache { |
| 75 |
|
| 76 |
using namespace Events; |
| 77 |
|
| 78 |
/*! |
| 79 |
* |
| 80 |
* \class CSaturationNodeAssociatedExpansionCache |
| 81 |
* \author Andreas Steigmiller |
| 82 |
* \version 0.1 |
| 83 |
* \brief TODO |
| 84 |
* |
| 85 |
*/ |
| 86 |
class CSaturationNodeAssociatedExpansionCache : public CThread, public CSaturationCache { |
| 87 |
// public methods |
| 88 |
public: |
| 89 |
//! Constructor |
| 90 |
CSaturationNodeAssociatedExpansionCache(CConfiguration* config = nullptr, QString threadIdentifierName = "Saturation-Node-Associated-Expansion-Cache", CWatchDog *watchDogThread = 0); |
| 91 |
|
| 92 |
//! Destructor |
| 93 |
virtual ~CSaturationNodeAssociatedExpansionCache(); |
| 94 |
|
| 95 |
CSaturationNodeAssociatedExpansionCacheReader* createCacheReader(); |
| 96 |
CSaturationNodeAssociatedExpansionCacheWriter* createCacheWriter(); |
| 97 |
|
| 98 |
|
| 99 |
CSaturationNodeAssociatedExpansionCache* writeCacheData(CSaturationNodeAssociatedExpansionCacheWriteData* writeData, CMemoryPool* memoryPools); |
| 100 |
|
| 101 |
CCacheStatistics* getCacheStatistics(); |
| 102 |
|
| 103 |
// protected methods |
| 104 |
protected: |
| 105 |
CSaturationNodeAssociatedExpansionCache* installWriteCacheData(CSaturationNodeAssociatedExpansionCacheWriteData* writeData, CSaturationNodeAssociatedExpansionCacheContext* context); |
| 106 |
|
| 107 |
CSaturationNodeAssociatedExpansionCache* propagateUnsatisfibility(CIndividualSaturationProcessNode* node, CSaturationNodeAssociatedExpansionCacheContext* context); |
| 108 |
CSaturationNodeAssociatedExpansionCache* addNodeExpansionData(CSaturationNodeAssociatedExpansionCacheExpansionWriteData* snaecewd, CSaturationNodeAssociatedExpansionCacheContext* context); |
| 109 |
|
| 110 |
|
| 111 |
CSaturationNodeAssociatedExpansionCacheEntry* getCacheEntryForNode(CIndividualSaturationProcessNode* node, CSaturationNodeAssociatedExpansionCacheContext* context, bool create = true); |
| 112 |
|
| 113 |
|
| 114 |
CSaturationNodeAssociatedExpansionCache* fillExpansionData(CSaturationNodeAssociatedConceptExpansion* conceptExpansion, CSaturationNodeAssociatedExpansionCacheExpansionWriteData* snaecewd, CSaturationNodeAssociatedExpansionCacheContext* context); |
| 115 |
CSaturationNodeAssociatedDeterministicConceptExpansion* extendDeterministicExpansionData(CSaturationNodeAssociatedConceptExpansion* conceptExpansion, CSaturationNodeAssociatedExpansionCacheExpansionWriteData* snaecewd, CSaturationNodeAssociatedExpansionCacheContext* context); |
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
virtual bool processCustomsEvents(QEvent::Type type, CCustomEvent *event); |
| 120 |
|
| 121 |
// protected variables |
| 122 |
protected: |
| 123 |
CSaturationNodeAssociatedExpansionCacheEntry* mEntryLinker; |
| 124 |
|
| 125 |
CSaturationNodeCacheUpdater* mSaturationNodeCacheUpdate; |
| 126 |
|
| 127 |
cint64 mConfAllowedNonDetExpansionCount; |
| 128 |
|
| 129 |
|
| 130 |
CSaturationNodeAssociatedExpansionCacheReader* mReaderLinker; |
| 131 |
QMutex mReaderSyncMutex; |
| 132 |
|
| 133 |
CCacheStatistics mCacheStat; |
| 134 |
CSaturationNodeAssociatedExpansionCacheContext mContext; |
| 135 |
|
| 136 |
// private methods |
| 137 |
private: |
| 138 |
|
| 139 |
// private variables |
| 140 |
private: |
| 141 |
|
| 142 |
}; |
| 143 |
|
| 144 |
}; // end namespace Cache |
| 145 |
|
| 146 |
}; // end namespace Kernel |
| 147 |
|
| 148 |
}; // end namespace Reasoner |
| 149 |
|
| 150 |
}; // end namespace Konclude |
| 151 |
|
| 152 |
#endif // KONCLUDE_REASONER_KERNEL_CACHE_CSATURATIONNODEASSOCIATEDEXPANSIONCACHE_H |