2 |
|
#include "ConstraintPair.hpp" |
3 |
|
#include "SimInfo.hpp" |
4 |
|
#include "ConstraintManager.hpp" |
5 |
+ |
#include "simError.h" |
6 |
|
|
7 |
|
//////////////////////////////////////////////////////////////////////////////// |
8 |
|
//Implementation of ConstraintAlgorithm |
28 |
|
} |
29 |
|
|
30 |
|
void ConstraintAlgorithm::doConstrain(){ |
31 |
< |
const int maxConsIteration = 30; |
31 |
> |
const int maxConsIteration = 300; |
32 |
|
bool done; |
33 |
|
int iteration; |
34 |
|
int maxIteration; |
38 |
|
int exeStatus; |
39 |
|
|
40 |
|
|
41 |
+ |
error = false; |
42 |
|
|
43 |
|
for(ceIter->first(); !ceIter->isEnd(); ceIter->next()){ |
44 |
|
consElem = ceIter->currentItem(); |
64 |
|
|
65 |
|
switch(exeStatus){ |
66 |
|
case consFail: |
67 |
< |
cerr << "ConstraintAlgorithm::doConstrain() Error: Constraint Fail" << endl; |
67 |
> |
cerr << "ConstraintAlgorithm::doConstrain() Error: Constraint Fail" << endl; |
68 |
> |
error = true; |
69 |
|
break; |
70 |
|
case consSuccess: |
71 |
|
//constrain the pair by moving two elements |
79 |
|
case consPairHandlerFail: |
80 |
|
//can not found call back functor for constraint pair |
81 |
|
cerr << "ConstraintAlgorithm::doConstrain() Error: can not found callback functor for constraint pair " << endl; |
82 |
+ |
error = true; |
83 |
|
break; |
84 |
|
case consElemHandlerFail: |
85 |
|
//can not found callback functor for constraint element |
86 |
|
cerr << "ConstraintAlgorithm::doConstrain() Error: can not found callback functor for constraint element " << endl; |
87 |
+ |
error = true; |
88 |
|
break; |
89 |
|
default: |
90 |
|
cerr << "ConstraintAlgorithm::doConstrain() Error: unrecognized status" << endl; |
91 |
+ |
error = true; |
92 |
|
break; |
93 |
|
} |
94 |
|
}//end for(iter->first()) |
101 |
|
|
102 |
|
iteration++; |
103 |
|
}//end while |
104 |
< |
|
104 |
> |
|
105 |
> |
//if (!done){ |
106 |
> |
// error = true; |
107 |
> |
// sprintf(painCave.errMsg, |
108 |
> |
// "Constraint failure in constrainB, too many iterations: %d\n", |
109 |
> |
// iteration); |
110 |
> |
// painCave.isFatal = 1; |
111 |
> |
// simError(); |
112 |
> |
//} |
113 |
|
} |
114 |
|
|
115 |
|
|
117 |
|
map<TypeInfo, CallbackFunctor*>::iterator foundResult; |
118 |
|
CallbackFunctor* functor; |
119 |
|
|
120 |
< |
foundResult = callbackMap.find(typeid(consPair)); |
120 |
> |
//typeid must operate on deferenced, otherwise it will return the type_info of base class |
121 |
> |
foundResult = callbackMap.find(TypeInfo(typeid(*consPair))); |
122 |
|
if (foundResult != callbackMap.end()){ |
123 |
|
functor = foundResult->second; |
124 |
|
return (*functor)(consPair); |
162 |
|
ConsAlgoFramework::~ConsAlgoFramework(){ |
163 |
|
delete ceIter; |
164 |
|
} |
165 |
+ |
|
166 |
|
void ConsAlgoFramework::doPreConstraint(){ |
167 |
|
ConstraintElement* consElem; |
168 |
|
|
169 |
|
for(ceIter->first(); !ceIter->isEnd(); ceIter->next()){ |
170 |
|
consElem = ceIter->currentItem(); |
171 |
|
consElem->saveOldState(); |
172 |
< |
} |
173 |
< |
} |
172 |
> |
} |
173 |
> |
} |