Variant of TStreamerInfo
to handle conversions.
More...
#include <TConvertingStreamerInfo.h>
Variant of TStreamerInfo
to handle conversions.
Definition at line 34 of file TConvertingStreamerInfo.h.
◆ TConvertingStreamerInfo() [1/2]
TConvertingStreamerInfo::TConvertingStreamerInfo |
( |
| ) |
|
◆ TConvertingStreamerInfo() [2/2]
◆ BuildOld()
void TConvertingStreamerInfo::BuildOld |
( |
| ) |
|
|
virtual |
Compare with class definition to handle schema evolution.
This is a standard TStreamerInfo
method. We override this to intercept warning messages that it produces. If we see a warning related to one of the conversions that we handle, we patch up the TStreamerElement
and swallow the warning.
Definition at line 93 of file TConvertingStreamerInfo.cxx.
95 using namespace std::placeholders;
99 TStreamerInfo::BuildOld();
◆ errhand()
bool TConvertingStreamerInfo::errhand |
( |
int |
level, |
|
|
Bool_t |
abort, |
|
|
const char * |
location, |
|
|
const char * |
msg |
|
) |
| |
|
private |
Error message interceptor.
- Parameters
-
level | Error message level. |
abort | Abort flag. |
location | Function that raised the error. |
msg | Error message. |
We interpose this in front of the default error handler while BuildOld
is running. If we see a message corresponding to a conversion that we handle, we fix up the TStreamerElement
and swallow the message.
Definition at line 194 of file TConvertingStreamerInfo.cxx.
◆ Initialize()
void TConvertingStreamerInfo::Initialize |
( |
| ) |
|
|
static |
Set up conversions.
Definition at line 39 of file TConvertingStreamerInfo.cxx.
43 std::lock_guard<std::mutex> lock (initmutex);
49 TClass*
cl = gROOT->GetClass (
"TStreamerInfo",
true);
55 TVirtualStreamerInfo::Factory ();
57 ::Error (
"TConvertingStreamerInfo",
58 "Can't find TClass for TStreamerInfo");
◆ new_TConvertingStreamerInfo()
void * TConvertingStreamerInfo::new_TConvertingStreamerInfo |
( |
void * |
p | ) |
|
|
staticprivate |
new() method for this object.
- Parameters
-
p | Address for placement new, or 0. |
- Returns
- Address of the new object.
This is installed as the New
method in TStreamerInfo's
TClass
. Thus, when we read from a file a TBranchElement
, we actually make an instance of this class.
- Parameters
-
p | Address for placement new, or 0. |
- Returns
- Address of the new object.
This is installed as the New
method in TStreamerInfo's
TClass
. Thus, when we read from a file a TStreamerInfo
, we actually make an instance of this class.
Definition at line 77 of file TConvertingStreamerInfo.cxx.
◆ operator=()
◆ parse()
bool TConvertingStreamerInfo::parse |
( |
const std::string & |
smsg | ) |
|
|
private |
Error message parser.
- Parameters
-
- Returns
- True if the message was handled; false otherwise.
If this is an error message corresponding to a conversion that we handle, we fix up the TStreamerElement
and return true. Otherwise, return false.
Definition at line 150 of file TConvertingStreamerInfo.cxx.
152 if (smsg.substr (0, 15) !=
"Cannot convert ")
return false;
154 std::string::size_type ifrom = smsg.find (
" from type:");
155 if (ifrom == std::string::npos)
return false;
157 std::string::size_type ifield = smsg.rfind (
"::", ifrom);
158 if (ifield == std::string::npos)
return false;
160 std::string
field (smsg, ifield+2, ifrom - (ifield+2));
162 std::string::size_type ito = smsg.find (
" to type:");
163 if (ito == std::string::npos)
return false;
166 while (ifrom < ito && smsg[ifrom] ==
' ')
168 std::string from (smsg, ifrom, ito - ifrom);
170 std::string::size_type iskip = smsg.find (
", skip element");
171 if (iskip == std::string::npos)
return false;
174 while (ito < iskip && smsg[ito] ==
' ')
176 std::string
to (smsg, ito, iskip - ito);
◆ patch()
bool TConvertingStreamerInfo::patch |
( |
const std::string & |
field, |
|
|
const std::string & |
from, |
|
|
const std::string & |
to |
|
) |
| |
|
private |
- Parameters
-
Streamer | patcher. |
field | Name of the field to patch. |
from | Original (persistent) type. |
to | Target (transient) type. |
- Returns
- True if the conversion was handled; false otherwise.
This is called after an error message for a type mismatch has been successfully parsed. Fix up the TStreamerElement
and return true if this is a conversion we handle; return false otherwise.
Definition at line 115 of file TConvertingStreamerInfo.cxx.
120 std::lock_guard<std::mutex> lock (
mutex);
122 if (TMemberStreamer*
conv =
126 TStreamerElement* elem = GetStreamerElement (
field.c_str(),
offset);
127 TClass*
cl = gROOT->GetClass (
to.c_str());
129 elem->SetTypeName (
to.c_str());
130 elem->Update (elem->GetClass(),
cl);
131 elem->SetNewType (elem->GetType());
132 elem->SetStreamer (
conv);
The documentation for this class was generated from the following files: