This is once again something with which the RCPP_EXPOSED_CLASS macro can help 
with. Try adding 

RCPP_EXPOSED_CLASS(A)

before you declare class A and simply use this signature for the method. 

void DoSomethingWithInstanceOfA(const A& ) 

Also, you can have both of these classes in the same module you know; 

RCPP_MODULE(LemonCurry)
{
        using namespace Rcpp;

        class_<A>( "A" )
            .constructor();

        class_<B>( "B" )
            .constructor()
            .method("DoSomethingWithInstanceOfA", 
&B::DoSomethingWithInstanceOfA);
}

Romain. 

PS: Having to resort to that sort of macros is one of the reason that made me 
remove modules from Rcpp11, which will be replaced by something that will be 
nicer to use later. 

Le 10 sept. 2014 à 02:56, Grant Brown <grant.brow...@gmail.com> a écrit :

> Hi folks, 
> 
> I'm building several Rcpp modules which specify parts of a complicated 
> statistical model, and want to pass them to a main module for use. Is there 
> an easy way to do this? 
> 
> Below is a simplified example, with question marks where I'm not sure what to 
> do. I've tried accepting a pointer to A, playing with using XPtrs, and a 
> bunch of things which made far less sense, but so far no luck. 
> 
> Any suggestions or links to sections of the docs I should revisit would be 
> appreciated. 
> 
> Thanks,
> -Grant
> 
> 
> ## file: A.cpp
> 
> class A
> {
>       public:
>               A();
>               ~A();  
> };
> 
> class B
> {
>       public:
>               B();
>               void DoSomethingWithInstanceOfA(???);
>               ~B();
> };
> 
> A::A()
> {
>       // Do stuff
> }
> 
> B::B()
> {
>       // Do stuff
> }
> 
> B::DoSomethingWithInstanceOfA(???)
> {
>       // Do stuff
> }
> 
> RCPP_MODULE(mod_A)
> {
>       using namespace Rcpp;
>       class_<A>( "A" )
>       .constructor();
> }
> 
> RCPP_MODULE(mod_B)
> {
>       using namespace Rcpp;
>       class_<B>( "B" )
>       .constructor()
>       .method("DoSomethingWithInstanceOfA", &B::DoSomethingWithInstanceOfA);
> }
> 
> 
> ### End pseduo c++ code
> 
> 
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel@lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to