[Rcpp-devel] Locating an Instance of a Reference Class in the Environment
On 22 March 2023 at 13:31, Matthew Supernaw - NOAA Federal wrote:
| I'm trying to get an instance of a reference class (vonBertalanffyInterface)
| from the R environment with the following code:
|
| void SetName(vonBertalanffyInterface& v) {
|
| Â Â Rcpp::Environment env = Rcpp::Environment::global_env();
| Â Â Rcpp::List l = Rcpp::as<Rcpp::List>(env.ls(true));
|
| Â Â for (int i = 0; i < l.size(); i++) {
| Â Â Â Â std::cout << typeid (l[i]).name() << std::endl;
| Â Â Â Â
| Â Â Â Â if(&v == l[i].get()){
| Â Â Â Â Â Â v.name Rcpp::as<std::string>(l[i]);
| Â Â Â Â }
| Â Â }
| }
|
| The problem is that elements in the list are of typeÂ
| N4Rcpp8internal13generic_proxyILi19ENS_15PreserveStorageEEE.
|
| I'm assuming that PreserveStorage is a wrapper class. Is there a way to
| retrieve the reference class from the PreserveStorage object?
Interesting question. Can you do it in plain R (once you created the object) ?
Dirk
dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org