[Rcpp-devel] nicer show method for C++Class
Romain Francois
romain at r-enthusiasts.com
Mon Nov 22 20:48:18 CET 2010
Le 22/11/10 19:48, Romain Francois a écrit :
> Le 22/11/10 16:08, Romain Francois a écrit :
>> Hello,
>>
>> I've modified the show method for C++Class so that it prints more
>> information:
> > [...]
>> Things to do:
>> - maybe pull out the const-ness of methods
Done. Silly example updated ;
require( Rcpp )
require( inline )
inc <- '
class Simple {
public:
Simple( ) : d_x(10.0){} ;
Simple( double x ) : d_x(x){} ;
const double& x(){ return d_x ;}
void move( double x ) { d_x += x ; }
double blabla() const { return d_x * 2 ; }
private:
double d_x ;
} ;
double bla( Simple* data ){ return 3; }
RCPP_MODULE(mod){
class_<Simple>( "Simple" )
.constructor( "default constructor" )
.constructor<double>( "bla bla bla" )
.property( "x" , &Simple::x , "documentation for x" )
.method( "move", &Simple::move, "some documentation for the move
method" )
.method( "blabla", &Simple::blabla, "some documentation for the blabla
method" )
.method( "bla", &bla, "bla bla" )
;
}
'
fx <- cxxfunction( , '', includes = inc, plugin = "Rcpp" )
mod <- Module( "mod", getDynLib( fx ) )
Simple <- mod$Simple
> show(Simple)
C++ class 'Simple' <0x1005450f0>
Constructors:
Simple()
docstring : default constructor
Simple(double)
docstring : bla bla bla
Fields:
double x [readonly]
docstring : documentation for x
Methods:
double bla()
docstring : bla bla
double blabla() const
docstring : some documentation for the blabla method
void move(double)
docstring : some documentation for the move method
Anything else in that department ?
--
Romain Francois
Professional R Enthusiast
+33(0) 6 28 91 30 30
http://romainfrancois.blog.free.fr
|- http://bit.ly/9VOd3l : ZAT! 2010
|- http://bit.ly/c6DzuX : Impressionnism with R
`- http://bit.ly/czHPM7 : Rcpp Google tech talk on youtube
More information about the Rcpp-devel
mailing list