Debian Codegraph @

FaCT++.JNI/Modularity.cpp

raw symbols SCIP
1 /* This file is part of the FaCT++ DL reasoner
2 Copyright (C) 2006-2015 Dmitry Tsarkov and The University of Manchester
3 Copyright (C) 2015-2017 Dmitry Tsarkov
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 // this file contains implementation of modularity-related methods of FaCT++ JNI interface
21
22 #include "uk_ac_manchester_cs_factplusplus_FaCTPlusPlus.h"
23 #include "Kernel.h"
24 #include "tJNICache.h"
25
26 /// translate int values of Java interface into ModuleType enum
27 inline enum ModuleType
28 moduleTypeByInt ( jint moduleType )
29 {
30 return moduleType == 0 ? M_BOT : moduleType == 1 ? M_TOP : M_STAR;
31 }
32
33 /// translate int values of Java interface into ModuleMethod enum
34 inline enum ModuleMethod
35 moduleMethodByInt ( jint moduleMethod )
36 {
37 return moduleMethod == 0 ? SYN_LOC_STD : moduleMethod == 1 ? SYN_LOC_COUNT : SEM_LOC;
38 }
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43
44 /*
45 * Class: uk_ac_manchester_cs_factplusplus_FaCTPlusPlus
46 * Method: getAtomicDecompositionSize
47 * Signature: (ZI)I
48 */
49 JNIEXPORT jint JNICALL Java_uk_ac_manchester_cs_factplusplus_FaCTPlusPlus_getAtomicDecompositionSize
50 (JNIEnv * env, jobject obj, jint moduleMethod, jint moduleType)
51 {
52 TRACE_JNI("getAtomicDecompositionSize");
53 return getK(env,obj)->getAtomicDecompositionSize ( moduleMethodByInt(moduleMethod), moduleTypeByInt(moduleType) );
54 }
55
56 /*
57 * Class: uk_ac_manchester_cs_factplusplus_FaCTPlusPlus
58 * Method: getAtomAxioms
59 * Signature: (I)[Luk/ac/manchester/cs/factplusplus/AxiomPointer;
60 */
61 JNIEXPORT jobjectArray JNICALL Java_uk_ac_manchester_cs_factplusplus_FaCTPlusPlus_getAtomAxioms
62 (JNIEnv * env, jobject obj, jint index)
63 {
64 TRACE_JNI("getAtomAxioms");
65 TJNICache* J = getJ(env,obj);
66 return J->buildArray ( J->K->getAtomAxioms(index), J->AxiomPointer );
67 }
68
69 /*
70 * Class: uk_ac_manchester_cs_factplusplus_FaCTPlusPlus
71 * Method: getAtomModule
72 * Signature: (I)[Luk/ac/manchester/cs/factplusplus/AxiomPointer;
73 */
74 JNIEXPORT jobjectArray JNICALL Java_uk_ac_manchester_cs_factplusplus_FaCTPlusPlus_getAtomModule
75 (JNIEnv * env, jobject obj, jint index)
76 {
77 TRACE_JNI("getAtomModule");
78 TJNICache* J = getJ(env,obj);
79 return J->buildArray ( J->K->getAtomModule(index), J->AxiomPointer );
80 }
81
82 /*
83 * Class: uk_ac_manchester_cs_factplusplus_FaCTPlusPlus
84 * Method: getAtomDependents
85 * Signature: (I)[I
86 */
87 JNIEXPORT jintArray JNICALL Java_uk_ac_manchester_cs_factplusplus_FaCTPlusPlus_getAtomDependents
88 (JNIEnv * env, jobject obj, jint index)
89 {
90 TRACE_JNI("getAtomDependents");
91 const TOntologyAtom::AtomSet aSet = getK(env,obj)->getAtomDependents(index);
92 size_t sz = aSet.size();
93 jint* buf = new jint[sz];
94 TOntologyAtom::AtomSet::const_iterator p = aSet.begin();
95 for ( size_t i = 0; i < sz; ++i, ++p )
96 buf[i] = (*p)->getId();
97 jint size = (jint)sz;
98 jintArray ret = env->NewIntArray(size);
99 env->SetIntArrayRegion ( ret, 0, size, buf );
100 delete [] buf;
101 return ret;
102 }
103
104 /*
105 * Class: uk_ac_manchester_cs_factplusplus_FaCTPlusPlus
106 * Method: getLocCheckNumber
107 * Signature: ()I
108 */
109 JNIEXPORT jint JNICALL Java_uk_ac_manchester_cs_factplusplus_FaCTPlusPlus_getLocCheckNumber
110 (JNIEnv * env, jobject obj)
111 {
112 TRACE_JNI("getLocCheckNumber");
113 TJNICache* J = getJ(env,obj);
114 return J->K->getLocCheckNumber();
115 }
116
117 /*
118 * Class: uk_ac_manchester_cs_factplusplus_FaCTPlusPlus
119 * Method: getModule
120 * Signature: (ZI)[Luk/ac/manchester/cs/factplusplus/AxiomPointer;
121 */
122 JNIEXPORT jobjectArray JNICALL Java_uk_ac_manchester_cs_factplusplus_FaCTPlusPlus_getModule
123 (JNIEnv * env, jobject obj, jint moduleMethod, jint moduleType)
124 {
125 TRACE_JNI("getModule");
126 TJNICache* J = getJ(env,obj);
127 return J->buildArray ( J->K->getModule(moduleMethodByInt(moduleMethod),moduleTypeByInt(moduleType)), J->AxiomPointer );
128 }
129
130 /*
131 * Class: uk_ac_manchester_cs_factplusplus_FaCTPlusPlus
132 * Method: getNonLocal
133 * Signature: (ZI)[Luk/ac/manchester/cs/factplusplus/AxiomPointer;
134 */
135 JNIEXPORT jobjectArray JNICALL Java_uk_ac_manchester_cs_factplusplus_FaCTPlusPlus_getNonLocal
136 (JNIEnv * env, jobject obj, jint moduleMethod, jint moduleType)
137 {
138 TRACE_JNI("getNonLocal");
139 TJNICache* J = getJ(env,obj);
140 return J->buildArray ( J->K->getNonLocal(moduleMethodByInt(moduleMethod),moduleTypeByInt(moduleType)), J->AxiomPointer );
141 }
142
143 #ifdef __cplusplus
144 }
145 #endif