| 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 |
#ifdef KONCLUDE_REDLAND_INTEGRATION |
| 21 |
|
| 22 |
#include "CRedlandStoredTriplesData.h" |
| 23 |
|
| 24 |
|
| 25 |
namespace Konclude { |
| 26 |
|
| 27 |
namespace Reasoner { |
| 28 |
|
| 29 |
namespace Triples { |
| 30 |
|
| 31 |
|
| 32 |
CRedlandStoredTriplesData::CRedlandStoredTriplesData() { |
| 33 |
mLastSharingTripleData = nullptr; |
| 34 |
mWorld = nullptr; |
| 35 |
mIndexedStorage = nullptr; |
| 36 |
mIndexedModel = nullptr; |
| 37 |
mStatementLinker = nullptr; |
| 38 |
mUpdateType = CTRIPLES_DATA_UPDATE_TYPE::TRIPLES_DATA_NOTHING; |
| 39 |
} |
| 40 |
|
| 41 |
CRedlandStoredTriplesData::~CRedlandStoredTriplesData() { |
| 42 |
if (mIndexedModel && (!mLastSharingTripleData || mLastSharingTripleData->mIndexedModel != mIndexedModel)) { |
| 43 |
librdf_free_model(mIndexedModel); |
| 44 |
} |
| 45 |
if (mIndexedStorage && (!mLastSharingTripleData || mLastSharingTripleData->mIndexedStorage != mIndexedStorage)) { |
| 46 |
librdf_free_storage(mIndexedStorage); |
| 47 |
} |
| 48 |
if (mWorld && (!mLastSharingTripleData || mLastSharingTripleData->mWorld != mWorld)) { |
| 49 |
librdf_free_world(mWorld); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
CRedlandStoredTriplesData* CRedlandStoredTriplesData::initTriplesData(CTRIPLES_DATA_UPDATE_TYPE updateType, CRedlandStoredTriplesData* lastSharingTripleData) { |
| 54 |
mLastSharingTripleData = (CRedlandStoredTriplesData*)lastSharingTripleData; |
| 55 |
mUpdateType = updateType; |
| 56 |
return this; |
| 57 |
} |
| 58 |
|
| 59 |
CTRIPLES_DATA_UPDATE_TYPE CRedlandStoredTriplesData::getUpdateType() { |
| 60 |
return mUpdateType; |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
CTriplesDataIterator* CRedlandStoredTriplesData::getTriplesDataIterator() { |
| 65 |
if (mStatementLinker) { |
| 66 |
return new CRedlandStoredTriplesDataLinkerIterator(mStatementLinker); |
| 67 |
} else { |
| 68 |
librdf_stream* stream = librdf_model_as_stream(mIndexedModel); |
| 69 |
return new CRedlandStoredTriplesDataModelIterator(stream); |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
CRedlandStoredTriplesData* CRedlandStoredTriplesData::setRedlandModelStorageWorldData(librdf_world* world, librdf_storage* indexedStorage, librdf_model* indexedModel, CXLinker<librdf_statement*>* linker) { |
| 75 |
mWorld = world; |
| 76 |
mIndexedStorage = indexedStorage; |
| 77 |
mIndexedModel = indexedModel; |
| 78 |
mStatementLinker = linker; |
| 79 |
return this; |
| 80 |
} |
| 81 |
|
| 82 |
|
| 83 |
CRedlandStoredTriplesData* CRedlandStoredTriplesData::setRedlandWorldData(librdf_world* world) { |
| 84 |
mWorld = world; |
| 85 |
return this; |
| 86 |
} |
| 87 |
|
| 88 |
CRedlandStoredTriplesData* CRedlandStoredTriplesData::setRedlandIndexedStorageData(librdf_storage* storage) { |
| 89 |
mIndexedStorage = storage; |
| 90 |
return this; |
| 91 |
} |
| 92 |
|
| 93 |
CRedlandStoredTriplesData* CRedlandStoredTriplesData::setRedlandIndexedModelData(librdf_model* model) { |
| 94 |
mIndexedModel = model; |
| 95 |
return this; |
| 96 |
} |
| 97 |
|
| 98 |
|
| 99 |
librdf_world* CRedlandStoredTriplesData::getRedlandWorld() { |
| 100 |
return mWorld; |
| 101 |
} |
| 102 |
|
| 103 |
librdf_storage* CRedlandStoredTriplesData::getRedlandIndexedStorage() { |
| 104 |
return mIndexedStorage; |
| 105 |
} |
| 106 |
|
| 107 |
librdf_model* CRedlandStoredTriplesData::getRedlandIndexedModel() { |
| 108 |
return mIndexedModel; |
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
CXLinker<librdf_statement*>* CRedlandStoredTriplesData::getRedlandStatementLinker() { |
| 113 |
return mStatementLinker; |
| 114 |
} |
| 115 |
|
| 116 |
CRedlandStoredTriplesData* CRedlandStoredTriplesData::setRedlandStatementLinker(CXLinker<librdf_statement*>* linker) { |
| 117 |
mStatementLinker = linker; |
| 118 |
return this; |
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
}; // end namespace Triples |
| 123 |
|
| 124 |
}; // end namespace Reasoner |
| 125 |
|
| 126 |
}; // end namespace Konclude |
| 127 |
|
| 128 |
#endif // !KONCLUDE_REDLAND_INTEGRATION |