Logo ROOT  
Reference Guide
ExpClass.C
Go to the documentation of this file.
1 
2 #include<TRInterface.h>
3 
4 using namespace Rcpp ;
5 
6 class 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 
24 Foo make_foo(){ return Foo(3, 4) ; }
25 
26 RCPP_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 
43 void ExpClass()
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 }
r
ROOT::R::TRInterface & r
Definition: Object.C:4
ROOT::R::TRInterface
ROOT R was implemented using the R Project library and the modules Rcpp and RInside
Definition: TRInterface.h:137
RCPP_MODULE
RCPP_MODULE(Mod)
Definition: ExpClass.C:28
x
Double_t x[n]
Definition: legend1.C:17
TRInterface.h
Rcpp
This is a class to support deprecated method to pass function to R's Environment, based in Rcpp::Inte...
Definition: RExports.h:64
ROOT::R::function
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
Definition: RExports.h:151
double
double
Definition: Converters.cxx:921
y
Double_t y[n]
Definition: legend1.C:17
LOAD_ROOTR_MODULE
#define LOAD_ROOTR_MODULE(NAME)
Definition: RExports.h:177
make_foo
Foo make_foo()
Definition: ExpClass.C:24
ROOT::R::TRInterface::Instance
static TRInterface & Instance()
static method to get an TRInterface instance reference
Definition: TRInterface.cxx:185
ExpClass
void ExpClass()
Definition: ExpClass.C:43