Skip to content
Prev 9119 / 10988 Next

[Rcpp-devel] Template + Rcpp::List error

I will send the complete code and bold the part where it get stuck.

C++ code template created :

namespace Rcpp{
  template<> te::da::DataSourceInfo as (SEXP datasource){
 * Rcpp::List dataSource (datasource);*
  te::da::DataSourceInfo ds;
  Rcpp::String typestring = (dataSource["type"]);
  std::string tstring = typestring;
  if(tstring == "OGR"){

    std::map<std::string, std::string> connInfo;
    Rcpp::List cInfo = dataSource["connInfo"] ;

connInfo.insert(std::pair<std::string,Rcpp::String>("URI",cInfo["URI"]));
    ds.setConnInfo(connInfo);
    ds.setType("OGR");

     }
   return ds
  }
}


Here is where I try to use the template

SEXP getTrajectory(SEXP datasource, SEXP dataset){
 try
  {
    //Indicates the data source
    te::da::DataSourceInfo dsinfo =
Rcpp::as<te::da::DataSourceInfo>(datasource);
   [.....]
   }
}


Here is the R list I send in the "datasource"
$connInfo
[1] "con"

$title
[1] "titl"

$accessDriver
[1] "ad"

$title
[1] "typ"


I send using this method :

setMethod(
  f = "getTrajectory",
  signature = c("DataSourceInfo","DataSetInfo"),
  definition = function(datasource, dataset)
  {
    loadPackages()
    dsource <- list("connInfo"=datasource at connInfo,"title"=datasource at title
,"accessDriver"=datasource at accessDriver,"title"=datasource at type)
    print(dsource)

    dset <- list("tableName"=dataset at tableName)
    c(dset,"phTimeName"=dataset at phTimeName)
    c(dset,"geomName"=dataset at geomName)
    c(dset,"trajId"=dataset at trajId)
    c(dset,"trajName"=dataset at trajName)
    c(dset,"objId"=dataset at trajName)

    traj1 <- getTrajectory(datasource,dataset)
    return (traj1)
  }
)


Is this enough and understandable ?

2016-02-17 20:58 GMT-02:00 Dirk Eddelbuettel <edd at debian.org>:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20160217/aefcbe5b/attachment.html>