Logo ROOT  
Reference Guide
ExpClass.C
Go to the documentation of this file.
1
2#include<TRInterface.h>
3
4using namespace Rcpp ;
5
6class Foo{
7 public:
8 enum Bla{ FOO, BAR } ;
9
10 Foo( double x_, double y_) : x(x_), y(y_){}
11
12 Foo* clone(){
13 return new Foo( x, y) ;
14 }
15
16 double x, y ;
17
18 void bla(const Foo& other){
19 Rprintf( "efez\n" ) ;
20 }
21
22} ;
23
24Foo make_foo(){ return Foo(3, 4) ; }
25
26RCPP_EXPOSED_CLASS(Foo)
27
29
30 class_<Foo>("Foo" )
31 .constructor<double,double>()
32 .method( "clone", &Foo::clone )
33
34 .field( "x", &Foo::x )
35 .field( "y", &Foo::y )
36
37 .method( "bla", &Foo::bla )
38 ;
39 Rcpp::function( "make_foo", &make_foo ) ;
40
41}
42
44{
46 r["Mod"]<<LOAD_ROOTR_MODULE(Mod);
47
48 r<<"Foo <- Mod$make_foo()";
49 r<<"Foo$bla(Foo)";
50 r<<"f <- Foo$clone()";
51 r<<"f$bla(Foo)";
52}
double
Definition: Converters.cxx:921
void ExpClass()
Definition: ExpClass.C:43
Foo make_foo()
Definition: ExpClass.C:24
RCPP_MODULE(Mod)
Definition: ExpClass.C:28
ROOT::R::TRInterface & r
Definition: Object.C:4
#define LOAD_ROOTR_MODULE(NAME)
Definition: RExports.h:177
ROOT R was implemented using the R Project library and the modules Rcpp and RInside
Definition: TRInterface.h:136
static TRInterface & Instance()
static method to get an TRInterface instance reference
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
Definition: RExports.h:151
This is a class to support deprecated method to pass function to R's Environment, based in Rcpp::Inte...
Definition: RExports.h:64