Actually, having just the declaration like this compiled fine but and ended up in an unresolved symbol when loading the library. <br><br>class Bar : public Foo {<br>
...<br> void doSomething();<div class="im"><br>
void Action() {<br>
[some code here]<br>
}<br>};<br><br><br><br>I actually had to implement doSomething and explicitly call the Method of the Base class:<br><br>
class Bar : public Foo {<br>
...<br>
void doSomething() { Foo::doSomething() }
<div class="im"><br>
void Action() {<br>
[some code here]<br>
}<br>};<br>
</div><br><br>Since I do not know the internals of Rcpp modules: how hard would it be to include support for derived classes?<br><br></div>Best regards,<br><font color="#888888">Jonas</font><br><br><div class="gmail_quote">
On Tue, Jun 14, 2011 at 7:36 PM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org">edd@debian.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Hi Jonas,<br>
<div><div></div><div class="h5"><br>
On 14 June 2011 at 19:06, Jonas Rauch wrote:<br>
| I am trying to write an R interface to a library that uses derived classes in<br>
| the following manner:<br>
|<br>
| class Foo {<br>
| ...<br>
| virtual void Action() = 0;<br>
| void doSomething() {<br>
| Action();<br>
| [do complicated stuff]<br>
| }<br>
| ...<br>
| };<br>
|<br>
| class Bar : public Foo {<br>
| ...<br>
| void Action() {<br>
| [some code here]<br>
| }<br>
| };<br>
|<br>
| class Baz : public Foo {<br>
| ...<br>
| void Action() {<br>
| [some other code here]<br>
| }<br>
| };<br>
|<br>
| etc.<br>
|<br>
| Where the abstract class Foo defines an interface and at the same time provides<br>
| base functionality that can then be applied to different implementations of<br>
| "Action".<br>
|<br>
| Is it possible to expose Bar::doSomething() to R using Rcpp modules? I have<br>
| tried different things and did not get it to work.<br>
<br>
</div></div>Nice C++ design. And it should work, but I think your only choice really is<br>
list all exposed functions, ie your need an explicit mention of<br>
Bar::doSomething as well as Baz::doSomething. That way Rcpp Modules doesn't<br>
even know these are derived class. It just seens two identifiers to hook up<br>
against. As always, I may be missing parts of the picture in which case<br>
Romain may come forward and correct the record....<br>
<div class="im"><br>
|<br>
| I would appreciate any help.<br>
|<br>
| Best regards,<br>
| Jonas Rauch<br>
|<br>
</div>| ----------------------------------------------------------------------<br>
| _______________________________________________<br>
| Rcpp-devel mailing list<br>
| <a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>
| <a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
<font color="#888888"><br>
--<br>
Gauss once played himself in a zero-sum game and won $50.<br>
-- #11 at <a href="http://www.gaussfacts.com" target="_blank">http://www.gaussfacts.com</a><br>
</font></blockquote></div><br>