//Example to create class Functor //Author: Omar Zapata #include #include typedef Double_t (*Function)(Double_t); //Functor class with the function inside class MyFunctor{ public: MyFunctor(){ status=false; f=TMath::BesselY1; } void setFunction(Function fun) { f=fun; status=true; } Bool_t getStatus(){return status;} Double_t doEval(Double_t x) { return f(x); } private: Function f; Bool_t status; }; //this macro exposes the class into R's enviornment // and lets you pass objects directly. ROOTR_EXPOSED_CLASS(MyFunctor) //Macro to create a module ROOTR_MODULE(MyFunctorModule) { ROOT::R::class_( "MyFunctor" ) //creating a default constructor .constructor() //adding the method doEval to evaluate the internal function .method( "doEval", &MyFunctor::doEval ) .method( "getStatus", &MyFunctor::getStatus) ; } void Functor() { ROOT::R::TRInterface &r=ROOT::R::TRInterface::Instance(); ////////////////////////////////////////////////////////// //Creating functor with deafult function TMath::BesselY1// // and status false from R's environment // ////////////////////////////////////////////////////////// //Loading module into R's enviornment r["MyFunctorModule"]<