Hi again list,
I'm continuing to investigate the possibilities of modules for my project.
and I can't found how to push a template class instance into the module. Since I'm not very good it my be a bad programming habbit of mine (in this case this is not a Rcpp question I admit) or it can be that what I'm trying to do is not allowed
below is a dumb example with class definition module definition and error log which ends up with
"invalid use of incomplete type ?class dynamicOf_<firstClass>"
any comments or idea
------ templateModule.h
#include <RcppCommon.h>
class firstClass ;
class secondClass ;
template<class aClass>
class dynamicOf_;
class firstClass
{
public:
double value_ ;
~firstClass(){Rcpp::Rcout<<"destructing firstClass"<<std::endl;};
firstClass(){Rcpp::Rcout<<"constructing firstClass"<<std::endl;};
firstClass(double value) : value_(value){};
};
class secondClass
{
public:
~secondClass(){Rcpp::Rcout<<"destructing secondClass"<<std::endl;};
secondClass(){Rcpp::Rcout<<"constructing secondClass"<<std::endl;};
};
template<class aClass>
class dynamicOf_{
public :
aClass obj;
double dyn_info;
~dynamicOf_(){};
dynamicOf_(){};
};
---- templatemodule.cpp
#include "TemplateModule.h"
#include <Rcpp.h>
RCPP_EXPOSED_CLASS(firstClass)
RCPP_EXPOSED_CLASS(secondClass)
RCPP_EXPOSED_CLASS(dynamicOf_<firstClass>)
RCPP_EXPOSED_CLASS(dynamicOf_<secondClass>)
RCPP_MODULE(mod_example_template){
using namespace Rcpp;
class_<firstClass>( "firstClass" )
//constructors
.constructor()
;
class_<secondClass>( "secondClass" )
//constructors
.constructor()
;
class_<dynamicOf_<firstClass> >( "dynamicOf_firstClass" )
//constructors
.constructor()
;
}
------ error log
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/XPtr.h: In function ?void Rcpp::standard_delete_finalizer(T*) [with T = dynamicOf_<firstClass>]?:
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/module/class.h:39: instantiated from ?Rcpp::class_<dynamicOf_<firstClass> >?
TemplateModule.cpp:21: instantiated from here
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/XPtr.h:39: warning: possible problem detected in invocation of delete operator:
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/XPtr.h:38: warning: ?obj? has incomplete type
TemplateModule.h:26: warning: declaration of ?class dynamicOf_<firstClass>?
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/XPtr.h:39: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined.
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/module/class.h: In constructor ?Rcpp::class_<Class>::class_(const char*, const char*) [with Class = dynamicOf_<firstClass>]?:
TemplateModule.cpp:21: instantiated from here
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/module/class.h:71: error: invalid use of incomplete type ?class dynamicOf_<firstClass>?
TemplateModule.h:26: error: declaration of ?class dynamicOf_<firstClass>?
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/module/Module_generated_Constructor.h: In member function ?Class* Rcpp::Constructor_0<Class>::get_new(SEXPREC**, int) [with Class = dynamicOf_<firstClass>]?:
TemplateModule.cpp:24: instantiated from here
/Library/Frameworks/R.framework/Versions/2.15/Resources/library/Rcpp/include/Rcpp/module/Module_generated_Constructor.h:37: error: invalid use of incomplete type ?class dynamicOf_<firstClass>?
TemplateModule.h:26: error: declaration of ?class dynamicOf_<firstClass>?
make: *** [TemplateModule.o] Error 1
ERROR: compilation failed for package ?ReproducibleExample?
Dr. Girard Robin
Charg? de Recherche
MINES-ParisTech / D?partement Energ?tique et Proc?d?s / PERSEE / Groupe ERSEI
Centre Proc?d?s, Energies Renouvelables et Syst?mes Energ?tiques (PERSEE)
Center for Processes, Renewables Energies and Energy Systems
Renewable Energies & Smartgrids (ERSEI)
1 Rue Claude Daunesse - CS 10207 - F-06904 Sophia Antipolis Cedex
Tel: +33.4.93.67.89.64 (~99), Fax: +33.4.93.95.75.35
e-mail : robin.girard at mines-paristech.fr
web page perso http://www.mines-paristech.fr/Services/Annuaire/&?id=8828
statoverflow : http://stats.stackexchange.com/users/223/robin-girard
web page centre PERSEE : http://www.cep.mines-paristech.fr/
linkedin : http://www.linkedin.com/profile/view?id=14907272&trk=tab_pro
Le lien vaut mieux que le bien.
________________________________________________________
CONFIDENTIALITY : This e-mail and any attachments are
confidential and may be privileged. If you are not a
named recipient, please notify the sender immediately and
do not disclose the contents to another person, use it for
any purpose or store or copy the information in any medium.
CONFIDENTIALITE : Ce message et les ?ventuelles pi?ces
attach?es sontconfidentiels et peuvent ?tre une
communication prot?g?e. Si vous n'?tes pas dans la liste
des destinataires, veuillez informer l'exp?diteur
imm?diatement et ne pas ouvrir ni divulguer le contenu
? une tierce personne, ne pas l'utiliser pour quelque
raison que ce soit, ne pas stocker ou copier l'information
qu'il contient sur un quelconque support.