1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
|
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<TITLE>nevrax.org : docs</TITLE>
<LINK REL=stylesheet TYPE="text/css" HREF="/inc/css/nevrax.css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY MARGINHEIGHT="0" MARGINWIDTH="0">
<!-- uplinks -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0>
<TR>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=><b>Home</B></FONT></A> </TD>
<TD><IMG width=6 height=14 SRC="/inc/img/reddots.gif" ALT="#" VSPACE=2 HSPACE=2 BORDER=0 ></TD><TD VALIGN=middle> <A CLASS=uplinks HREF=><b>nevrax.com</B></FONT></A> </TD>
</TR>
</TABLE>
<!-- banner Nevrax -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 WIDTH=100%>
<TR><TD BGCOLOR="#000000" BACKGROUND="/inc/img/black_banner.jpg"><A HREF=""><IMG SRC="/inc/img/nevrax.gif" WIDTH="170" HEIGHT="45" BORDER=0 ALT="Nevrax" ></A></TD></TR>
</TABLE>
<!-- main table -->
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0 height=100%>
<TR>
<TD WIDTH=16><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="10" BORDER=0 ALT=""></TD>
<TD WIDTH=140 BGCOLOR=#dddddd VALIGN=TOP ALIGN=middle><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!------ Begin Box ------>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 BGCOLOR=black><TR><TD><TABLE border=0 cellspacing=2 cellpadding=0 width=120><tr><TD ALIGN=middle bgcolor=black>
<FONT COLOR=white FACE="sans-serif"><B>Nevrax.org</B></FONT></TD></TR><tr><td colspan=2 bgcolor=#FFFFFF>
<TABLE cellspacing=0 cellpadding=1 border=0>
<tr><td ALIGN=middle><a class='linkbox' href="/news/" TITLE="Rubrique news"><img width=13 height=15 hspace=5 border=0 src=/inc/img/picto-news.gif ALT=#></A></td><td><a class='linkbox' href="/news/" TITLE="News">News</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/mail/" TITLE="Rubrique mail"><img width=15 height=11 hspace=5 border=0 src=/inc/img/picto-mail.gif ALT=#></A></td><td><a class='linkbox' href="/mail/" TITLE="Mailing list archive">Mailing-list</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/docs/" TITLE="Rubrique docs"><img width=14 height=16 hspace=5 border=0 src=/inc/img/picto-docs.gif ALT=#></A></td><td><a class='linkbox' href="/docs/" TITLE="Documentation">Documentation</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/cvs/" TITLE="Rubrique cvs"><img width=13 height=17 hspace=5 border=0 src=/inc/img/picto-cvs.gif ALT=#></A></td><td><a class='linkbox' href="/cvs/" TITLE="CVS Web">CVS</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/bugs/" TITLE="Rubrique bugs"><img width=20 height=16 hspace=5 border=0 src=/inc/img/picto-bugs.gif ALT=#></A></td><td><a class='linkbox' href="/bugs/" TITLE="Bugtracking">Bugs</a></td></tr>
<tr><td ALIGN=middle><a class='linkbox' href="/GPL.php3" TITLE="Rubrique license"><img width=18 height=12 hspace=5 border=0 src=/inc/img/picto-gpl.gif ALT=#></A></td><td><a class='linkbox' href="/GPL.php3" TITLE="License">License</a></td></tr>
</TABLE>
</TD></TR></TABLE></TD></TR></TABLE>
<!------ End Box ------>
</TD>
<TD WIDTH=15><IMG SRC="/inc/img/pixel.gif" WIDTH="16" HEIGHT="16" BORDER=0 ALT=""></TD>
<TD ALIGN=left valign=top><IMG SRC="/inc/img/pixel.gif" WIDTH="140" HEIGHT="10" BORDER=0 ALT="">
<!-- title -->
<TABLE background="/inc/img/redline.gif" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td>
<A HREF="/docs/"><img src="/inc/img/t_docs.gif" ALT="Docs" HEIGHT=20 BORDER=0></A>
</td><td><IMG SRC="/inc/img/pixel.gif" WIDTH="1" HEIGHT="1" BORDER=0 ALT="">
</td></tr></table>
<!-- block -->
<TABLE bgcolor="#dddddd" CELLSPACING=0 CELLPADDING=0 BORDER=0 width=100%><tr><td width=1% valign=middle><img width=6 height=14 hspace=2 vspace=2 src="/inc/img/reddots.gif"></TD>
<TD><B>Documentation</B></TD>
<TD ALIGN=RIGHT> </td>
</tr></table>
<!-- Generated by Doxygen 1.2.14 -->
<center>
<a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> <a class="qindexRef" doxygen="_cgi:/cgi-bin/nel-search.cgi" href="/cgi-bin/nel-search.cgi">Search</a> </center>
<hr><h1>clause.cpp</h1><a href="clause_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="comment">/* Copyright, 2000 Nevrax Ltd.</font>
00002 <font class="comment"> *</font>
00003 <font class="comment"> * This file is part of NEVRAX <MODULE_NAME>.</font>
00004 <font class="comment"> * NEVRAX <MODULE_NAME> is free software; you can redistribute it and/or modify</font>
00005 <font class="comment"> * it under the terms of the GNU General Public License as published by</font>
00006 <font class="comment"> * the Free Software Foundation; either version 2, or (at your option)</font>
00007 <font class="comment"> * any later version.</font>
00008 <font class="comment"></font>
00009 <font class="comment"> * NEVRAX <MODULE_NAME> is distributed in the hope that it will be useful, but</font>
00010 <font class="comment"> * WITHOUT ANY WARRANTY; without even the implied warranty of</font>
00011 <font class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</font>
00012 <font class="comment"> * General Public License for more details.</font>
00013 <font class="comment"></font>
00014 <font class="comment"> * You should have received a copy of the GNU General Public License</font>
00015 <font class="comment"> * along with NEVRAX <MODULE_NAME>; see the file COPYING. If not, write to the</font>
00016 <font class="comment"> * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,</font>
00017 <font class="comment"> * MA 02111-1307, USA.</font>
00018 <font class="comment"> */</font>
00019
00020 <font class="preprocessor">#include "<a class="code" href="clause_8h.html">nel/ai/logic/clause.h</a>"</font>
00021 <font class="preprocessor">#include "<a class="code" href="boolval_8h.html">nel/ai/logic/boolval.h</a>"</font>
00022 <font class="preprocessor">#include "<a class="code" href="ai__assert_8h.html">nel/ai/logic/ai_assert.h</a>"</font>
00023 <font class="preprocessor">#include "<a class="code" href="valueset_8h.html">nel/ai/logic/valueset.h</a>"</font>
00024 <font class="preprocessor">#include "<a class="code" href="fo__assert_8h.html">nel/ai/logic/fo_assert.h</a>"</font>
00025
00026 <font class="keyword">namespace </font>NLAILOGIC
00027 {
00028 <font class="keyword">using</font> <font class="keyword">namespace </font>NLAIAGENT;
00029
<a name="l00030"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a0">00030</a> CClause::CClause()
00031 {
00032 <a class="code" href="classNLAILOGIC_1_1CClause.html#n3">_Liaisons</a>.push_back( <font class="keyword">new</font> CValueSet( <a class="code" href="classNLAILOGIC_1_1CVarSet.html#n0">_Vars</a>.size() ) );
00033 <a class="code" href="classNLAILOGIC_1_1CClause.html#n6">_NbValid</a> = 0;
00034 }
00035
<a name="l00036"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a2">00036</a> CClause::CClause(<a class="code" href="classstd_1_1list.html">std::list<CFactPattern *></a> &conds) : CVarSet()
00037 {
00038 <a class="code" href="classNLAILOGIC_1_1CClause.html#n6">_NbValid</a> = 0;
00039 <a class="code" href="classstd_1_1list.html">std::list<CFactPattern *></a>::iterator it_c = conds.begin();
00040 <font class="keywordflow">while</font> ( it_c != conds.end() )
00041 {
00042 <a class="code" href="classNLAILOGIC_1_1CClause.html#a4">addCond</a>( (CFactPattern *) (*it_c)->clone() );
00043 it_c++;
00044 }
00045 <a class="code" href="classNLAILOGIC_1_1CClause.html#n3">_Liaisons</a>.push_back( <font class="keyword">new</font> CValueSet( <a class="code" href="classNLAILOGIC_1_1CVarSet.html#n0">_Vars</a>.size() ) );
00046 }
00047
<a name="l00048"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a1">00048</a> CClause::CClause(<font class="keyword">const</font> CClause &cl) : CVarSet(cl)
00049
00050 {
00051 <a class="code" href="classNLAILOGIC_1_1CClause.html#n6">_NbValid</a> = cl._NbValid;
00052 std::vector<IBaseBoolType *>::const_iterator it_c = cl._Conds.begin();
00053 <font class="keywordflow">while</font> ( it_c != cl._Conds.end() )
00054 {
00055 <a class="code" href="classNLAILOGIC_1_1CClause.html#a4">addCond</a>( (CFactPattern *) *it_c );
00056 it_c++;
00057 }
00058
00059 std::vector< std::vector<sint32> >::const_iterator it_li = cl._PosVarsCond.begin();
00060 <font class="keywordflow">while</font> ( it_li != cl._PosVarsCond.end() )
00061 {
00062 std::vector<sint32>::const_iterator it_i = (*it_li).begin();
00063 <a class="code" href="classNLAILOGIC_1_1CClause.html#n2">_PosVarsCond</a>.push_back( std::vector<sint32>() );
00064
00065 <font class="keywordflow">while</font> ( it_i != (*it_li).end() )
00066 {
00067 <a class="code" href="classNLAILOGIC_1_1CClause.html#n2">_PosVarsCond</a>.back().push_back( *it_i ) ;
00068 it_i++;
00069 }
00070 it_li++;
00071 }
00072 }
00073
<a name="l00074"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a3">00074</a> CClause::~CClause()
00075 {
00076 <font class="keywordflow">for</font> ( <a class="code" href="types__nl_8h.html#a9">sint32</a> i = 0; i < (sint32) <a class="code" href="classNLAILOGIC_1_1CClause.html#n1">_Conds</a>.size(); i++ )
00077 <a class="code" href="classNLAILOGIC_1_1CClause.html#n1">_Conds</a>[i]->release();
00078
00079 <font class="keywordflow">while</font> ( ! <a class="code" href="classNLAILOGIC_1_1CClause.html#n5">_Conflits</a>.empty() )
00080 {
00081 <font class="keyword">delete</font> <a class="code" href="classNLAILOGIC_1_1CClause.html#n5">_Conflits</a>.front();
00082 <a class="code" href="classNLAILOGIC_1_1CClause.html#n5">_Conflits</a>.pop_front();
00083 }
00084
00085 <font class="keywordflow">while</font> ( ! <a class="code" href="classNLAILOGIC_1_1CClause.html#n3">_Liaisons</a>.empty() )
00086 {
00087 <font class="keyword">delete</font> <a class="code" href="classNLAILOGIC_1_1CClause.html#n3">_Liaisons</a>.front();
00088 <a class="code" href="classNLAILOGIC_1_1CClause.html#n3">_Liaisons</a>.pop_front();
00089 }
00090
00091 <font class="keywordflow">while</font> ( ! <a class="code" href="classNLAILOGIC_1_1CClause.html#n4">_BufLiaisons</a>.empty() )
00092 {
00093 <font class="keyword">delete</font> <a class="code" href="classNLAILOGIC_1_1CClause.html#n4">_BufLiaisons</a>.front();
00094 <a class="code" href="classNLAILOGIC_1_1CClause.html#n4">_BufLiaisons</a>.pop_front();
00095 }
00096 }
00097
<a name="l00098"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a11">00098</a> <font class="keyword">const</font> <a class="code" href="classNLAIC_1_1IBasicType.html">NLAIC::IBasicType</a> *CClause::clone()<font class="keyword"> const</font>
00099 <font class="keyword"> </font>{
00100 <a class="code" href="classNLAILOGIC_1_1CClause.html#a0">CClause</a> *<a class="code" href="classNLAILOGIC_1_1CClause.html#a11">clone</a> = <font class="keyword">new</font> <a class="code" href="classNLAILOGIC_1_1CClause.html#a0">CClause</a>( *<font class="keyword">this</font> );
00101 <font class="keywordflow">return</font> <a class="code" href="classNLAILOGIC_1_1CClause.html#a11">clone</a>;
00102 }
00103
<a name="l00104"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a12">00104</a> <font class="keyword">const</font> <a class="code" href="classNLAIC_1_1IBasicType.html">NLAIC::IBasicType</a> *CClause::newInstance()<font class="keyword"> const</font>
00105 <font class="keyword"> </font>{
00106 <a class="code" href="classNLAILOGIC_1_1CClause.html#a0">CClause</a> *instance = <font class="keyword">new</font> <a class="code" href="classNLAILOGIC_1_1CClause.html#a0">CClause</a>();
00107 <font class="keywordflow">return</font> instance;
00108 }
00109
<a name="l00110"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#b0">00110</a> <a class="code" href="types__nl_8h.html#a9">sint32</a> CClause::findAssert(IBaseAssert *a)
00111 {
00112 <font class="keywordflow">if</font> ( a )
00113 <font class="keywordflow">for</font> ( <a class="code" href="types__nl_8h.html#a9">sint32</a> i = 0; i < (sint32)<a class="code" href="classNLAILOGIC_1_1CClause.html#n7">_Asserts</a>.size(); i++ )
00114 {
00115 <font class="keywordflow">if</font> ( <a class="code" href="classNLAILOGIC_1_1CClause.html#n7">_Asserts</a>[i]->getName() == a->getName() )
00116 {
00117 <font class="keywordflow">return</font> i;
00118 }
00119 }
00120
00121 <font class="keywordflow">return</font> -1;
00122 }
00123
<a name="l00124"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a4">00124</a> <font class="keywordtype">void</font> CClause::addCond(CFactPattern *cond)
00125 {
00126 <a class="code" href="classNLAILOGIC_1_1CClause.html#n1">_Conds</a>.push_back( (CFactPattern *) cond->clone() );
00127
00128 <font class="comment">// Recherche l'assertion</font>
00129 <a class="code" href="types__nl_8h.html#a9">sint32</a> pos_assert= <a class="code" href="classNLAILOGIC_1_1CClause.html#b0">findAssert</a>( cond->getAssert() );
00130 <font class="keywordflow">if</font> ( pos_assert < 0 )
00131 {
00132 <a class="code" href="classNLAILOGIC_1_1CClause.html#n7">_Asserts</a>.push_back( cond->getAssert() );
00133 pos_assert = <a class="code" href="classNLAILOGIC_1_1CClause.html#n7">_Asserts</a>.size();
00134 }
00135
00136 <font class="comment">// Recherche si variables � ajouter</font>
00137 std::vector<sint32> pos_vars;
00138 std::vector<IBaseVar *> *vars_cond = cond->getVars();
00139 <font class="keywordflow">if</font> ( vars_cond )
00140 {
00141 std::vector<IBaseVar *>::iterator it_cond = vars_cond->begin();
00142 <font class="keywordflow">while</font> ( it_cond != vars_cond->end() )
00143 {
00144 <font class="keywordtype">bool</font> found;
00145 <font class="keywordflow">if</font> ( <a class="code" href="classNLAILOGIC_1_1CVarSet.html#n0">_Vars</a>.size() )
00146 {
00147 found = <font class="keyword">false</font>;
00148 <font class="keywordflow">for</font> (<a class="code" href="types__nl_8h.html#a9">sint32</a> i = 0; i < (sint32)<a class="code" href="classNLAILOGIC_1_1CVarSet.html#n0">_Vars</a>.size() ; i++ )
00149 {
00150 <font class="keywordflow">if</font> ( ( *it_cond )->getName() == <a class="code" href="classNLAILOGIC_1_1CVarSet.html#n0">_Vars</a>[ i ]->getName() )
00151 {
00152 found = <font class="keyword">true</font>;
00153 pos_vars.push_back( i );
00154 }
00155 }
00156 }
00157 <font class="keywordflow">else</font>
00158 found = <font class="keyword">false</font>;
00159
00160 <font class="keywordflow">if</font> ( !found )
00161 {
00162 <a class="code" href="classNLAILOGIC_1_1CVarSet.html#n0">_Vars</a>.push_back( (IBaseVar *)(*it_cond)->clone() );
00163 pos_vars.push_back( <a class="code" href="classNLAILOGIC_1_1CVarSet.html#n0">_Vars</a>.size() - 1);
00164 }
00165 it_cond++;
00166 }
00167 }
00168
00169 <font class="comment">// Pr�venir l'assertion</font>
00170 <font class="keywordflow">if</font> ( cond->getAssert() )
00171 {
00172 ((CFirstOrderAssert *) cond->getAssert())->addClause( <font class="keyword">this</font>, pos_vars );
00173 <a class="code" href="classNLAILOGIC_1_1CClause.html#n2">_PosVarsCond</a>.push_back( pos_vars );
00174 }
00175
00176 <font class="keywordflow">for</font> ( <a class="code" href="types__nl_8h.html#a9">sint32</a> i = 0; i < (sint32) vars_cond->size(); i++ )
00177 {
00178 (*vars_cond)[i]->release();
00179 }
00180 <font class="keyword">delete</font> vars_cond;
00181 }
00182
<a name="l00183"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a5">00183</a> <font class="keywordtype">void</font> CClause::getDebugString(std::string &txt)<font class="keyword"> const</font>
00184 <font class="keyword"> </font>{
00185 txt += <font class="stringliteral">"CClause "</font>;
00186 <font class="keywordflow">for</font> (<a class="code" href="types__nl_8h.html#a9">sint32</a> i = 0; i < (sint32)<a class="code" href="classNLAILOGIC_1_1CVarSet.html#n0">_Vars</a>.size(); i++ )
00187 {
00188 std::string buf;
00189 <a class="code" href="classNLAILOGIC_1_1CVarSet.html#n0">_Vars</a>[ i ]->getDebugString( buf );
00190 txt += <font class="stringliteral">" - "</font>;
00191 txt += buf;
00192 }
00193 }
00194
<a name="l00195"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a9">00195</a> <font class="keywordtype">void</font> CClause::propagate(CFactPattern *fp)
00196 {
00197 <font class="comment">// Pour chaque liaison...</font>
00198 <font class="comment">/* std::list< CValueSet *>::iterator it_l = _Liaisons.begin();</font>
00199 <font class="comment"> </font>
00200 <font class="comment"> while ( it_l != _Liaisons.end() )</font>
00201 <font class="comment"> {</font>
00202 <font class="comment"> CValueSet *result;</font>
00203 <font class="comment"> if ( result = fp->unify( *it_l ) )</font>
00204 <font class="comment"> {</font>
00205 <font class="comment"> if ( result->undefined() == 0 )</font>
00206 <font class="comment"> _Conflits.push_back( result );</font>
00207 <font class="comment"> else </font>
00208 <font class="comment"> _BufLiaisons.push_back( result );</font>
00209 <font class="comment"> }</font>
00210 <font class="comment"> it_l++;</font>
00211 <font class="comment"> }*/</font>
00212 }
00213
00214 <font class="keywordtype">void</font> CClause::propagate(<a class="code" href="classstd_1_1list.html">std::list<IObjectIA *></a> *vals, std::vector<sint32> &pos_vals)
00215 {
00216 <font class="comment">// Pour chaque liaison...</font>
00217 <a class="code" href="classstd_1_1list.html">std::list< CValueSet *></a>::iterator it_l = <a class="code" href="classNLAILOGIC_1_1CClause.html#n3">_Liaisons</a>.begin();
00218
00219 <font class="keywordflow">while</font> ( it_l != <a class="code" href="classNLAILOGIC_1_1CClause.html#n3">_Liaisons</a>.end() )
00220 {
00221 <font class="comment">// char buf[512];</font>
00222 CValueSet *<a class="code" href="namespaceNLAISCRIPT.html#a20">l</a> = *it_l;
00223 <font class="comment">/* l->getDebugString( buf );</font>
00224 <font class="comment"> TRACE( "Pour liaison: %s \n", buf );*/</font>
00225 CValueSet *result = <a class="code" href="classNLAILOGIC_1_1CClause.html#a7">unifyLiaison</a>( <a class="code" href="namespaceNLAISCRIPT.html#a20">l</a>, vals, pos_vals );
00226 <font class="keywordflow">if</font> ( result )
00227 {
00228
00229 <font class="comment">/* char buf[512];</font>
00230 <font class="comment"> result->getDebugString( buf );</font>
00231 <font class="comment"> TRACE( "Unification: %s \n", buf );*/</font>
00232
00233 <font class="keywordflow">if</font> ( result->undefined() == 0 )
00234 {
00235 <a class="code" href="classNLAILOGIC_1_1CClause.html#n5">_Conflits</a>.push_back( result );
00236 <a class="code" href="classNLAILOGIC_1_1CClause.html#n6">_NbValid</a>++;
00237 }
00238
00239 <font class="keywordflow">else</font>
00240 <a class="code" href="classNLAILOGIC_1_1CClause.html#n4">_BufLiaisons</a>.push_back( result );
00241 }
00242 it_l++;
00243 }
00244
00245 <a class="code" href="classNLAILOGIC_1_1CClause.html#a21">addBuffer</a>();
00246 <a class="code" href="classNLAILOGIC_1_1CClause.html#a22">addConflicts</a>();
00247
00248 }
00249
00250 <font class="comment">// Tente d'unifier deux instanciations partielles des variables de la CClause</font>
00251 CValueSet *CClause::unifyLiaison( <font class="keyword">const</font> CValueSet *fp, <a class="code" href="classstd_1_1list.html">std::list<IObjectIA *></a> *vals, std::vector<sint32> &pos_vals)
00252 {
00253 CValueSet *result;
00254
00255 <font class="keywordflow">if</font> ( (result = fp->unify( vals, pos_vals )) )
00256 <font class="keywordflow">return</font> result;
00257 <font class="keywordflow">else</font>
00258 {
00259 <font class="keyword">delete</font> result;
00260 <font class="keywordflow">return</font> NULL;
00261 }
00262 }
00263
<a name="l00264"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a13">00264</a> IObjetOp *CClause::operator ! ()<font class="keyword"> const</font>
00265 <font class="keyword"> </font>{
00266
00267 <font class="keywordflow">return</font> <font class="keyword">new</font> CBoolType( !<a class="code" href="classNLAILOGIC_1_1CClause.html#a16">isTrue</a>() );
00268 }
00269
<a name="l00270"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a14">00270</a> IObjetOp *CClause::operator != (IObjetOp &a)<font class="keyword"> const</font>
00271 <font class="keyword"> </font>{
00272 <font class="keywordflow">return</font> <font class="keyword">new</font> CBoolType( <a class="code" href="classNLAILOGIC_1_1CClause.html#a16">isTrue</a>() != a.isTrue() );
00273 }
00274
<a name="l00275"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a16">00275</a> <font class="keywordtype">bool</font> CClause::isTrue()<font class="keyword"> const</font>
00276 <font class="keyword"> </font>{
00277 <font class="keywordflow">return</font> ( <a class="code" href="classNLAILOGIC_1_1CClause.html#n6">_NbValid</a> > 0 );
00278 }
00279
<a name="l00280"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a17">00280</a> <font class="keywordtype">float</font> CClause::truthValue()<font class="keyword"> const</font>
00281 <font class="keyword"> </font>{
00282 <font class="keywordflow">if</font> ( <a class="code" href="classNLAILOGIC_1_1CClause.html#n6">_NbValid</a> > 0 )
00283 <font class="keywordflow">return</font> 1.0;
00284 <font class="keywordflow">else</font>
00285 <font class="keywordflow">return</font> 0.0;
00286 }
00287
<a name="l00288"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a15">00288</a> IObjetOp *CClause::operator == (IObjetOp &a)<font class="keyword"> const</font>
00289 <font class="keyword"> </font>{
00290 <font class="keywordflow">return</font> <font class="keyword">new</font> CBoolType( <a class="code" href="classNLAILOGIC_1_1CClause.html#a16">isTrue</a>() == a.isTrue() );
00291 }
00292
<a name="l00293"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a18">00293</a> <font class="keywordtype">void</font> CClause::showConflicts()
00294 {
00295 <a class="code" href="classstd_1_1list.html">std::list<CValueSet *></a>::iterator it_vs = <a class="code" href="classNLAILOGIC_1_1CClause.html#n5">_Conflits</a>.begin();
00296 <font class="keywordflow">while</font> ( it_vs != <a class="code" href="classNLAILOGIC_1_1CClause.html#n5">_Conflits</a>.end() )
00297 {
00298 std::string buf;
00299 ( *it_vs )->getDebugString( buf );
00300 it_vs++;
00301 }
00302 }
00303
<a name="l00304"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a19">00304</a> <font class="keywordtype">void</font> CClause::showBuffer()
00305 {
00306 <a class="code" href="classstd_1_1list.html">std::list<CValueSet *></a>::iterator it_vs = <a class="code" href="classNLAILOGIC_1_1CClause.html#n4">_BufLiaisons</a>.begin();
00307 <font class="keywordflow">while</font> ( it_vs != <a class="code" href="classNLAILOGIC_1_1CClause.html#n4">_BufLiaisons</a>.end() )
00308 {
00309 std::string buf;
00310 ( *it_vs )->getDebugString( buf );
00311 it_vs++;
00312 }
00313 }
00314
<a name="l00315"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a20">00315</a> <font class="keywordtype">void</font> CClause::showLiaisons()
00316 {
00317 <a class="code" href="classstd_1_1list.html">std::list<CValueSet *></a>::iterator it_vs = <a class="code" href="classNLAILOGIC_1_1CClause.html#n3">_Liaisons</a>.begin();
00318 <font class="keywordflow">while</font> ( it_vs != <a class="code" href="classNLAILOGIC_1_1CClause.html#n3">_Liaisons</a>.end() )
00319 {
00320 std::string buf;
00321 ( *it_vs )->getDebugString( buf );
00322 it_vs++;
00323 }
00324 }
00325
00326
00327 <font class="comment">// Transfert des liaisons du buffer � la liste des liaisons</font>
<a name="l00328"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a21">00328</a> <font class="keywordtype">void</font> CClause::addBuffer()
00329 {
00330 <font class="keywordflow">while</font> ( !<a class="code" href="classNLAILOGIC_1_1CClause.html#n4">_BufLiaisons</a>.empty() )
00331 {
00332 <a class="code" href="classNLAILOGIC_1_1CClause.html#n3">_Liaisons</a>.push_back( <a class="code" href="classNLAILOGIC_1_1CClause.html#n4">_BufLiaisons</a>.front() );
00333 std::string buf;
00334 <a class="code" href="classNLAILOGIC_1_1CClause.html#n4">_BufLiaisons</a>.front()->getDebugString( buf );
00335 <font class="comment">//TRACE ( "Ajout de la liaison du buffer: %s ", buf );</font>
00336 <a class="code" href="classNLAILOGIC_1_1CClause.html#n4">_BufLiaisons</a>.pop_front();
00337 }
00338 }
00339
00340 <font class="comment">// Traitement des conflits</font>
<a name="l00341"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a22">00341</a> <font class="keywordtype">void</font> CClause::addConflicts()
00342 {
00343 }
00344
00345 <font class="comment">// Renvoie les assertions des conditions de la CClause</font>
00346 std::vector<IBaseAssert *> &CClause::getAssert()
00347 {
00348 <font class="keywordflow">return</font> <a class="code" href="classNLAILOGIC_1_1CClause.html#n7">_Asserts</a>;
00349 }
00350
<a name="l00351"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a6">00351</a> CVarSet *CClause::unify(CVarSet *)
00352 {
00353 <font class="comment">// TODO:</font>
00354 <font class="comment">/*</font>
00355 <font class="comment"> std::list<CValueSet *>::iterator it_l = _Liaisons.begin();</font>
00356 <font class="comment"> while ( it_cond != _Conds.end() )</font>
00357 <font class="comment"> {</font>
00358 <font class="comment"> CVarSet *tmp = ( *it_cond )->unify( fact );</font>
00359 <font class="comment"> </font>
00360 <font class="comment"> if ( !tmp )</font>
00361 <font class="comment"> return;</font>
00362 <font class="comment"> it_cond++;</font>
00363 <font class="comment"> }</font>
00364 <font class="comment"> */</font>
00365 <font class="keywordflow">return</font> NULL;
00366 }
00367
<a name="l00368"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a10">00368</a> <a class="code" href="classstd_1_1list.html">std::list<CClause *></a> *CClause::getInputs()
00369 {
00370 <font class="keywordflow">return</font> <font class="keyword">new</font> <a class="code" href="classstd_1_1list.html">std::list<CClause *></a>;
00371 }
00372
<a name="l00373"></a><a class="code" href="classNLAILOGIC_1_1CClause.html#a24">00373</a> <a class="code" href="types__nl_8h.html#a9">sint32</a> CClause::nbVars()
00374 {
00375 <font class="keywordflow">return</font> <a class="code" href="classNLAILOGIC_1_1CVarSet.html#n0">_Vars</a>.size();
00376 }
00377
00378 <font class="keywordtype">void</font> CClause::init(IObjectIA *<a class="code" href="driver__opengl__extension__def_8h.html#a235">params</a>)
00379 {
00380 <font class="comment">/* if ( params->size() != 3 )</font>
00381 <font class="comment"> {</font>
00382 <font class="comment"> // TODO throw Exc::....</font>
00383 <font class="comment"> }*/</font>
00384
00385 <font class="comment">// Conditions</font>
00386 CIteratorContener it_fp = ((IBaseGroupType *)<a class="code" href="driver__opengl__extension__def_8h.html#a235">params</a>)->getIterator();
00387 <font class="keywordflow">while</font> ( !it_fp.isInEnd())
00388 {
00389 <a class="code" href="classNLAILOGIC_1_1CClause.html#a4">addCond</a>( (CFactPattern *) it_fp++ );
00390 }
00391 }
00392
00393 <font class="comment">/* const std::vector< std::list<sint32> > &CClause::getPosVar()</font>
00394 <font class="comment"> {</font>
00395 <font class="comment"> return _pos_vars;</font>
00396 <font class="comment"> }</font>
00397 <font class="comment"> */</font>
00398 }
</pre></div>
<!-- footer -->
<BR><FONT Size=+5> </FONT>
</TD>
<TD WIDTH=15><IMG SRC=/inc/img/pixel.gif WIDTH=15 HEIGHT=15 BORDER=0 ALT=""></TD>
</TR>
</TABLE>
</BODY>
</HTML>
|