Dear all,
I would like to use a std::map of pointers to member functions. My class is derived from TSelector.
#include <map>
#include <string>
#include <TNamed.h>
#include <TSelector.h>
class testMap;
//typedef Float_t (testMap::*func_ptr)();
#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ class testMap+;
//#pragma link C++ class map<string, testMap::*func_ptr>+;
#endif
class testMap: public TSelector
{
typedef Float_t (testMap::*func_ptr)();
std::map< std::string, func_ptr > m;
std::map< std::string, func_ptr >::iterator m_it;
Float_t mjj;
inline Float_t getMJJ(){ return mjj; }
/* ... */
public:
testMap()
{
m["mjj"] = &testMap::getMJJ;
}
/* ... */
inline Float_t getVar( TNamed* vD )
{
// My use case is more complex...
m_it = m.find(vD->GetName());
if( m_it != m.end() ) return (this->*this->m_it->second)();
return -99.;
}
/* ... */
};
Here are the errors I get.
root [0] .L testMap.C+
Info in <TUnixSystem::ACLiC>: creating shared library /Users/karolos/data/LargeAnalysisCode/src/test/./testMap_C.so
Error: Symbol G__p2memfuncsecond is not defined in current scope /Applications/root_v5.26.00/cint/cint/lib/prec_stl/utility:19:
Error: class,struct,union or type G__p2memfunc not defined /Applications/root_v5.26.00/cint/cint/lib/prec_stl/map:66:
Error: Symbol G__p2memfuncsecond is not defined in current scope /Applications/root_v5.26.00/cint/cint/lib/prec_stl/utility:19:
Warning: Error occurred during reading source files
Warning: Error occurred during dictionary source generation
!!!Removing /Users/karolos/data/LargeAnalysisCode/src/test/./testMap_C_ACLiC_dict.cxx /Users/karolos/data/LargeAnalysisCode/src/test/./testMap_C_ACLiC_dict.h !!!
Error: /Applications/root_v5.26.00/bin/rootcint: error loading headers...
Error in <ACLiC>: Dictionary generation failed!
Info in <ACLiC>: Invoking compiler to check macro's validity
Info in <ACLiC>: The compiler has not found any problem with your macro.
Probably your macro uses something rootcint can't parse.
Check http://root.cern.ch/root/Cint.phtml?limitations for Cint's limitations.
root [1]
I’ve been going a bit into the map header and saw that the problem is at a line that attempts
typedef T mapped_type;
and then the utility header tries to use
Could it be a simple space issue, i.e that G__p2memfuncsecond should be G__p2memfunc second (extra space) ?
I have tried to use pragma and to move the typdef to a global one without success. This is the farthest as I could get.
I am not familiar with the inner workings of CINT and I also understand that this is a limit use case. Is there a workaround to this or is this something that requires a modification in CINT ?
I have also tried to compile my library as a shared class but I couldn’t load it:
root [0] .L testMap.so
dlopen error: /home/karolos/data/LargeAnalysisCode/src/test/./testMap.so: undefined symbol: _ZN9testMap201011ShowMembersER16TMemberInspectorPc
Load Error: Failed to load Dynamic link library /home/karolos/data/LargeAnalysisCode/src/test/./testMap.so
*** Interpreter error recovered ***
Is there a way to manually add this TMemberInspector object, i.e. make my dictionary manually ? I tried to figure out if it was possible for rootcint to provide me with the dictionary it was able to generate instead of deleting it in order to have a look myself but without success.
The whole point of what I’m doing is to use Proof and submit my analysis. The code would be anyhow compiled and there is only the getVar that CINT needs to be aware of. Is it possible to mask the inner details of using a map ? Also, I don’t know on which line CINT fails ; is there a way to get a verbose output to makecint ? The man page doesn’t seem to suggest anything like that.
Thanks for your help,
Karolos