[Rcpp-devel] Reading-list when creating a mapping for a semi-complex C++ library
edd at debian.org
Sun Jul 24 00:44:39 CEST 2011
On 23 July 2011 at 23:24, Steffen Neumann wrote:
| I am asking for a reading list (rather than the actual answers,
| certainly it is somewhere in the great and vast Documentation!)
| or best practices creating R bindings to a moderately complex
| C++ library.
| We have created https://github.com/sneumann/mzR
| which is an R package to read mass spectrometry data,
| using the http://proteowizard.sourceforge.net/ (short: pwiz) library.
| The first thing we did was to create a C++ wrapper class,
| which encapsulated the "complexity" of pwiz, and would have
| a number ov Rcpp::List::create(...) to prepare the return
| values and a single Rcpp-module to call into the wrapper class.
| That works fine, and now we want to go one step further ;-)
| The class hierarchy in pwiz has a class "MSData",
| which contains a class "Run" which contains a class "SpectrumListPtr"
| which is a "boost::shared_ptr<SpectrumList>" etc. You get the idea.
| An example of what one can do in C++ is line 60..100
| and it would be great to be able to do something similar in R.
| 1) Is it feasible to create Rcpp-modules for each of these classes,
| so that accessing them can be programmed in R ?
"Maybe". Rcpp Modules are very nice, very useful and quite promising. But
some things are limiting as e.g. the inability to have inheritance.
| 2) Or does it make more sense to create C++ wrappers which are simpler
| to add as Rcpp-module(s), and to keep the R side simpler ?
"Maybe". That is what I have done in the past. It's simple, but it does not
scale very well. But maybe you can use some cheap labour from Univ. Halle :)
| 3) Which of the existing packages using Rcpp comes closest
| (in terms of architecture) to what I want, so I can go
| and read their code for inspiration ?
Maybe my (in the architectural sense "old fashioned / simple") RQuantLib
which was at the start of Rcpp? It accesses a somewhat large, complex,
Boost-using library called QuantLib.
RSNNS may be another candidate but I haven't looked that closely at it for
lack of time. Others may speak for their projects.
Hope this helps, Dirk
Gauss once played himself in a zero-sum game and won $50.
-- #11 at http://www.gaussfacts.com
More information about the Rcpp-devel