[Rcpp-devel] Fwd: package contains overloaded methods in module

Chaomei Lo chaomeilo at gmail.com
Tue Jul 8 20:31:28 CEST 2014


Hi, Romain,

Please see my previous message in below.  When I created a package, the
RcppExports.cpp did not contain any info about the class "Randomizer".
Would you please give a advice ?

Thanks in advance.
Chaomei
---------- Forwarded message ----------
From: Chaomei Lo <chaomeilo at gmail.com>
Date: Tue, Jul 1, 2014 at 11:29 PM
Subject: package contains overloaded methods in module
To: rcpp-devel at lists.r-forge.r-project.org


I use Romain's example as follows (after /// line).  It works fine with the
sourceCpp(..). However, with the package I created, it loaded fine but I
got this error below when I instantiate the class. -Thanks for help.

 > library("testModule", lib.loc="/people/me/.Rlibs")
> r <- new( Randomizer )
Error in .getClassFromCache(Class, where) : object 'Randomizer' not found

////////////////////////////////////////////////////////
#include <Rcpp.h>

using namespace Rcpp;

class Randomizer {
public:

     Randomizer(){}

        NumericVector get( int n ){
                RNGScope scope ;
                return runif( n, 0.0, 1.0 );
        }

        NumericVector get( int n, double min ){
                RNGScope scope ;
                return runif( n, min, 1.0 );
        }

        NumericVector get( int n, double min, double max ){
                RNGScope scope ;
                return runif( n, min, max );
        }

} ;


RCPP_MODULE(mod){

     // helping the compiler disambiguate things
     NumericVector (Randomizer::*get_1)(int) = &Randomizer::get ;
     NumericVector (Randomizer::*get_2)(int,double) = &Randomizer::get ;
     NumericVector (Randomizer::*get_3)(int,double,double) =
&Randomizer::get ;

        class_<Randomizer>( "Randomizer" )

            .default_constructor()

                .method( "get" , get_1 )
                .method( "get" , get_2 )
                .method( "get" , get_3 )
                ;


}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20140708/0c623110/attachment.html>


More information about the Rcpp-devel mailing list