ATLAS Offline Software
Loading...
Searching...
No Matches
TConverterRegistry.h
Go to the documentation of this file.
1// This file's extension implies that it's C, but it's really -*- C++ -*-.
2
3/*
4 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5*/
23
24
25#ifndef ROOTCONVERSIONS_TCONVERTERREGISTRY_H
26#define ROOTCONVERSIONS_TCONVERTERREGISTRY_H
27
28#include <map>
29#include <mutex>
30#include <string>
31#include "Rtypes.h"
32
34class TMemberStreamer;
35
36
41{
42public:
47
48
49 //==========================================================================
50 // @c TConvertingBranchElement converters.
51 //
52
63
72 void AddConverter (TVirtualConverter* conv, bool takeown);
73
82 bool AddConverter (const char* convname);
83
90 TVirtualConverter* GetConverter (const char* name, int checksum) const;
91
92
93 //==========================================================================
94 // @c TConvertingStreamerInfo converters.
95 //
96
97 void AddStreamerConverter (const std::string& from_type,
98 const std::string& to_type,
99 TMemberStreamer* streamer);
100
101 TMemberStreamer* GetStreamerConverter (const std::string& from_type,
102 const std::string& to_type) const;
103
104
105private:
108
109 // We store a map of names to maps of checksums to converters.
110 // The bool flag tells whether or not we own this converter.
111 using Payload = std::pair<TVirtualConverter*, bool>;
112 using CheckSumMap = std::map<UInt_t, Payload>;
113 using MapType = std::map<std::string, CheckSumMap>;
114
117
119 mutable std::mutex fMutex;
120 using lock_t = std::lock_guard<std::mutex>;
121
123#ifndef __CLING__
124 using SMapType = std::map<std::string, TMemberStreamer*>;
126#endif
127};
128
129
130#endif // not ROOTCONVERSIONS_TCONVERTERREGISTRY_H
Registry for Root converters.
MapType fMap
Map of registered converters.
TMemberStreamer * GetStreamerConverter(const std::string &from_type, const std::string &to_type) const
std::map< UInt_t, Payload > CheckSumMap
std::map< std::string, TMemberStreamer * > SMapType
Streamer converters.
std::map< std::string, CheckSumMap > MapType
std::pair< TVirtualConverter *, bool > Payload
std::lock_guard< std::mutex > lock_t
static TConverterRegistry * Instance()
Return a pointer to the global registry instance.
void AddConverter(TVirtualConverter *conv)
Add a new converter to the registry.
std::mutex fMutex
Protect access to the map.
void AddStreamerConverter(const std::string &from_type, const std::string &to_type, TMemberStreamer *streamer)
TVirtualConverter * GetConverter(const char *name, int checksum) const
Look up a converter in the registry by name and checksum.
Base class for converters for Root schema evolution.