#include <constraint_stack_component.h>
Inheritance diagram for NLAISCRIPT::CConstraintStackComp:
This class is allow to load component from the stack or the heap.
Nevrax France
Definition at line 40 of file constraint_stack_component.h.
NLMISC::IStreamable method. | |
virtual std::string | getClassName () |
virtual void | serial (NLMISC::IStream &) throw (NLMISC::EStream) |
Public Types | |
enum | ConstraintTypeEnum { constraintMethode, constraintChkMethodeType, operandSimple, operandSimpleListOr, operandAnyObject, operandVoid, operandUnknown, operationType, operationTypeGD, operandListType, constraintStackComp, constraintDebug, constraintFindRun } |
enum | OpCodeType { heapCall, stackCall, heapAffectation } |
This enum give information of the way to load the compoment. More... | |
Public Member Functions | |
void | addConstraint (IConstraint *c) |
Add a constraint dependency. We add a constraint dependency when a given constraint want the result of an other constraint. | |
CConstraintStackComp (OpCodeType opCodeType, sint32 stackPos, const std::list< NLAISCRIPT::CStringType > &memberName, IOpType *typeStack, sint32 lign, sint32 col) | |
sint32 | decRef () |
Decrement the reference of an object. | |
virtual void | getDebugString (std::string &t) const |
const sint32 & | getRef () const |
get the refence count. | |
void | incRef () |
Inc a reference. We use this when we have to conserve a pointer memeory for exemple in a list. | |
void | popConstraint (IConstraint *c) |
pop the last constaint dependency. | |
virtual void | release () |
Release allow to release the pointer. The last release when the _Ref is nul delete the object. | |
void | runConnexcion () |
When a constraint is resoved,we call all dependency. | |
virtual | ~CConstraintStackComp () |
IConstraint method. | |
void | addIndex (sint32 i, CCodeBrancheRun *c) |
const IConstraint * | clone () const |
Get a clone pointer memory. | |
bool | dependOn (const IConstraint *) const |
If this constraint depond on other constraint. | |
int | getColone () const |
get the colone of the expression that it have to be resolve by constraint in the code source. | |
const NLAIC::CIdentType * | getConstraintTypeOf () |
Type of the expression that it have to be resolve by constraint. | |
void | getError (char *) const |
get an error string when the constraint is'nt stisfied. | |
const char * | getInfo () |
Get a string info. | |
int | getLine () const |
get the line of the expression that it have to be resolve by constraint in the code source. | |
virtual ConstraintTypeEnum | getTypeOfClass () const |
get the type of class. the type must be in the ConstraintTypeEnum enumeration. | |
bool | operator== (const IConstraint &c) const |
void | run (IConstraint *) |
Run with a IConstraint dependency. | |
void | run (CCompilateur &) |
Run with a CCompilateur dependency. | |
bool | satisfied () |
If the constraint is resolved. | |
Static Public Member Functions | |
const IOpType * | loadIOpType (NLMISC::IStream &f) |
Loader for IOpType. Not that we save and load an know type. | |
Private Attributes | |
NLAIC::CIdentType * | _Id |
The type of compoment when it resolve. | |
std::list< NLAISCRIPT::CStringType > | _MemberName |
Set herarchy name (a hierarchy name is some thing like classBaseName.className.component). | |
OpCodeType | _OpCodeType |
Type of load. | |
sint32 | _StackPos |
It used when the type is a heapCall and define the heap position. | |
IOpType * | _TypeStack |
Set the type of component, it can be an unresolved constraint. | |
Attribut need for IConstraint method. | |
std::list< std::pair< sint32, CCodeBrancheRun * > > | _Code |
sint32 | _Col |
sint32 | _Lin |
bool | _Satisfied |
char * | _TxtInfo |
|
This enum define all IConstraint class type defined. That is'nt very clean because it is'nt very objects way to do jobs but that make easy to make job with out make heavy the hisarchy class. Because the best way is to derive class form NLAIC::IBasicInterface but we have to register class in class factory, define a save an load ..., in short make a lot of work for an internal work. If later peopole need this kind of class we'll clean it.
Definition at line 138 of file constraint.h.
00139 { 00141 constraintMethode, 00143 constraintChkMethodeType, 00145 operandSimple, 00147 operandSimpleListOr, 00149 operandAnyObject, 00151 operandVoid, 00153 operandUnknown, 00155 operationType, 00157 operationTypeGD, 00159 operandListType, 00161 constraintStackComp, 00163 constraintDebug, 00165 constraintFindRun 00166 }; |
|
This enum give information of the way to load the compoment.
Definition at line 44 of file constraint_stack_component.h.
00044 { 00046 heapCall, 00048 stackCall, 00050 heapAffectation 00051 }; |
|
Definition at line 32 of file constraint_stack_component.cpp. References _MemberName, _OpCodeType, _StackPos, nlinfo, s, sint32, and NLAIC::stringGetBuild(). Referenced by clone().
00032 : 00033 _TypeStack(typeStack),_MemberName(memberName),_Lin(lign),_Col(col) 00034 { 00035 char m[1028*8]; 00036 std::list<NLAISCRIPT::CStringType >::const_iterator i = _MemberName.begin(); 00037 m[0] = 0; 00038 while(i != _MemberName.end()) 00039 { 00040 const NLAISCRIPT::CStringType &s = *i; 00041 strcat(m,s.data()); 00042 i ++; 00043 if(i != _MemberName.end()) strcat(m,"."); 00044 } 00045 std::string text; 00046 text = NLAIC::stringGetBuild("resolve constraint for the component '%s' at line %d",m,_Lin); 00047 _TxtInfo = new char [strlen(text.c_str()) + 1]; 00048 strcpy(_TxtInfo,text.c_str()); 00049 _Satisfied = false; 00050 _Id = NULL; 00051 _OpCodeType = opCodeType; 00052 _StackPos = stackPos; 00053 00054 #ifdef NL_DEBUG 00055 static int kkkkk = 0; 00056 nlinfo("meme %4x, %d",this, kkkkk ++); 00057 #endif 00058 } |
|
Definition at line 60 of file constraint_stack_component.cpp. References _TypeStack, and NLAIC::IPointerGestion::release().
00061 { 00062 _TypeStack->release(); 00063 if(_Id) delete _Id; 00064 delete _TxtInfo; 00065 } |
|
Add a constraint dependency. We add a constraint dependency when a given constraint want the result of an other constraint.
Definition at line 207 of file constraint.h. References NLAISCRIPT::IConstraint::_ConstraintList. Referenced by NLAISCRIPT::COperandUnknown::COperandUnknown().
00208 { 00209 _ConstraintList.push_back(c); 00210 } |
|
Add a op-code dependency. the integer n is the index of the opcode in in the opcodePtr pointer. Implements NLAISCRIPT::IConstraint. Definition at line 55 of file type_def.h.
00055 {} |
|
Definition at line 90 of file constraint_stack_component.h. References sint32.
00091 { 00092 _Code.push_back(std::pair<sint32, CCodeBrancheRun *>(i,c)); 00093 } |
|
Get a clone pointer memory.
Implements NLAISCRIPT::IConstraint. Definition at line 180 of file constraint_stack_component.cpp. References _MemberName, _OpCodeType, _TypeStack, CConstraintStackComp(), NLAIC::IPointerGestion::incRef(), and x.
00181 { 00182 _TypeStack->incRef(); 00183 IConstraint *x = new CConstraintStackComp(_OpCodeType,0,_MemberName,_TypeStack,_Lin,_Col); 00184 return x; 00185 } |
|
Decrement the reference of an object.
Definition at line 93 of file abstract_interface.h. References NLAIC::IPointerGestion::_Ref, and sint32. Referenced by NLAIC::IPointerGestion::release(), and NLAIAGENT::CAgentTimerHandle::~CAgentTimerHandle().
00094 {
00095 return --_Ref;
00096 }
|
|
If this constraint depond on other constraint.
Implements NLAISCRIPT::IConstraint. Definition at line 157 of file constraint_stack_component.cpp. References _TypeStack.
00158 { 00159 return _TypeStack == c; 00160 } |
|
Reimplemented in NLAISCRIPT::COperandSimpleListOr. Definition at line 76 of file type_def.cpp. References NLAISCRIPT::IOpType::evalParam(), NLAISCRIPT::IConstraint::getConstraintTypeOf(), NLAISCRIPT::IConstraint::getTypeOfClass(), NLAISCRIPT::l, and x. Referenced by NLAISCRIPT::CParam::eval().
00077 { 00078 if(getConstraintTypeOf() != NULL && e->getConstraintTypeOf() != NULL) 00079 { 00080 if(e->getTypeOfClass() == operandSimpleListOr) 00081 { 00082 COperandSimpleListOr *l = (COperandSimpleListOr *)e; 00083 std::list<NLAIC::CIdentType *>::const_iterator i = l->getList().begin(); 00084 while(i != l->getList().end() ) 00085 { 00086 COperandSimple *x =new COperandSimple (new NLAIC::CIdentType(*(*i++))); 00087 double d = evalParam(x); 00088 delete x; 00089 if(d >= 0.0) return d; 00090 } 00091 00092 } 00093 else return evalParam(e); 00094 } 00095 return -1.0; 00096 } |
|
Definition at line 34 of file type_def.cpp. References NLAISCRIPT::IClassInterpret::getComputeBaseClass(), NLAISCRIPT::IConstraint::getConstraintTypeOf(), NLAIC::CIdentType::getFactory(), NLAISCRIPT::IClassInterpret::getType(), and type. Referenced by NLAISCRIPT::IOpType::eval().
00035 { 00036 double d; 00037 if(e->getConstraintTypeOf() != NULL) 00038 { 00039 const NLAIC::CIdentType &idG = *getConstraintTypeOf(); 00040 const NLAIC::CIdentType &idD = *e->getConstraintTypeOf(); 00041 if(!(idG == idD)) 00042 { 00043 if(((const NLAIC::CTypeOfObject &)idD) & NLAIC::CTypeOfObject::tInterpret ) 00044 { 00045 IClassInterpret *o = (IClassInterpret *)((CClassInterpretFactory *)idD.getFactory())->getClass(); 00046 bool type = false; 00047 d = 0.0; 00048 while(o != NULL) 00049 { 00050 if( o->getType() == idG) 00051 { 00052 d += 1.0; 00053 type = true; 00054 break; 00055 } 00056 o = (IClassInterpret *)o->getComputeBaseClass(); 00057 } 00058 if(!type) return -1.0; 00059 else return d; 00060 } 00061 else 00062 { 00063 //NLAIC::CTypeOfObject o_t(tNombre | TString | tList | tLogic); 00064 if(((const NLAIC::CTypeOfObject &)idD) & ((const NLAIC::CTypeOfObject &)idG)) 00065 { 00066 return 0.0; 00067 } 00068 else return -1.0; 00069 } 00070 } 00071 else return 0.0; 00072 } 00073 else return -1.0; 00074 } |
|
Implements NLMISC::IClassable. Reimplemented in NLAIC::CIdentType. Definition at line 116 of file abstract_interface.h. Referenced by NLAISCRIPT::CAgentClass::isClassInheritedFrom().
00117 { 00118 return std::string("<unnamed>"); 00119 } |
|
get the colone of the expression that it have to be resolve by constraint in the code source.
Reimplemented from NLAISCRIPT::IOpType. Definition at line 106 of file constraint_stack_component.h.
00107 { 00108 return _Col; 00109 } |
|
Type of the expression that it have to be resolve by constraint.
Implements NLAISCRIPT::IConstraint. Definition at line 187 of file constraint_stack_component.cpp.
00188 { 00189 return _Id; 00190 } |
|
|
get an error string when the constraint is'nt stisfied.
Reimplemented from NLAISCRIPT::IOpType. Definition at line 173 of file constraint_stack_component.cpp. References NLAIC::stringGetBuild().
00174 { 00175 std::string text; 00176 text = NLAIC::stringGetBuild("can't %s",_TxtInfo); 00177 strcpy(txt, (char *)text.c_str()); 00178 } |
|
Get a string info.
Implements NLAISCRIPT::IConstraint. Definition at line 78 of file constraint_stack_component.h.
00079 { 00080 return _TxtInfo; 00081 } |
|
get the line of the expression that it have to be resolve by constraint in the code source.
Reimplemented from NLAISCRIPT::IOpType. Definition at line 102 of file constraint_stack_component.h.
00103 { 00104 return _Lin; 00105 } |
|
get the refence count.
Definition at line 99 of file abstract_interface.h. References NLAIC::IPointerGestion::_Ref, and sint32. Referenced by NLAIAGENT::CAgentTimerHandle::~CAgentTimerHandle().
00100 {
00101 return _Ref;
00102 }
|
|
get the type of class. the type must be in the ConstraintTypeEnum enumeration.
Implements NLAISCRIPT::IConstraint. Definition at line 96 of file constraint_stack_component.h. Referenced by operator==().
00097 { 00098 return constraintStackComp; 00099 } |
|
|
Loader for IOpType. Not that we save and load an know type.
Definition at line 982 of file type_def.h. References NLMISC::IStream::serial(), sint32, and x.
00983 { 00984 IConstraint::ConstraintTypeEnum k = constraintMethode; 00985 IOpType *x; 00986 00987 f.serial((sint32 &)k); 00988 00989 switch(k) 00990 { 00991 case operandAnyObject: 00992 x = new COperandAnyObject(); 00993 return x; 00994 00995 case operandVoid: 00996 x = new COperandVoid(); 00997 return x; 00998 00999 case operandSimple: 01000 x = new COperandSimple(f); 01001 return x; 01002 01003 case operandSimpleListOr: 01004 x = new COperandSimpleListOr(f); 01005 return x; 01006 default: break; 01007 } 01008 return NULL; 01009 } |
|
Implements NLAISCRIPT::IConstraint. Definition at line 162 of file constraint_stack_component.cpp. References _MemberName, _OpCodeType, _StackPos, _TypeStack, NLAISCRIPT::IConstraint::getTypeOfClass(), and getTypeOfClass().
00163 { 00164 if((getTypeOfClass() == c.getTypeOfClass()) && *((const CConstraintStackComp &)c)._TypeStack == *_TypeStack) 00165 { 00166 return ((const CConstraintStackComp &)c)._MemberName == _MemberName && 00167 ((const CConstraintStackComp &)c)._OpCodeType == _OpCodeType && 00168 ((const CConstraintStackComp &)c)._StackPos == _StackPos; 00169 } 00170 return false; 00171 } |
|
pop the last constaint dependency.
Definition at line 32 of file constraint.cpp. References NLAISCRIPT::IConstraint::_ConstraintList. Referenced by NLAISCRIPT::COperandUnknown::~COperandUnknown().
00033 { 00034 std::list<IConstraint *>::iterator it = _ConstraintList.begin(); 00035 while(it != _ConstraintList.end()) 00036 { 00037 if(*it == c) 00038 { 00039 _ConstraintList.erase(it); 00040 break; 00041 } 00042 it ++ ; 00043 } 00044 } |
|
|
Run with a IConstraint dependency.
Reimplemented from NLAISCRIPT::IOpType. Definition at line 153 of file constraint_stack_component.cpp.
00154 { 00155 } |
|
Run with a CCompilateur dependency.
Reimplemented from NLAISCRIPT::IOpType. Definition at line 67 of file constraint_stack_component.cpp. References _MemberName, _OpCodeType, _StackPos, _TypeStack, NLAISCRIPT::IConstraint::getConstraintTypeOf(), NLAIC::CIdentType::getFactory(), NLAIAGENT::IObjectIA::getStaticMemberIndex(), heapAffectation, NLAISCRIPT::CCompilateur::isValidateVarName(), NLAIC::IPointerGestion::release(), NLAISCRIPT::IOpType::run(), NLAISCRIPT::IConstraint::satisfied(), sint32, and x.
00068 { 00069 if(_Satisfied) return; 00070 _TypeStack->run(comp); 00071 if(_TypeStack->satisfied()) 00072 { 00073 if(_MemberName.size() == 1) 00074 { 00075 const NLAIAGENT::IObjectIA *c = (NLAIAGENT::IObjectIA *)((NLAIC::IClassFactory *)_TypeStack->getConstraintTypeOf()->getFactory())->getClass(); 00076 sint32 i = c->getStaticMemberIndex(NLAIAGENT::CStringVarName(_MemberName.front().data())); 00077 if(i >= 0) 00078 { 00079 /*if((const NLAIC::CTypeOfObject &)c->getType() & NLAIC::CTypeOfObject::tAgentInterpret) 00080 { 00081 i += comp.getCompementShift((IClassInterpret *)c); 00082 }*/ 00083 00084 std::list<sint32> b; 00085 b.push_back(i); 00086 IOpCode *x=0; 00087 switch(_OpCodeType) 00088 { 00089 case stackCall: 00090 x = new CLdbStackMemberiOpCode(b); 00091 break; 00092 case heapCall: 00093 x = new CLdbHeapMemberiOpCode(b,_StackPos); 00094 break; 00095 00096 case heapAffectation: 00097 x = new CAffHeapMemberiOpCode(b,_StackPos); 00098 break; 00099 00100 } 00101 00102 std::pair<sint32, CCodeBrancheRun *> &p = _Code.back(); 00103 IOpCode *op = (*p.second)[p.first];// 00104 op->release(); 00105 (*p.second)[p.first] = x; 00106 _Code.pop_back(); 00107 _Satisfied = true; 00108 } 00109 else 00110 { 00111 return; 00112 } 00113 } 00114 else 00115 { 00116 std::list<sint32> b; 00117 IOpType *c; 00118 NLAIAGENT::IObjectIA *cl = (NLAIAGENT::IObjectIA *)((NLAIC::IClassFactory *)_TypeStack->getConstraintTypeOf()->getFactory())->getClass(); 00119 if(!comp.isValidateVarName(cl,b,_MemberName,c) && c->getConstraintTypeOf() != NULL) 00120 { 00121 c->release(); 00122 return; 00123 } 00124 _Id = new NLAIC::CIdentType (*c->getConstraintTypeOf()); 00125 c->release(); 00126 IOpCode *x=0; 00127 00128 switch(_OpCodeType) 00129 { 00130 case stackCall: 00131 x = new CLdbStackMemberiOpCode(b); 00132 break; 00133 case heapCall: 00134 x = new CLdbHeapMemberiOpCode(b,_StackPos); 00135 break; 00136 00137 case heapAffectation: 00138 x = new CAffHeapMemberiOpCode(b,_StackPos); 00139 break; 00140 } 00141 00142 std::pair<sint32, CCodeBrancheRun *> &p = _Code.back(); 00143 IOpCode *op = (*p.second)[p.first];// 00144 op->release(); 00145 (*p.second)[p.first] = x; 00146 _Code.pop_back(); 00147 _Satisfied = true; 00148 00149 } 00150 } 00151 } |
|
When a constraint is resoved,we call all dependency.
Definition at line 214 of file constraint.h. References NLAISCRIPT::IConstraint::_ConstraintList, and NLAISCRIPT::IConstraint::run(). Referenced by NLAISCRIPT::CConstraintChkMethodeType::run(), NLAISCRIPT::CConstraintFindRun::setOpCode(), and NLAISCRIPT::CConstraintMethode::setOpCode().
00215 { 00216 while(_ConstraintList.size()) 00217 { 00218 IConstraint *a = _ConstraintList.back(); 00219 _ConstraintList.pop_back(); 00220 a->run(this); 00221 } 00222 } |
|
If the constraint is resolved.
Implements NLAISCRIPT::IConstraint. Definition at line 84 of file constraint_stack_component.h.
00085 { 00086 return _Satisfied; 00087 } |
|
Implements NLMISC::IStreamable. Reimplemented in NLAIC::CIdentType, NLAIC::IBasicInterface, NLAISCRIPT::COperandVoid, NLAISCRIPT::COperandAnyObject, NLAISCRIPT::COperandSimple, NLAISCRIPT::COperandSimpleListOr, NLAISCRIPT::COperandUnknown, NLAISCRIPT::COperationType, NLAISCRIPT::COperationTypeGD, and NLAISCRIPT::COperandListType. Definition at line 120 of file abstract_interface.h. Referenced by NLAISCRIPT::CFindRunMsg::save().
00121 { 00122 } |
|
Definition at line 64 of file constraint_stack_component.h. |
|
Definition at line 61 of file constraint_stack_component.h. |
|
The type of compoment when it resolve.
Definition at line 68 of file constraint_stack_component.h. |
|
Definition at line 60 of file constraint_stack_component.h. |
|
Set herarchy name (a hierarchy name is some thing like classBaseName.className.component).
Definition at line 56 of file constraint_stack_component.h. Referenced by CConstraintStackComp(), clone(), operator==(), and run(). |
|
Type of load.
Definition at line 70 of file constraint_stack_component.h. Referenced by CConstraintStackComp(), clone(), operator==(), and run(). |
|
Definition at line 62 of file constraint_stack_component.h. |
|
It used when the type is a heapCall and define the heap position.
Definition at line 72 of file constraint_stack_component.h. Referenced by CConstraintStackComp(), operator==(), and run(). |
|
Definition at line 63 of file constraint_stack_component.h. |
|
Set the type of component, it can be an unresolved constraint.
Definition at line 54 of file constraint_stack_component.h. Referenced by clone(), dependOn(), operator==(), run(), and ~CConstraintStackComp(). |