Hi Romain, glad to hear that! Although I solved my original problem with the workaround described, I would be happy to do some testing when you have a solution.
On Fri, Jul 8, 2011 at 2:00 PM, Romain Francois <[email protected]>wrote: > Le 07/07/11 15:18, Romain Francois a écrit : > > Le 15/06/11 14:57, Douglas Bates a écrit : >> >>> On Wed, Jun 15, 2011 at 6:38 AM, Jonas >>> Rauch<jonas.rauch@googlemail.**com <[email protected]>> wrote: >>> >>>> Hey again, >>>> >>>> just to clarify: The final solution was to implement all methods of the >>>> derived class that are to be exposed to R and to call the method of >>>> the base >>>> class explicitly: >>>> >>>> class Bar : public Foo { >>>> ... >>>> void doSomething() { Foo::doSomething() } >>>> }; >>>> >>> >>> Yes, we've been there before. According to Romain, it would be very >>> tricky to expose the method of the underlying class through the >>> derived class but it has been done in module bindings in Python, on >>> which Romain patterned some of the Rcpp modules code. >>> >> >> It is just that I need time to steal that from Boost.Python. >> >> This is one of the improvements I want to do in modules. >> > > This is now on a background thread in my head so that I can have > dreams/nightmares about it. I failed a few times yesterday evening and this > morning, but I can feel I'm getting closer to at least know how to do it. > > > On Wed, Jun 15, 2011 at 7:16 AM, Jonas > Rauch<jonas.rauch@googlemail.**com<[email protected]> >>>> > >>>> wrote: >>>> >>>>> >>>>> Actually, having just the declaration like this compiled fine but and >>>>> ended up in an unresolved symbol when loading the library. >>>>> >>>>> class Bar : public Foo { >>>>> ... >>>>> void doSomething(); >>>>> void Action() { >>>>> [some code here] >>>>> } >>>>> }; >>>>> >>>>> >>>>> >>>>> I actually had to implement doSomething and explicitly call the >>>>> Method of >>>>> the Base class: >>>>> >>>>> class Bar : public Foo { >>>>> ... >>>>> void doSomething() { Foo::doSomething() } >>>>> void Action() { >>>>> [some code here] >>>>> } >>>>> }; >>>>> >>>>> >>>>> Since I do not know the internals of Rcpp modules: how hard would it >>>>> be to >>>>> include support for derived classes? >>>>> >>>>> Best regards, >>>>> Jonas >>>>> >>>>> On Tue, Jun 14, 2011 at 7:36 PM, Dirk Eddelbuettel<[email protected]> >>>>> wrote: >>>>> >>>>>> >>>>>> Hi Jonas, >>>>>> >>>>>> On 14 June 2011 at 19:06, Jonas Rauch wrote: >>>>>> | I am trying to write an R interface to a library that uses derived >>>>>> classes in >>>>>> | the following manner: >>>>>> | >>>>>> | class Foo { >>>>>> | ... >>>>>> | virtual void Action() = 0; >>>>>> | void doSomething() { >>>>>> | Action(); >>>>>> | [do complicated stuff] >>>>>> | } >>>>>> | ... >>>>>> | }; >>>>>> | >>>>>> | class Bar : public Foo { >>>>>> | ... >>>>>> | void Action() { >>>>>> | [some code here] >>>>>> | } >>>>>> | }; >>>>>> | >>>>>> | class Baz : public Foo { >>>>>> | ... >>>>>> | void Action() { >>>>>> | [some other code here] >>>>>> | } >>>>>> | }; >>>>>> | >>>>>> | etc. >>>>>> | >>>>>> | Where the abstract class Foo defines an interface and at the same >>>>>> time >>>>>> provides >>>>>> | base functionality that can then be applied to different >>>>>> implementations of >>>>>> | "Action". >>>>>> | >>>>>> | Is it possible to expose Bar::doSomething() to R using Rcpp >>>>>> modules? I >>>>>> have >>>>>> | tried different things and did not get it to work. >>>>>> >>>>>> Nice C++ design. And it should work, but I think your only choice >>>>>> really >>>>>> is >>>>>> list all exposed functions, ie your need an explicit mention of >>>>>> Bar::doSomething as well as Baz::doSomething. That way Rcpp Modules >>>>>> doesn't >>>>>> even know these are derived class. It just seens two identifiers to >>>>>> hook >>>>>> up >>>>>> against. As always, I may be missing parts of the picture in which >>>>>> case >>>>>> Romain may come forward and correct the record.... >>>>>> >>>>>> | >>>>>> | I would appreciate any help. >>>>>> | >>>>>> | Best regards, >>>>>> | Jonas Rauch >>>>>> | >>>>>> | >>>>>> ------------------------------**------------------------------** >>>>>> ---------- >>>>>> | ______________________________**_________________ >>>>>> | Rcpp-devel mailing list >>>>>> | >>>>>> [email protected]**project.org<[email protected]> >>>>>> | >>>>>> https://lists.r-forge.r-**project.org/cgi-bin/mailman/** >>>>>> listinfo/rcpp-devel<https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel> >>>>>> >>>>>> >>>>>> -- >>>>>> Gauss once played himself in a zero-sum game and won $50. >>>>>> -- #11 at http://www.gaussfacts.com >>>>>> >>>>> >>>>> >>>> >>>> ______________________________**_________________ >>>> Rcpp-devel mailing list >>>> [email protected]**project.org<[email protected]> >>>> https://lists.r-forge.r-**project.org/cgi-bin/mailman/** >>>> listinfo/rcpp-devel<https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel> >>>> >>>> >>>> ______________________________**_________________ >>> Rcpp-devel mailing list >>> [email protected]**project.org<[email protected]> >>> https://lists.r-forge.r-**project.org/cgi-bin/mailman/** >>> listinfo/rcpp-devel<https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel> >>> >>> >> >> > > -- > Romain Francois > Professional R Enthusiast > +33(0) 6 28 91 30 30 > http://romainfrancois.blog.**free.fr <http://romainfrancois.blog.free.fr> > http://romain-francois.com > |- http://bit.ly/lJoWbH : Montpellier Comédie Club - Juin 2011 > |- http://bit.ly/kaSV6U : Stand up set at Up The Creek > `- http://bit.ly/hdKhCy : Rcpp article in JSS > > > ______________________________**_________________ > Rcpp-devel mailing list > [email protected]**project.org<[email protected]> > https://lists.r-forge.r-**project.org/cgi-bin/mailman/** > listinfo/rcpp-devel<https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel> >
_______________________________________________ Rcpp-devel mailing list [email protected] https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
