|
13 | 13 | #include <TMemberStreamer.h> |
14 | 14 | #include <TBuffer.h> |
15 | 15 | #include <TClass.h> |
| 16 | +#include <TError.h> |
16 | 17 | #include <DataFormatsTPC/Defs.h> |
17 | | -#include <cstdlib> |
18 | 18 | #include <iostream> |
| 19 | +#include <cstdlib> |
| 20 | +#include <vector> |
19 | 21 |
|
20 | 22 | // to enable assert statements |
21 | 23 | #ifdef NDEBUG |
@@ -66,32 +68,37 @@ void MemberVectorPadFlagsStreamer(TBuffer& R__b, void* objp, int n) |
66 | 68 | } |
67 | 69 | } |
68 | 70 |
|
69 | | -// Register the streamer via static global initialization on library load. |
70 | | -// The streamer is only correct in combination with new ROOT. |
71 | | -// |
72 | | -// Do not use ROOT::GenerateInitInstance here: it is not available in all ROOT |
73 | | -// builds/versions where this file is compiled. Also do not assert if the class |
74 | | -// lookup fails during static initialization: depending on library load order the |
75 | | -// dictionary may not be available yet, and killing the process at this point |
76 | | -// makes the whole build/load fail. |
| 71 | +// register the streamer via static global initialization (on library load) |
| 72 | +// the streamer is only correct in combination with new ROOT |
77 | 73 | #if ROOT_VERSION_CODE >= ROOT_VERSION(6, 33, 00) |
78 | | -namespace |
| 74 | +namespace ROOT |
79 | 75 | { |
80 | | -[[maybe_unused]] __attribute__((used)) int _R__dummyStreamer_3 = []() { |
81 | | - if (std::getenv("TPC_PADFLAGS_STREAMER_OFF")) { |
82 | | - return 0; |
83 | | - } |
| 76 | +static __attribute__((used)) int _R__dummyStreamer_3 = |
| 77 | + ([]() { |
| 78 | + if (getenv("TPC_PADFLAGS_STREAMER_OFF")) { |
| 79 | + return 0; |
| 80 | + } |
84 | 81 |
|
85 | | - auto* cl = TClass::GetClass<o2::tpc::CalArray<o2::tpc::PadFlags>>(); |
86 | | - if (!cl) { |
87 | | - std::cerr << "Warning in TPCFlagsMemberCustomStreamer: could not find " |
88 | | - << "TClass for o2::tpc::CalArray<o2::tpc::PadFlags>; " |
89 | | - << "PadFlags member streamer was not registered" << std::endl; |
90 | | - return 0; |
91 | | - } |
| 82 | + auto cl = TClass::GetClass( |
| 83 | + "o2::tpc::CalArray<o2::tpc::PadFlags>", |
| 84 | + true, // try to autoload dictionary |
| 85 | + true // silent |
| 86 | + ); |
| 87 | + |
| 88 | + if (!cl) { |
| 89 | + ::Warning("TPCFlagsMemberCustomStreamer", |
| 90 | + "could not find TClass for " |
| 91 | + "o2::tpc::CalArray<o2::tpc::PadFlags>; " |
| 92 | + "PadFlags member streamer was not registered"); |
| 93 | + return 0; |
| 94 | + } |
| 95 | + |
| 96 | + cl->AdoptMemberStreamer( |
| 97 | + "mData", |
| 98 | + new TMemberStreamer(MemberVectorPadFlagsStreamer) |
| 99 | + ); |
92 | 100 |
|
93 | | - cl->AdoptMemberStreamer("mData", new TMemberStreamer(MemberVectorPadFlagsStreamer)); |
94 | | - return 0; |
95 | | -}(); |
96 | | -} // namespace |
| 101 | + return 0; |
| 102 | + })(); |
| 103 | +} // namespace ROOT |
97 | 104 | #endif |
0 commit comments