libalcommon  1.14.5
alcommon/alproxy.hxx
00001 
00007 #pragma once
00008 #ifndef _LIBALCOMMON_ALCOMMON_ALPROXY_HXX_
00009 #define _LIBALCOMMON_ALCOMMON_ALPROXY_HXX_
00010 
00011 #include <alcommon/detail/alpcall.h>
00012 
00013 namespace AL
00014 {
00015 
00016 #define CHECK_RESULT()                                                  \
00017   if (getParamStrType<R>() != lDesc->returnInfo.strType)                \
00018   {                                                                     \
00019     throw ALERROR("ALProxy", "call",                                    \
00020                   std::string("wrong return type for function '") +     \
00021                   pName + "'" +                                         \
00022                   " type is '" + getParamStrType<R>() + "'" +           \
00023                   " instead of '" + lDesc->returnInfo.strType);         \
00024   }
00025 
00026 #define CHECK_PARAM(x)                                                  \
00027   if (getParamStrType<P ## x>() != lDesc->parameters[x-1].strType)      \
00028   {                                                                     \
00029     throw ALERROR("ALProxy", "call/pCall",                              \
00030                   std::string("When trying to call module '") +         \
00031                   xGetModuleName() + "'"                                \
00032                   " function '" + pName + "' parameter #" +             \
00033                   (char) (x + '0') +                                    \
00034                   " is of type " + getParamStrType<P ## x>() +          \
00035                   " instead of type " +                                 \
00036                   lDesc->parameters[x-1].strType);                      \
00037   }
00038 
00039   template <typename R>
00040   R ALProxy::call(const std::string& pName)
00041   {
00042     if (isLocal())
00043     {
00044       if (isScript())
00045       {
00046         AL::ALValue param;
00047         AL::ALValue result;
00048         xExecute(pName, param, result);
00049         AL::detail::converter<R> conv;
00050         return conv.convertFromALValue(result);
00051       }
00052       ALMethodInfo *lDesc = xLookupMethod(pName);
00053       if (!lDesc)
00054       {
00055         std::vector<std::string> param;
00056         lDesc = xLookupMethod(pName, param, true);
00057       }
00058       CHECK_RESULT();
00059       return (*(detail::ALFunctor_0<ALModule, R> *)(lDesc->getFunction()))();
00060     }
00061     AL::ALValue p, r;
00062     CALL_METHODS(pName, p, r);
00063     if (!r.isValid())
00064       throw ALERROR("ALProxy", "call", "Waiting for the result of a void function");
00065     AL::detail::converter<R> conv;
00066     return conv.convertFromALValue(r);
00067   }
00068 
00069   template <typename R, typename P1>
00070   R ALProxy::call(const std::string& pName, const P1 &p1)
00071   {
00072     if (isLocal())
00073     {
00074       if (isScript())
00075       {
00076         AL::ALValue param;
00077         AL::ALValue result;
00078         param.arraySetSize(1);
00079         param[0] = p1;
00080         xExecute(pName, param, result);
00081         AL::detail::converter<R> conv;
00082         R resultConv = conv.convertFromALValue(result);
00083         return resultConv;
00084       }
00085       ALMethodInfo *lDesc = xLookupMethod(pName);
00086       if (!lDesc)
00087       {
00088         std::vector<std::string> param;
00089         param.push_back(getParamStrType<P1>());
00090         lDesc = xLookupMethod(pName, param,false);
00091       }
00092       CHECK_RESULT();
00093       CHECK_PARAM(1);
00094       return (*(detail::ALFunctor_1<ALModule, P1, R> *)(lDesc->getFunction()))(p1);
00095     }
00096     AL::ALValue p, r;
00097     p.arraySetSize(1);
00098     p[0] = p1;
00099     CALL_METHODS(pName, p, r);
00100     if ( !r.isValid() )
00101     {
00102       std::string error = std::string("Waiting for the result of a void function ") + pName + std::string(" ") + p.toString(VerbosityMini) + std::string("   ") + r.toString(VerbosityMini);
00103       throw ALERROR("ALProxy", "call", error);
00104     }
00105     AL::detail::converter<R> conv;
00106     R resultConv = conv.convertFromALValue(r);
00107     return resultConv;
00108   }
00109 
00110 
00111   template <typename R, typename P1, typename P2>
00112   R ALProxy::call(const std::string& pName, const P1 &p1, const P2 &p2)
00113   {
00114     if (isLocal())
00115     {
00116       if (isScript())
00117       {
00118         AL::ALValue param;
00119         AL::ALValue result;
00120         param.arraySetSize(2);
00121         param[0] = p1;
00122         param[1] = p2;
00123         xExecute(pName, param, result);
00124         return result;
00125       }
00126       ALMethodInfo *lDesc = xLookupMethod(pName);
00127       if (!lDesc)
00128       {
00129         std::vector<std::string> param;
00130         param.push_back(getParamStrType<P1>());
00131         param.push_back(getParamStrType<P2>());
00132         lDesc = xLookupMethod(pName, param,false);
00133       }
00134       CHECK_RESULT();
00135       CHECK_PARAM(1);
00136       CHECK_PARAM(2);
00137       return (*(detail::ALFunctor_2<ALModule, P1, P2, R> *)(lDesc->getFunction()))(p1, p2);
00138     }
00139     AL::ALValue p, r;
00140     p.arraySetSize(2);
00141     p[0] = p1;
00142     p[1] = p2;
00143     CALL_METHODS(pName, p, r);
00144     if ( !r.isValid() )
00145       throw ALERROR("ALProxy", "call", "Waiting for the result of a void function");
00146     AL::detail::converter<R> conv;
00147     R resultConv = conv.convertFromALValue(r);
00148     return resultConv;
00149   }
00150 
00151 
00152   template <typename R, typename P1, typename P2, typename P3>
00153   R ALProxy::call(const std::string& pName, const P1 &p1, const P2 &p2, const P3 &p3)
00154   {
00155     if (isLocal())
00156     {
00157       if (isScript())
00158       {
00159         AL::ALValue param;
00160         AL::ALValue result;
00161         param.arraySetSize(3);
00162         param[0] = p1;
00163         param[1] = p2;
00164         param[2] = p3;
00165         xExecute(pName, param, result);
00166         return result;
00167       }
00168       ALMethodInfo *lDesc = xLookupMethod(pName);
00169       if (!lDesc)
00170       {
00171         std::vector<std::string> param;
00172         param.push_back(getParamStrType<P1>());
00173         param.push_back(getParamStrType<P2>());
00174         param.push_back(getParamStrType<P3>());
00175         lDesc = xLookupMethod(pName, param, false);
00176       }
00177       CHECK_RESULT();
00178       CHECK_PARAM(1);
00179       CHECK_PARAM(2);
00180       CHECK_PARAM(3);
00181       return (*(detail::ALFunctor_3<ALModule, P1, P2, P3, R> *)(lDesc->getFunction()))(p1, p2, p3);
00182     }
00183     AL::ALValue p, r;
00184     p.arraySetSize(3);
00185     p[0] = p1;
00186     p[1] = p2;
00187     p[2] = p3;
00188 
00189     CALL_METHODS(pName, p, r);
00190     if ( !r.isValid() )
00191       throw ALERROR("ALProxy", "call", "Waiting for the result of a void function");
00192     AL::detail::converter<R> conv;
00193     R resultConv = conv.convertFromALValue(r);
00194     return resultConv;
00195   }
00196 
00197 
00198   template <typename R, typename P1, typename P2, typename P3, typename P4>
00199   R ALProxy::call(const std::string& pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4)
00200   {
00201     if (isLocal())
00202     {
00203       if (isScript())
00204       {
00205         AL::ALValue param;
00206         AL::ALValue result;
00207         param.arraySetSize(4);
00208         param[0] = p1;
00209         param[1] = p2;
00210         param[2] = p3;
00211         param[3] = p4;
00212         xExecute(pName, param, result);
00213         return result;
00214       }
00215       ALMethodInfo *lDesc = xLookupMethod(pName);
00216       if (!lDesc)
00217       {
00218         std::vector<std::string> param;
00219         param.push_back(getParamStrType<P1>());
00220         param.push_back(getParamStrType<P2>());
00221         param.push_back(getParamStrType<P3>());
00222         param.push_back(getParamStrType<P4>());
00223         lDesc = xLookupMethod(pName, param, false);
00224       }
00225       CHECK_RESULT();
00226       CHECK_PARAM(1);
00227       CHECK_PARAM(2);
00228       CHECK_PARAM(3);
00229       CHECK_PARAM(4);
00230       return (*(detail::ALFunctor_4<ALModule, P1, P2, P3, P4, R> *)(lDesc->getFunction()))(p1, p2, p3, p4);
00231     }
00232     AL::ALValue p, r;
00233     p.arraySetSize(4);
00234     p[0] = p1;
00235     p[1] = p2;
00236     p[2] = p3;
00237     p[3] = p4;
00238     CALL_METHODS(pName, p, r);
00239     if ( !r.isValid() )
00240       throw ALERROR("ALProxy", "call", "Waiting for the result of a void function");
00241     AL::detail::converter<R> conv;
00242     R resultConv = conv.convertFromALValue(r);
00243     return resultConv;
00244   }
00245 
00246 
00247   template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5>
00248   R ALProxy::call(const std::string& pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5)
00249   {
00250     if (isLocal())
00251     {
00252       if (isScript())
00253       {
00254         AL::ALValue param;
00255         AL::ALValue result;
00256         param.arraySetSize(5);
00257         param[0] = p1;
00258         param[1] = p2;
00259         param[2] = p3;
00260         param[3] = p4;
00261         param[4] = p5;
00262         xExecute(pName, param, result);
00263         return result;
00264       }
00265       ALMethodInfo *lDesc = xLookupMethod(pName);
00266       if (!lDesc)
00267       {
00268         std::vector<std::string> param;
00269         param.push_back(getParamStrType<P1>());
00270         param.push_back(getParamStrType<P2>());
00271         param.push_back(getParamStrType<P3>());
00272         param.push_back(getParamStrType<P4>());
00273         param.push_back(getParamStrType<P5>());
00274         lDesc = xLookupMethod(pName, param, false);
00275       }
00276       CHECK_RESULT();
00277       CHECK_PARAM(1);
00278       CHECK_PARAM(2);
00279       CHECK_PARAM(3);
00280       CHECK_PARAM(4);
00281       CHECK_PARAM(5);
00282       return (*(detail::ALFunctor_5<ALModule, P1, P2, P3, P4, P5, R> *)(lDesc->getFunction()))(p1, p2, p3, p4, p5);
00283     }
00284     AL::ALValue p, r;
00285     p.arraySetSize(5);
00286     p[0] = p1;
00287     p[1] = p2;
00288     p[2] = p3;
00289     p[3] = p4;
00290     p[4] = p5;
00291     CALL_METHODS(pName, p, r);
00292     if ( !r.isValid() )
00293       throw ALERROR("ALProxy", "call", "Waiting for the result of a void function");
00294     AL::detail::converter<R> conv;
00295     R resultConv = conv.convertFromALValue(r);
00296     return resultConv;
00297   }
00298 
00299 
00300   template <typename R, typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
00301   R ALProxy::call(const std::string& pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6)
00302   {
00303     if (isLocal())
00304     {
00305       if (isScript())
00306       {
00307         AL::ALValue param;
00308         AL::ALValue result;
00309         param.arraySetSize(6);
00310         param[0] = p1;
00311         param[1] = p2;
00312         param[2] = p3;
00313         param[3] = p4;
00314         param[4] = p5;
00315         param[5] = p6;
00316         xExecute(pName, param, result);
00317         return result;
00318       }
00319 
00320       ALMethodInfo *lDesc = xLookupMethod(pName);
00321       if (!lDesc)
00322         throw ALERROR("ALProxy", "call", "Function does not exist");
00323       CHECK_RESULT();
00324       CHECK_PARAM(1);
00325       CHECK_PARAM(2);
00326       CHECK_PARAM(3);
00327       CHECK_PARAM(4);
00328       CHECK_PARAM(5);
00329       CHECK_PARAM(6);
00330       return (*(detail::ALFunctor_6<ALModule, P1, P2, P3, P4, P5, P6, R> *)(lDesc->getFunction()))(p1, p2, p3, p4, p5, p6);
00331     }
00332     AL::ALValue p, r;
00333     p.arraySetSize(6);
00334     p[0] = p1;
00335     p[1] = p2;
00336     p[2] = p3;
00337     p[3] = p4;
00338     p[4] = p5;
00339     p[5] = p6;
00340     CALL_METHODS(pName, p, r);
00341     if ( !r.isValid() )
00342       throw ALERROR("ALProxy", "call", "Waiting for the result of a void function");
00343     AL::detail::converter<R> conv;
00344     R resultConv = conv.convertFromALValue(r);
00345     return resultConv;
00346   }
00347 
00348   inline
00349   void ALProxy::callVoid(const std::string& pName)
00350   {
00351     if (isLocal())
00352     {
00353       if (isScript())
00354       {
00355         AL::ALValue param;
00356         AL::ALValue result;
00357         xExecute(pName, param, result);
00358         return;
00359       }
00360       ALMethodInfo *lDesc = xLookupMethod(pName);
00361       if (!lDesc)
00362         throw ALERROR("ALProxy", "getMethodInfo", std::string("Function ") + pName + " does not exist in module " + xGetModuleName() );
00363       (*(detail::ALFunctor_0<ALModule, ALVoid> *)(xLookupMethod(pName)->ptrOnMethod.get()))();
00364       return;
00365     }
00366     AL::ALValue p, r;
00367     CALL_METHODS(pName, p, r);
00368     return;
00369   }
00370 
00371   template <typename P1>
00372   void ALProxy::callVoid(const std::string& pName, const P1 &p1)
00373   {
00374     if (isLocal())
00375     {
00376       if (isScript())
00377       {
00378         AL::ALValue param;
00379         AL::ALValue result;
00380         param.arraySetSize(1);
00381         AL::detail::converter<P1> conv;
00382         param[0] = conv.convertToALValue(p1);
00383         xExecute(pName, param, result);
00384         return;
00385       }
00386       ALMethodInfo *lDesc = xLookupMethod(pName);
00387       if (!lDesc)
00388       {
00389         std::vector<std::string> param;
00390         param.push_back(getParamStrType<P1>());
00391         lDesc = xLookupMethod(pName, param, false);
00392       }
00393       CHECK_PARAM(1);
00394       (*(detail::ALFunctor_1<ALModule, P1, void> *)(lDesc->getFunction()))(p1);
00395       return;
00396     }
00397     AL::ALValue p, r;
00398     p.arraySetSize(1);
00399     AL::detail::converter<P1> conv;
00400     p[0] = conv.convertToALValue(p1);
00401     CALL_METHODS(pName, p, r);
00402     return;
00403   }
00404 
00405   template <typename P1, typename P2>
00406   void ALProxy::callVoid(const std::string& pName, const P1 &p1, const P2 &p2)
00407   {
00408     if (isLocal())
00409     {
00410       if (isScript())
00411       {
00412         AL::ALValue param;
00413         AL::ALValue result;
00414         param.arraySetSize(2);
00415         param[0] = p1;
00416         param[1] = p2;
00417         xExecute(pName, param, result);
00418         return;
00419       }
00420       ALMethodInfo *lDesc = xLookupMethod(pName);
00421       if (!lDesc)
00422       {
00423         std::vector<std::string> param;
00424         param.push_back(getParamStrType<P1>());
00425         param.push_back(getParamStrType<P2>());
00426         lDesc = xLookupMethod(pName, param, false);
00427       }
00428       CHECK_PARAM(1);
00429       CHECK_PARAM(2);
00430       (*(detail::ALFunctor_2<ALModule, P1, P2, void> *)(lDesc->getFunction()))(p1, p2);
00431       return;
00432     }
00433     AL::ALValue p, r;
00434     p.arraySetSize(2);
00435     p[0] = p1;
00436     p[1] = p2;
00437     CALL_METHODS(pName, p, r);
00438   }
00439 
00440   template <typename P1, typename P2, typename P3>
00441   void ALProxy::callVoid(const std::string& pName, const P1 &p1, const P2 &p2, const P3 &p3)
00442   {
00443     if (isLocal())
00444     {
00445       if (isScript())
00446       {
00447         AL::ALValue param;
00448         AL::ALValue result;
00449         param.arraySetSize(3);
00450         param[0] = p1;
00451         param[1] = p2;
00452         param[2] = p3;
00453         xExecute(pName, param, result);
00454         return;
00455       }
00456       ALMethodInfo *lDesc = xLookupMethod(pName);
00457       if (!lDesc)
00458       {
00459         std::vector<std::string> param;
00460         param.push_back(getParamStrType<P1>());
00461         param.push_back(getParamStrType<P2>());
00462         param.push_back(getParamStrType<P3>());
00463         lDesc = xLookupMethod(pName, param, false);
00464       }
00465       CHECK_PARAM(1);
00466       CHECK_PARAM(2);
00467       CHECK_PARAM(3);
00468       (*(detail::ALFunctor_3<ALModule, P1, P2, P3, void> *)(lDesc->getFunction()))(p1, p2, p3);
00469       return;
00470     }
00471     AL::ALValue p, r;
00472     p.arraySetSize(3);
00473     p[0] = p1;
00474     p[1] = p2;
00475     p[2] = p3;
00476     CALL_METHODS(pName, p, r);
00477   }
00478 
00479   template <typename P1, typename P2, typename P3, typename P4>
00480   void ALProxy::callVoid(const std::string& pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4)
00481   {
00482     if (isLocal())
00483     {
00484       if (isScript())
00485       {
00486         AL::ALValue param;
00487         AL::ALValue result;
00488         param.arraySetSize(4);
00489         param[0] = p1;
00490         param[1] = p2;
00491         param[2] = p3;
00492         param[3] = p4;
00493         xExecute(pName, param, result);
00494         return;
00495       }
00496       ALMethodInfo *lDesc = xLookupMethod(pName);
00497       if (!lDesc)
00498       {
00499         std::vector<std::string> param;
00500         param.push_back(getParamStrType<P1>());
00501         param.push_back(getParamStrType<P2>());
00502         param.push_back(getParamStrType<P3>());
00503         param.push_back(getParamStrType<P4>());
00504         lDesc = xLookupMethod(pName, param, false);
00505       }
00506       CHECK_PARAM(1);
00507       CHECK_PARAM(2);
00508       CHECK_PARAM(3);
00509       CHECK_PARAM(4);
00510       (*(detail::ALFunctor_4<ALModule, P1, P2, P3, P4, ALVoid> *)(lDesc->getFunction()))(p1, p2, p3, p4);
00511       return;
00512     }
00513     AL::ALValue p, r;
00514     p.arraySetSize(4);
00515     p[0] = p1;
00516     p[1] = p2;
00517     p[2] = p3;
00518     p[3] = p4;
00519     CALL_METHODS(pName, p, r);
00520   }
00521 
00522   template <typename P1, typename P2, typename P3, typename P4, typename P5>
00523   void ALProxy::callVoid(const std::string& pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5)
00524   {
00525     if (isLocal())
00526     {
00527       if (isScript())
00528       {
00529         AL::ALValue param;
00530         AL::ALValue result;
00531         param.arraySetSize(5);
00532         param[0] = p1;
00533         param[1] = p2;
00534         param[2] = p3;
00535         param[3] = p4;
00536         param[4] = p5;
00537         xExecute(pName, param, result);
00538         return;
00539       }
00540       ALMethodInfo *lDesc = xLookupMethod(pName);
00541       if (!lDesc)
00542       {
00543         std::vector<std::string> param;
00544         param.push_back(getParamStrType<P1>());
00545         param.push_back(getParamStrType<P2>());
00546         param.push_back(getParamStrType<P3>());
00547         param.push_back(getParamStrType<P4>());
00548         param.push_back(getParamStrType<P5>());
00549         lDesc = xLookupMethod(pName, param, false);
00550       }
00551       CHECK_PARAM(1);
00552       CHECK_PARAM(2);
00553       CHECK_PARAM(3);
00554       CHECK_PARAM(4);
00555       CHECK_PARAM(5);
00556       (*(detail::ALFunctor_5<ALModule, P1, P2, P3, P4, P5, ALVoid> *)(lDesc->getFunction()))(p1, p2, p3, p4, p5);
00557       return;
00558     }
00559     AL::ALValue p, r;
00560     p.arraySetSize(5);
00561     p[0] = p1;
00562     p[1] = p2;
00563     p[2] = p3;
00564     p[3] = p4;
00565     p[4] = p5;
00566     CALL_METHODS(pName, p, r);
00567   }
00568 
00569 
00570   template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
00571   void ALProxy::callVoid(const std::string& pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6)
00572   {
00573     if (isLocal())
00574     {
00575       if (isScript())
00576       {
00577         AL::ALValue param;
00578         AL::ALValue result;
00579         param.arraySetSize(6);
00580         param[0] = p1;
00581         param[1] = p2;
00582         param[2] = p3;
00583         param[3] = p4;
00584         param[4] = p5;
00585         param[5] = p6;
00586 
00587         xExecute(pName, param, result);
00588         return;
00589       }
00590       ALMethodInfo *lDesc = xLookupMethod(pName);
00591       if (!lDesc)
00592         throw ALERROR("ALProxy", "call", "Function does not exist");
00593       CHECK_PARAM(1);
00594       CHECK_PARAM(2);
00595       CHECK_PARAM(3);
00596       CHECK_PARAM(4);
00597       CHECK_PARAM(5);
00598       CHECK_PARAM(6);
00599       (*(detail::ALFunctor_6<ALModule, P1, P2, P3, P4, P5, P6, ALVoid> *)(lDesc->getFunction()))(p1, p2, p3, p4, p5, p6);
00600       return;
00601     }
00602     AL::ALValue p, r;
00603     p.arraySetSize(6);
00604     p[0] = p1;
00605     p[1] = p2;
00606     p[2] = p3;
00607     p[3] = p4;
00608     p[4] = p5;
00609     p[5] = p6;
00610     CALL_METHODS(pName, p, r);
00611   }
00612 
00613   inline
00614   int ALProxy::pCall(const std::string& pName)
00615   {
00616     if (isLocal())
00617     {
00618       if (isScript())
00619       {
00620         AL::ALValue param;
00621         return xPCallScript(pName, param);
00622       }
00623       ALMethodInfo *lDesc = xLookupMethod(pName);
00624       if (!lDesc)
00625         throw ALERROR("ALProxy", "getMethodInfo", std::string("Function ") + pName + " does not exist in module " + xGetModuleName() );
00626       boost::shared_ptr<detail::ALTaskInfo> r = xCreateTaskInfo(pName);
00627       detail::PCallBase *pcall(new detail::_pcall0((detail::ALFunctor_0<ALModule, ALVoid> *)(lDesc->getFunction()),r,getModuleCore()));
00628       xAddTask(r->toString(), pcall);
00629       return r->getID();
00630     }
00631     AL::ALValue p,r;
00632     PCALL_METHODS(pName, p, r);
00633     return r;
00634   }
00635 
00636 
00637   template <typename P1>
00638   int ALProxy::pCall(const std::string& pName, const P1 &p1)
00639   {
00640     if (isLocal())
00641     {
00642       if (isScript())
00643       {
00644         AL::ALValue param;
00645         param.arraySetSize(1);
00646         AL::detail::converter<P1> conv;
00647         param[0] = conv.convertToALValue(p1);
00648         return xPCallScript(pName, param);
00649       }
00650       ALMethodInfo *lDesc = xLookupMethod(pName);
00651       if (!lDesc)
00652       {
00653         std::vector<std::string> param;
00654         param.push_back(getParamStrType<P1>());
00655         lDesc = xLookupMethod(pName, param, true);
00656       }
00657       CHECK_PARAM(1);
00658       boost::shared_ptr<detail::ALTaskInfo> r = xCreateTaskInfo(pName);
00659       detail::PCallBase *task(new detail::_pcall1<P1>((detail::ALFunctor_1<ALModule, P1, ALVoid> *)(lDesc->getFunction()), p1,getModuleCore(),r ));
00660       xAddTask(r->toString(), task);
00661       return r->getID();
00662     }
00663     AL::ALValue p, r;
00664     p.arraySetSize(1);
00665     AL::detail::converter<P1> conv;
00666     p[0] = conv.convertToALValue(p1);
00667     PCALL_METHODS(pName, p, r);
00668     return r;
00669   }
00670 
00671 
00672   template <typename P1, typename P2>
00673   int ALProxy::pCall(const std::string& pName, const P1 &p1, const P2 &p2)
00674   {
00675     if (isLocal())
00676     {
00677       if (isScript())
00678       {
00679         AL::ALValue param;
00680         param.arraySetSize(2);
00681         param[0] = p1;
00682         param[1] = p2;
00683         return xPCallScript(pName, param);
00684       }
00685       ALMethodInfo *lDesc = xLookupMethod(pName);
00686       if (!lDesc)
00687       {
00688         std::vector<std::string> param;
00689         param.push_back(getParamStrType<P1>());
00690         param.push_back(getParamStrType<P2>());
00691         lDesc = xLookupMethod(pName, param, true);
00692       }
00693       CHECK_PARAM(1);
00694       CHECK_PARAM(2);
00695       boost::shared_ptr<detail::ALTaskInfo> r = xCreateTaskInfo(pName);
00696       detail::PCallBase *task(new detail::_pcall2<P1, P2>((detail::ALFunctor_2<ALModule, P1, P2, ALVoid> *)(lDesc->getFunction()), p1, p2, getModuleCore(), r));
00697       xAddTask(r->toString(), task);
00698       return r->getID();
00699     }
00700     AL::ALValue p, r;
00701     p.arraySetSize(2);
00702     p[0] = p1;
00703     p[1] = p2;
00704     PCALL_METHODS(pName, p, r);
00705     return r;
00706   }
00707 
00708   template <typename P1, typename P2, typename P3>
00709   int ALProxy::pCall(const std::string& pName, const P1 &p1, const P2 &p2, const P3 &p3)
00710   {
00711     if (isLocal())
00712     {
00713       if (isScript())
00714       {
00715         AL::ALValue param;
00716         param.arraySetSize(3);
00717         param[0] = p1;
00718         param[1] = p2;
00719         param[2] = p3;
00720         return xPCallScript(pName, param);
00721       }
00722       ALMethodInfo *lDesc = xLookupMethod(pName);
00723       if (!lDesc)
00724       {
00725         std::vector<std::string> param;
00726         param.push_back(getParamStrType<P1>());
00727         param.push_back(getParamStrType<P2>());
00728         param.push_back(getParamStrType<P3>());
00729         lDesc = xLookupMethod(pName, param, true);
00730       }
00731       CHECK_PARAM(1);
00732       CHECK_PARAM(2);
00733       CHECK_PARAM(3);
00734       boost::shared_ptr<detail::ALTaskInfo> r  = xCreateTaskInfo(pName);
00735       detail::PCallBase *task(new detail::_pcall3<P1, P2, P3>((detail::ALFunctor_3<ALModule, P1, P2, P3, ALVoid> *)(lDesc->getFunction()), p1, p2, p3,getModuleCore(),r));
00736       xAddTask(r->toString(), task);
00737       return r->getID();
00738     }
00739     AL::ALValue p, r;
00740     p.arraySetSize(3);
00741     p[0] = p1;
00742     p[1] = p2;
00743     p[2] = p3;
00744     PCALL_METHODS(pName, p, r);
00745     return r;
00746   }
00747 
00748   template <typename P1, typename P2, typename P3, typename P4>
00749   int ALProxy::pCall(const std::string& pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4)
00750   {
00751     if (isLocal())
00752     {
00753       if (isScript())
00754       {
00755         AL::ALValue param;
00756         param.arraySetSize(4);
00757         param[0] = p1;
00758         param[1] = p2;
00759         param[2] = p3;
00760         param[3] = p4;
00761         return xPCallScript(pName, param);
00762       }
00763       ALMethodInfo *lDesc = xLookupMethod(pName);
00764       if (!lDesc)
00765       {
00766         std::vector<std::string> param;
00767         param.push_back(getParamStrType<P1>());
00768         param.push_back(getParamStrType<P2>());
00769         param.push_back(getParamStrType<P3>());
00770         param.push_back(getParamStrType<P4>());
00771         lDesc = xLookupMethod(pName, param, true);
00772       }
00773       CHECK_PARAM(1);
00774       CHECK_PARAM(2);
00775       CHECK_PARAM(3);
00776       CHECK_PARAM(4);
00777       boost::shared_ptr<detail::ALTaskInfo> r  = xCreateTaskInfo(pName);
00778       detail::PCallBase *task(new detail::_pcall4<P1, P2, P3, P4>((detail::ALFunctor_4<ALModule, P1, P2, P3, P4, ALVoid> *)(lDesc->getFunction()), p1, p2, p3, p4,getModuleCore(), r ));
00779       xAddTask(r->toString(), task);
00780       return r->getID();
00781     }
00782     AL::ALValue p, r;
00783     p.arraySetSize(4);
00784     p[0] = p1;
00785     p[1] = p2;
00786     p[2] = p3;
00787     p[3] = p4;
00788     PCALL_METHODS(pName, p, r);
00789     return r;
00790   }
00791 
00792   template <typename P1, typename P2, typename P3, typename P4, typename P5>
00793   int ALProxy::pCall(const std::string& pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5)
00794   {
00795     if (isLocal())
00796     {
00797       if (isScript())
00798       {
00799         AL::ALValue param;
00800         param.arraySetSize(5);
00801         param[0] = p1;
00802         param[1] = p2;
00803         param[2] = p3;
00804         param[3] = p4;
00805         param[4] = p5;
00806         return xPCallScript(pName, param);
00807       }
00808       ALMethodInfo *lDesc = xLookupMethod(pName);
00809       if (!lDesc)
00810       {
00811         std::vector<std::string> param;
00812         param.push_back(getParamStrType<P1>());
00813         param.push_back(getParamStrType<P2>());
00814         param.push_back(getParamStrType<P3>());
00815         param.push_back(getParamStrType<P4>());
00816         param.push_back(getParamStrType<P5>());
00817         lDesc = xLookupMethod(pName, param, false);
00818       }
00819       CHECK_PARAM(1);
00820       CHECK_PARAM(2);
00821       CHECK_PARAM(3);
00822       CHECK_PARAM(4);
00823       CHECK_PARAM(5);
00824       boost::shared_ptr<detail::ALTaskInfo> r = xCreateTaskInfo(pName);
00825       detail::PCallBase *task(new detail::_pcall5<P1, P2, P3, P4, P5>((detail::ALFunctor_5<ALModule, P1, P2, P3, P4, P5, ALVoid> *)(lDesc->getFunction()), p1, p2, p3, p4, p5, getModuleCore(), r));
00826       xAddTask(r->toString(), task);
00827       return r->getID();
00828     }
00829     AL::ALValue p, r;
00830     p.arraySetSize(5);
00831     p[0] = p1;
00832     p[1] = p2;
00833     p[2] = p3;
00834     p[3] = p4;
00835     p[4] = p5;
00836     PCALL_METHODS(pName, p, r);
00837     return r;
00838   }
00839 
00840 
00841   template <typename P1, typename P2, typename P3, typename P4, typename P5, typename P6>
00842   int ALProxy::pCall(const std::string& pName, const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4, const P5 &p5, const P6 &p6)
00843   {
00844     if (isLocal())
00845     {
00846       if (isScript())
00847       {
00848         AL::ALValue param;
00849         param.arraySetSize(6);
00850         param[0] = p1;
00851         param[1] = p2;
00852         param[2] = p3;
00853         param[3] = p4;
00854         param[4] = p5;
00855         param[5] = p6;
00856         return xPCallScript(pName, param);
00857       }
00858       ALMethodInfo *lDesc = xLookupMethod(pName);
00859       if (!lDesc)
00860         throw ALERROR("ALProxy", "call", "Function does not exist");
00861       CHECK_PARAM(1);
00862       CHECK_PARAM(2);
00863       CHECK_PARAM(3);
00864       CHECK_PARAM(4);
00865       CHECK_PARAM(5);
00866       CHECK_PARAM(6);
00867       boost::shared_ptr<detail::ALTaskInfo> r = xCreateTaskInfo(pName);
00868       detail::PCallBase *task(new detail::_pcall6<P1, P2, P3, P4, P5, P6>((detail::ALFunctor_6<ALModule, P1, P2, P3, P4, P5, P6, ALVoid> *)(lDesc->getFunction()), p1, p2, p3, p4, p5, p6, getModuleCore(), r));
00869       xAddTask(r->toString(), task);
00870       return r->getID();
00871     }
00872     AL::ALValue p, r;
00873     p.arraySetSize(6);
00874     p[0] = p1;
00875     p[1] = p2;
00876     p[2] = p3;
00877     p[3] = p4;
00878     p[4] = p5;
00879     p[5] = p6;
00880     PCALL_METHODS(pName, p, r);
00881     return r;
00882   }
00883 }
00884 
00885 #endif  // _LIBALCOMMON_ALCOMMON_ALPROXY_HXX_
00886 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines