Debian Codegraph @

Source/Test/CCacheTestWriter.cpp

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 #include "CCacheTestWriter.h"
22
23
24 namespace Konclude {
25
26 namespace Test {
27
28
29
30 CCacheTestWriter::CCacheTestWriter(COccurrenceUnsatisfiableCacheWriter *takeOccUnsatCacheWriter) {
31 writer = takeOccUnsatCacheWriter;
32 writeCount = 0;
33 }
34
35
36 CCacheTestWriter::~CCacheTestWriter() {
37 quit();
38 wait();
39 if (writer) {
40 delete writer;
41 }
42 }
43
44 void CCacheTestWriter::startWriter() {
45 start();
46 moveToThread(this);
47 }
48
49
50 qint64 CCacheTestWriter::getCacheWrites() {
51 return writeCount;
52 }
53
54
55 void CCacheTestWriter::run() {
56 if (writer) {
57 qint64 count = 100;
58
59 qint64 maxOntTag = 1;
60 qint64 maxConTag = 100;
61 qint64 maxCount = 5;
62
63 while (true/*--count > 0*/) {
64 qint64 randOntTagNumber = rand() % maxOntTag;
65 qint64 randCount = (rand() % maxCount) + 2;
66 QVector<qint64> conTags(randCount,0);
67 for (qint64 i = 0; i < randCount; ++i) {
68 qint64 randConTagNumber = rand() % maxConTag;
69 conTags[i] = randConTagNumber;
70 }
71 qSort(conTags);
72 QList<CCacheValue> values;
73 for (qint64 i = 0; i < randCount; ++i) {
74 values.append(CCacheValue(conTags[i],randOntTagNumber,CCacheValue::CACHEVALCONCEPTONTOLOGYTAG));
75 }
76
77 writeCount++;
78 writer->setUnsatisfiable(values);
79
80 QThread::msleep(10);
81 }
82 }
83 }
84
85
86
87
88 }; // end namespace Test
89
90 }; // end namespace Konclude