<div class="gmail_quote">On Thu, May 17, 2012 at 6:02 PM, Liam <span dir="ltr">&lt;<a href="mailto:xapian@networkimprov.net" target="_blank">xapian@networkimprov.net</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br><br><div class="gmail_quote"><div class="im">On Thu, May 17, 2012 at 2:38 AM, Marius Tibeica <span dir="ltr">&lt;<a href="mailto:mtibeica@gmail.com" target="_blank">mtibeica@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

I have tried multiple approaches. <div>The difficulty comes from the fact that each class can have multiple sync/async functions. For example, Enquire has atleast get_mset, get_matching_terms and get_eset.<div>Another problem is that from the pool methods (which should be templatized) I have to call methods from the class (GetMset_process, GetMset_convert, GetMatchingTerm_process, ...). This means that I also probably have to pass a function as a template parameter.</div>


<div>The thirt problem is that func##_pool and func##_done need to be (int (eio_req *req)), so I can not pass a function pointer.</div><div><br></div><div>At the moment I am trying a hybrid approach (bot templates and macroes).  <br>

</div></div></blockquote></div><div><br>OK, no need to bend over backwards. Simplicity is preferable after all. <br></div></div></blockquote><div><br></div><div>I tend to agree. The hybrid approach is even more complicated.</div>
<div><br></div><div><div>template &lt;class dataType, class className&gt;</div><div>class PoolHelper</div><div>{</div><div>public:</div><div>  ...</div><div>  template &lt;Handle&lt;Value&gt; (*convertFunction)(className *data)&gt;;</div>
<div>  static void execute_done(eio_req *data)</div><div>  {</div><div>    HandleScope scope;</div><div>    OpInfo* aInfo = (OpInfo*) req-&gt;data;</div><div>    dataType *aData = (dataType*)aInfo-&gt;data;</div><div>    AsyncOp&lt;className&gt; *aAsOp = (AsyncOp&lt;className&gt;*)aInfo-&gt;op;</div>
<div>    Handle&lt;Value&gt; argv[2];</div><div>    if (aAsOp-&gt;error) {</div><div>      argv[0] = Exception::Error(String::New(aAsOp-&gt;error-&gt;get_msg().c_str()));</div><div>    } else {</div><div>      argv[0] = Null();</div>
<div>      argv[1] = convertFunction(aData);</div><div>    }</div><div>    tryCallCatch(aAsOp-&gt;callback, aAsOp-&gt;object-&gt;handle_, aAsOp-&gt;error ? 1 : 2, argv);</div><div>    delete aData;</div><div>    delete aAsOp;</div>
<div>    delete aInfo;</div><div>  }</div><div>};</div><div><br></div><div><br></div><div>#define DECLARE_POOLS(func,classn) \</div><div>...</div><div>static int func##_done(eio_req *req) {\</div><div>  HandleScope scope;\</div>
<div>  PoolHelper&lt;func##_data,classn&gt;::execute_pool&lt;func##_convert&gt;(req);\</div><div>  return 0;\</div><div>}\</div></div><div><br></div><div><br></div><div>I will leave the macro as it is.</div><div><br></div>
<div><br></div><div>The question now is, what&#39;s next?</div><div>Should I start implementing other methods?</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="gmail_quote"><div></div></div><br>
<br>_______________________________________________<br>
Xapian-devel mailing list<br>
<a href="mailto:Xapian-devel@lists.xapian.org">Xapian-devel@lists.xapian.org</a><br>
<a href="http://lists.xapian.org/mailman/listinfo/xapian-devel" target="_blank">http://lists.xapian.org/mailman/listinfo/xapian-devel</a><br>
<br></blockquote></div><br>