Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake/MacroRootDict.cmake adding std:: containing struct to dictionary #356

Merged
merged 4 commits into from
Dec 28, 2022

Conversation

jgalan
Copy link
Member

@jgalan jgalan commented Dec 22, 2022

jgalan Ok: 49

Now, the dictionary for structures will be added in the class that they are used with a std:: list.

Extract from cmake output:

-- Testing disabled (Disabled by default, enabled via -DTEST=ON flag)
-- /usr/bin/git submodule foreach git rev-parse --git-path hooks
-- Check for ROOT_DICT_OUTPUT_DIR: /home/jgalan/rest-framework/build/rootdict
-- Check for ROOT_DICT_CINT_DEFINITIONS: 
-- Begin of external dependencies
-- making build files for /home/jgalan/rest-framework/source/framework, schema evolution: 
specified sub-dirs: external/tinyxml;tools;core;analysis;masks
-- Adding std::vector<HistoInfoSet> to the dictionary!
-- Adding std::map<std::string, RelevantQuantity> to the dictionary!

This solves a problem that appeared when trying to read a TRestDataSet.

See also:
https://root-forum.cern.ch/t/problem-with-std-map-and-structure-when-stored-in-root-i-o-streamer-dictionary/52852

@jgalan jgalan marked this pull request as ready for review December 23, 2022 07:59
@juanangp
Copy link
Member

juanangp commented Dec 23, 2022

Don't quite understand these changes, this is to create some kind of umbrella dictionary for all stl containers?

@jgalan
Copy link
Member Author

jgalan commented Dec 23, 2022

Don quite understand these changes, this is to create some kind of umbrella dictionary for all stl containers?

It generates the following new lines inside the LinkDef file we generate before dictionary compilation.

#pragma link C++ class RelevantQuantity+;
#pragma link C++ class std::map<std::string, RelevantQuantity>+;

The full TRestDataSet_LinkDef.h file looks as follows:

#ifdef __CINT__
#pragma link off all globals;
#pragma link off all classes;
#pragma link off all functions;
#pragma link C++ nestedclasses;
#pragma link C++ nestedtypedef;
#pragma link C++ class RelevantQuantity+;
#pragma link C++ class std::map<std::string, RelevantQuantity>+;
#pragma link C++ class TRestDataSet+;
#endif

It was to solve the problem reported in the ROOT forum
https://root-forum.cern.ch/t/problem-with-std-map-and-structure-when-stored-in-root-i-o-streamer-dictionary/52852

The code addition searches for struct StructName and then it searches if a std::XYZ <StructName> exists, if it does it automatically creates those new lines inside the LinkDef.

@jgalan jgalan requested review from lobis, juanangp and nkx111 December 23, 2022 10:15
@jgalan
Copy link
Member Author

jgalan commented Dec 23, 2022

It is a critical/urgent update I need to be able to open files generated using TRestDataSet.

@jgalan jgalan merged commit c9bd40c into master Dec 28, 2022
@jgalan jgalan deleted the jgalan_add_std_to_dictionary branch December 28, 2022 09:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants