[Rcpp-devel] Rcpp modules: Derived class - exposing method from base class?

Dirk Eddelbuettel edd at debian.org
Tue Jun 14 19:36:20 CEST 2011


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
| Rcpp-devel at lists.r-forge.r-project.org
| 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


More information about the Rcpp-devel mailing list