Skip to content

Commit f7655c8

Browse files
committed
[hist] Request dictionaries for common RHistEngine<T>
This results in proper error messages when trying to stream. Other instantiations will be caught by the RAxes member.
1 parent 36f7101 commit f7655c8

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

hist/histv7/inc/LinkDef.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
// For RHistEngine, we request dictionaries for the most commonly used bin content types. This results in proper error
2+
// messages when trying to stream. Other instantiations will be caught by the RAxes member.
3+
#pragma link C++ class ROOT::Experimental::RHistEngine<int>-;
4+
#pragma link C++ class ROOT::Experimental::RHistEngine<long>-;
5+
#pragma link C++ class ROOT::Experimental::RHistEngine<long long>-;
6+
#pragma link C++ class ROOT::Experimental::RHistEngine<float>-;
7+
#pragma link C++ class ROOT::Experimental::RHistEngine<double>-;
8+
19
#pragma link C++ class ROOT::Experimental::RRegularAxis-;
210
#pragma link C++ class ROOT::Experimental::RVariableBinAxis-;
311
#pragma link C++ class ROOT::Experimental::Internal::RAxes-;

hist/histv7/test/hist_io.cxx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,29 @@ TEST(RAxes, Streamer)
5050
const RAxes axes({regularAxis, variableBinAxis});
5151
ExpectThrowOnWriteObject(axes);
5252
}
53+
54+
TEST(RHistEngine, Streamer)
55+
{
56+
static constexpr std::size_t Bins = 20;
57+
const RRegularAxis axis(Bins, 0, Bins);
58+
59+
// We don't request a dictionary for RHistEngine<unsigned char>, and we generally don't recommend such narrow bin
60+
// content types. If used, the RAxes member will prevent streaming.
61+
const RHistEngine<unsigned char> engineC({axis});
62+
ExpectThrowOnWriteObject(engineC);
63+
64+
const RHistEngine<int> engineI({axis});
65+
ExpectThrowOnWriteObject(engineI);
66+
67+
const RHistEngine<long> engineL({axis});
68+
ExpectThrowOnWriteObject(engineL);
69+
70+
const RHistEngine<long long> engineLL({axis});
71+
ExpectThrowOnWriteObject(engineLL);
72+
73+
const RHistEngine<float> engineF({axis});
74+
ExpectThrowOnWriteObject(engineF);
75+
76+
const RHistEngine<double> engineD({axis});
77+
ExpectThrowOnWriteObject(engineD);
78+
}

0 commit comments

Comments
 (0)