| 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 |
#include "CQueryStatisticsCollectionStrings.h" |
| 22 |
|
| 23 |
|
| 24 |
namespace Konclude { |
| 25 |
|
| 26 |
namespace Reasoner { |
| 27 |
|
| 28 |
namespace Query { |
| 29 |
|
| 30 |
|
| 31 |
CQueryStatisticsCollectionStrings::CQueryStatisticsCollectionStrings() { |
| 32 |
mCalcStatCollLinker = nullptr; |
| 33 |
mStatStringsCollected = false; |
| 34 |
} |
| 35 |
|
| 36 |
|
| 37 |
CQueryStatisticsCollectionStrings::~CQueryStatisticsCollectionStrings() { |
| 38 |
CQueryCalculationStatisticsCollection* mCalcStatCollLinkerIt = mCalcStatCollLinker; |
| 39 |
while (mCalcStatCollLinkerIt) { |
| 40 |
CQueryCalculationStatisticsCollection* tmpCalcStatCollLinker = mCalcStatCollLinkerIt; |
| 41 |
mCalcStatCollLinkerIt = mCalcStatCollLinkerIt->getNext(); |
| 42 |
delete tmpCalcStatCollLinker; |
| 43 |
} |
| 44 |
} |
| 45 |
|
| 46 |
|
| 47 |
CQueryCalculationStatisticsCollection* CQueryStatisticsCollectionStrings::getCalculationStatisticsCollectorLinker() { |
| 48 |
return mCalcStatCollLinker; |
| 49 |
} |
| 50 |
|
| 51 |
CQueryCalculationStatisticsCollection* CQueryStatisticsCollectionStrings::createCalculationStatisticsCollection() { |
| 52 |
CQueryCalculationStatisticsCollection* tmpCalcStatCollLinker = new CQueryCalculationStatisticsCollection(); |
| 53 |
mCalcStatCollLinker = tmpCalcStatCollLinker->append(mCalcStatCollLinker); |
| 54 |
return mCalcStatCollLinker; |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
bool CQueryStatisticsCollectionStrings::addProcessingStatistics(COntologyProcessingStatistics* ontProcStats) { |
| 59 |
QHash<QString,cint64>* statsValueHash = ontProcStats->getProcessingCountStatisticsHash(); |
| 60 |
for (QHash<QString,cint64>::const_iterator it = statsValueHash->constBegin(), itEnd = statsValueHash->constEnd(); it != itEnd; ++it) { |
| 61 |
const QString& statString(it.key()); |
| 62 |
cint64 statValue = it.value(); |
| 63 |
incProcessingStatistics(statString,statValue); |
| 64 |
} |
| 65 |
return true; |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
bool CQueryStatisticsCollectionStrings::addProcessingStatistics(const QString& statName, cint64 statValue) { |
| 70 |
mStatNameStringsValueHash[statName] = statValue; |
| 71 |
return true; |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
bool CQueryStatisticsCollectionStrings::incProcessingStatistics(const QString& statName, cint64 incStatValue) { |
| 76 |
mStatNameStringsValueHash[statName] += incStatValue; |
| 77 |
return true; |
| 78 |
} |
| 79 |
|
| 80 |
QList<QString> CQueryStatisticsCollectionStrings::getStatisticsNameStringList() { |
| 81 |
if (!mStatStringsCollected) { |
| 82 |
CQueryCalculationStatisticsCollection* mCalcStatCollLinkerIt = mCalcStatCollLinker; |
| 83 |
while (mCalcStatCollLinkerIt) { |
| 84 |
mCalcStatCollLinkerIt->appendStatisticsStringNames(&mStatNameStrings); |
| 85 |
mCalcStatCollLinkerIt = mCalcStatCollLinkerIt->getNext(); |
| 86 |
} |
| 87 |
foreach (QString statName, mStatNameStringsValueHash.keys()) { |
| 88 |
mStatNameStrings.insert(statName); |
| 89 |
} |
| 90 |
mStatStringsCollected = true; |
| 91 |
} |
| 92 |
return mStatNameStrings.toList(); |
| 93 |
} |
| 94 |
|
| 95 |
cint64 CQueryStatisticsCollectionStrings::getStatisticIntegerValue(const QString& statName) { |
| 96 |
cint64 statValue = mStatNameStringsValueHash.value(statName,0); |
| 97 |
CQueryCalculationStatisticsCollection* mCalcStatCollLinkerIt = mCalcStatCollLinker; |
| 98 |
while (mCalcStatCollLinkerIt) { |
| 99 |
statValue += mCalcStatCollLinkerIt->getStatisticIntegerValue(statName); |
| 100 |
mCalcStatCollLinkerIt = mCalcStatCollLinkerIt->getNext(); |
| 101 |
} |
| 102 |
return statValue; |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
}; // end namespace Query |
| 107 |
|
| 108 |
}; // end namespace Reasoner |
| 109 |
|
| 110 |
}; // end namespace Konclude |