Debian Codegraph @

Source/Reasoner/Ontology/CABox.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 "CABox.h"
22
23
24 namespace Konclude {
25
26 namespace Reasoner {
27
28 namespace Ontology {
29
30
31 CABox::CABox(CBoxContext* boxContext) {
32 mBoxContext = boxContext;
33 mMemMan = CContext::getMemoryAllocationManager(mBoxContext);
34 mIndiVec = nullptr;
35 mDeleteBoxContext = nullptr;
36 mActiveIndividualSet = nullptr;
37 mUnivConnIndiID = 0;
38 mHasUnivConnIndiID = false;
39
40 mNextIndividualId = 0;
41 }
42
43
44 CABox::~CABox() {
45 delete mDeleteBoxContext;
46 COPADestroyAndRelease(mIndiVec,mMemMan);
47 }
48
49
50 CABox *CABox::setIndividualVector(CIndividualVector* roleVec) {
51 COPADestroyAndRelease(mIndiVec,mMemMan);
52 mIndiVec = roleVec;
53 return this;
54 }
55
56 CIndividualVector* CABox::getIndividualVector(bool create) {
57 if (!mIndiVec && create) {
58 mIndiVec = CObjectParameterizingAllocator<CIndividualVector,CBoxContext*>::allocateAndConstructAndParameterize(CContext::getMemoryAllocationManager(mBoxContext),mBoxContext);
59 }
60 return mIndiVec;
61 }
62
63 qint64 CABox::getIndividualCount() {
64 cint64 indiCount = 0;
65 if (mIndiVec) {
66 indiCount = mIndiVec->getItemCount();
67 }
68 return indiCount;
69 }
70
71
72
73 CABox *CABox::getABoxReferenceCopy(CBoxContext *boxContext) {
74 CABox *aBox = CObjectParameterizingAllocator<CABox,CBoxContext*>::allocateAndConstructAndParameterize(CContext::getMemoryAllocationManager(boxContext),boxContext);
75 aBox->referenceABox(this);
76 return aBox;
77 }
78
79
80 CABox *CABox::referenceABox(CABox *aBox) {
81 mHasUnivConnIndiID = aBox->mHasUnivConnIndiID;
82 mUnivConnIndiID = aBox->mUnivConnIndiID;
83 mNextIndividualId = aBox->mNextIndividualId;
84 if (aBox->mIndiVec) {
85 getIndividualVector();
86 mIndiVec->referenceVector(aBox->mIndiVec);
87 } else if (mIndiVec) {
88 mIndiVec->clear();
89 }
90 return this;
91 }
92
93
94 CBoxContext *CABox::getBoxContext(bool create) {
95 if (!mBoxContext && create) {
96 mBoxContext = new CConcreteOntologyContextBase();
97 mDeleteBoxContext = mBoxContext;
98 }
99 return mBoxContext;
100 }
101
102
103 cint64 CABox::getUniversalConnectionIndividualID() {
104 return mUnivConnIndiID;
105 }
106
107 CABox* CABox::setUniversalConnectionIndividualID(cint64 univConnIndiID) {
108 mUnivConnIndiID = univConnIndiID;
109 return this;
110 }
111
112 bool CABox::hasUniversalConnectionIndividual() {
113 return mHasUnivConnIndiID;
114 }
115
116 CABox* CABox::setHasUniversalConnectionIndividual(bool hasUnivConnIndi) {
117 mHasUnivConnIndiID = hasUnivConnIndi;
118 return this;
119 }
120
121
122
123
124 CBOXSET<CIndividual*>* CABox::getActiveIndividualSet(bool create) {
125 if (!mActiveIndividualSet && create) {
126 mActiveIndividualSet = CObjectParameterizingAllocator< CBOXSET<CIndividual*> ,CBoxContext*>::allocateAndConstructAndParameterize(CContext::getMemoryAllocationManager(mBoxContext),mBoxContext);
127 }
128 return mActiveIndividualSet;
129 }
130
131 CABox* CABox::setActiveIndividualSet(CBOXSET<CIndividual*>* takeActiveIndividualSet) {
132 mActiveIndividualSet = takeActiveIndividualSet;
133 return this;
134 }
135
136 cint64 CABox::getNextIndividualId(bool increment) {
137 if (mNextIndividualId == 0) {
138 if (mIndiVec) {
139 mNextIndividualId = mIndiVec->getItemCount() + 1;
140 }
141 }
142 if (increment) {
143 return mNextIndividualId++;
144 } else {
145 return mNextIndividualId;
146 }
147 }
148
149 CABox* CABox::setNextIndividualId(cint64 nextIndividualId) {
150 mNextIndividualId = nextIndividualId;
151 return this;
152 }
153
154
155 }; // end namespace Ontology
156
157 }; // end namespace Reasoner
158
159 }; // end namespace Konclude