Debian Codegraph @

Source/Reasoner/Answerer/CRedlandRasqalLiteralHasher.h

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
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 #ifndef KONCLUDE_REASONER_TRIPLES_CREDLANDRASQALLITERALHASHER_H
23 #define KONCLUDE_REASONER_TRIPLES_CREDLANDRASQALLITERALHASHER_H
24
25 // Libraries includes
26 #include <QHash>
27 #include <Redland.h>
28
29 // Namespace includes
30 #include "AnswererSettings.h"
31
32
33 // Other includes
34 #include "Utilities/UtilitiesSettings.h"
35
36
37 // Logger includes
38 #include "Logger/CLogger.h"
39
40
41
42
43 namespace Konclude {
44
45 using namespace Utilities;
46
47 namespace Reasoner {
48
49 namespace Answerer {
50
51
52 /*!
53 *
54 * \class CRedlandRasqalLiteralHasher
55 * \author Andreas Steigmiller
56 * \version 0.1
57 * \brief TODO
58 *
59 */
60 class CRedlandRasqalLiteralHasher {
61 // public methods
62 public:
63 //! Constructor
64 CRedlandRasqalLiteralHasher(rasqal_literal* node);
65 CRedlandRasqalLiteralHasher(const CRedlandRasqalLiteralHasher& hasher);
66
67 ~CRedlandRasqalLiteralHasher();
68
69 CRedlandRasqalLiteralHasher& operator=(const CRedlandRasqalLiteralHasher& hasher);
70
71 cint64 getNodeHashValue() const {
72 return mHashValue;
73 }
74
75 bool operator==(const CRedlandRasqalLiteralHasher& nodeHasher) const {
76 if (mHashValue != nodeHasher.getNodeHashValue()) {
77 return false;
78 }
79 if (!rasqal_literal_equals(mNode, nodeHasher.mNode)) {
80 return false;
81 }
82 return true;
83 }
84
85
86 cint64 hash_c_string(const char* p) {
87 cint64 result = 0;
88 const cint64 prime = 31;
89 for (cint64 i = 0; p[i] != 0; ++i) {
90 result = p[i] + (result * prime);
91 }
92 return result;
93 }
94
95 // protected methods
96 protected:
97
98 // protected variables
99 protected:
100 rasqal_literal* mNode;
101 cint64 mHashValue;
102
103 // private methods
104 private:
105
106 // private variables
107 private:
108
109 };
110
111
112
113
114 inline uint qHash(const CRedlandRasqalLiteralHasher& nodeHasher) {
115 qint64 key = (qint64)nodeHasher.getNodeHashValue();
116 if (sizeof(quint64) > sizeof(uint)) {
117 return uint((key >> (8 * sizeof(uint) - 1)) ^ key);
118 } else {
119 return uint(key);
120 }
121 }
122
123
124 }; // end namespace Answerer
125
126 }; // end namespace Reasoner
127
128 }; // end namespace Konclude
129
130 #endif // KONCLUDE_REASONER_TRIPLES_CREDLANDRASQALLITERALHASHER_H
131
132 #endif // !KONCLUDE_REDLAND_INTEGRATION