[Rcpp-devel] Rcpp modules: Classes as arguments
Jonas Rauch
jonas.rauch at googlemail.com
Wed Jun 15 08:04:18 CEST 2011
On a related note to the question on derived classes I sent yesterday, here
is another interesting idea. Assume I have classes
class Foo {
...
};
class Bar {
...
//pass Foo pointer as parameter
void myMethod(Foo* X) {
...
}
//or Foo reference
void myMethod2(Foo& X) {
...
}
//or return Foo pointer
Foo* getFoo() {
...
}
};
Now, when exposing both classes to R using modules, it would be great to be
able to do something like
FooVar <- new( Mod$Foo )
BarVar <- new( Mod$Bar )
//pass Bar as parameter
BarVar$myMethod(FooVar)
//get Bar back
FooVar2 = BarVar$getFoo()
Since the C++ part of Rcpp Modules has to have a pointer to the underlying
object (i.e. of type Foo*) somewhere anyway, this seems possible. But since
I am no expert in C++ meta programming, I don't know if e.g. Bar needs to
know at compile time that Foo is exposed as well or what it looks like or if
this can be handled dynamically at runtime.
Best regards,
Jonas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20110615/30e534bf/attachment.htm>
More information about the Rcpp-devel
mailing list