00001
00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023
00024
00025 #include "nel/ai/agent/agentexport.h"
00026 #include "nel/ai/agent/agent_operator.h"
00027 #include "nel/ai/agent/agent_method_def.h"
00028
00029 namespace NLAIAGENT
00030 {
00031
00032 tQueue IObjetOp::isMember(const IVarName *className, const IVarName *name, const IObjectIA ¶ms) const
00033 {
00034 tQueue result;
00035
00036 result = IObjectIA::isMember( className, name, params );
00037
00038 if ( result.size() )
00039 return result;
00040
00041 if(className != NULL)
00042 {
00043 if ( *name == CStringVarName(_OPPLUS_) )
00044 {
00045 result.push( NLAIAGENT::CIdMethod(op_add,0.0,NULL,NULL) );
00046 }
00047 if ( *name == CStringVarName(_OPMOINS_) )
00048 {
00049 result.push( NLAIAGENT::CIdMethod(op_sub,0.0,NULL,NULL) );
00050 }
00051 if ( *name == CStringVarName(_OPMUL_) )
00052 {
00053 result.push( NLAIAGENT::CIdMethod(op_mul,0.0,NULL,NULL) );
00054 }
00055 if ( *name == CStringVarName(_OPEQ_) )
00056 {
00057 result.push( CIdMethod(NLAIC::CTypeOfOperator::opEq,0.0,NULL,NULL) );
00058 }
00059 if ( *name == CStringVarName(_OPDIV_) )
00060 {
00061 result.push( NLAIAGENT::CIdMethod(op_div,0.0,NULL,NULL) );
00062 }
00063
00064 if ( *name == CStringVarName(_OPLESS_) )
00065 {
00066 result.push( NLAIAGENT::CIdMethod(op_neg,0.0,NULL,NULL) );
00067 }
00068
00069 if ( *name == CStringVarName(_OPEQ_) )
00070 {
00071 result.push( NLAIAGENT::CIdMethod(op_eq,0.0,NULL,NULL) );
00072 }
00073
00074 if ( *name == CStringVarName(_OPINFEQ_) )
00075 {
00076 result.push( NLAIAGENT::CIdMethod(op_inf_eq,0.0,NULL,NULL) );
00077 }
00078
00079 if ( *name == CStringVarName(_OPSUPEQ_) )
00080 {
00081 result.push( NLAIAGENT::CIdMethod(op_sup_eq,0.0,NULL,NULL) );
00082 }
00083
00084 if ( *name == CStringVarName(_OPDIFF_) )
00085 {
00086 result.push( NLAIAGENT::CIdMethod(op_diff,0.0,NULL,NULL) );
00087 }
00088 }
00089
00090 return result;
00091 }
00092
00093 sint32 IObjetOp::getMethodIndexSize() const
00094 {
00095 return IObjectIA::getMethodIndexSize() + op_last;
00096 }
00097
00098
00099 IObjectIA::CProcessResult IObjetOp::runMethodeMember(sint32 index, IObjectIA *param)
00100 {
00101
00102 if ( index <= IObjectIA::getMethodIndexSize() )
00103 return IObjectIA::runMethodeMember(index, param);
00104
00105 IObjetOp *x = (IObjetOp *)( (IBaseGroupType *) param)->getFront();
00106 ( (IBaseGroupType *) param)->popFront();
00107
00108 IObjectIA::CProcessResult r;
00109 r.ResultState = processIdle;
00110
00111 switch ( index )
00112 {
00113 case op_add:
00114 r.Result = (IObjectIA *) &( (*this) += ( * (IObjetOp *) x) );
00115 break;
00116
00117 case op_sub:
00118 r.Result = (IObjectIA *) &( (*this) -= ( * (IObjetOp *) x) );
00119 break;
00120
00121 case op_mul:
00122 r.Result = (IObjectIA *) &( (*this) *= ( * (IObjetOp *) x) );
00123 break;
00124
00125 case op_div:
00126 r.Result = (IObjectIA *) &( (*this) /= ( * (IObjetOp *) x) );
00127 break;
00128
00129 case op_not:
00130 r.Result = (IObjectIA *) ( !(*this) );
00131 break;
00132
00133 case op_eq:
00134 r.Result = (IObjectIA *) ( (*this) == ( * (IObjetOp *) x ) );
00135 break;
00136
00137 case NLAIC::CTypeOfOperator::opInfEq :
00138 r.Result = (IObjectIA *) ( (*this) <= ( * (IObjetOp *) x ) );
00139 break;
00140
00141 case NLAIC::CTypeOfOperator::opSupEq :
00142 r.Result = (IObjectIA *) ( (*this) >= ( * (IObjetOp *) x ) );
00143 break;
00144
00145 case NLAIC::CTypeOfOperator::opDiff :
00146 r.Result = (IObjectIA *) ( (*this) != ( * (IObjetOp *) x ) );
00147 break;
00148 }
00149 return r;
00150 }
00151 }