33 static std::map<const std::string, std::vector<std::unique_ptr<const Exporter>>> toAdd;
48 for (
auto &item : exportersToAdd()) {
51 auto &toAdd = item.second;
54 auto nullIt = std::find(toAdd.begin(), toAdd.end(),
nullptr);
56 if (nullIt == toAdd.end()) {
57 throw std::runtime_error(
"toAdd does not contain nullptr separator");
61 exporters.insert(
exporters.end(), std::make_move_iterator(nullIt + 1), std::make_move_iterator(toAdd.end()));
64 exporters.insert(
exporters.begin(), std::make_move_iterator(toAdd.begin()), std::make_move_iterator(nullIt));
68 exportersToAdd().clear();
69 return exportersImpl();
72bool registerImporter(
const std::string &key, std::unique_ptr<const Importer>
f,
bool topPriority)
75 vec.insert(topPriority ? vec.begin() : vec.end(), std::move(
f));
82 vec.insert(topPriority ? vec.begin() : vec.end(), std::move(
f));
86bool registerExporter(
const std::string &key, std::unique_ptr<const Exporter>
f,
bool topPriority)
88 auto &vec = exportersToAdd()[key];
93 vec.emplace_back(
nullptr);
95 vec.insert(topPriority ? vec.begin() : vec.end(), std::move(
f));
102int removeByTypeName(Map &map,
const std::string &needle)
105 for (
auto &element : map) {
106 for (
size_t i = element.second.size(); i > 0; --i) {
107 auto *imp = element.second[i - 1].get();
108 std::string
name(
typeid(*imp).name());
109 if (
name.find(needle) != std::string::npos) {
110 element.second.erase(element.second.begin() + i - 1);
118template <
class Map,
class KeyPr
inter>
119void printByTypeName(Map &map, KeyPrinter printKey)
121 for (
const auto &
x : map) {
122 for (
const auto &ePtr :
x.second) {
124 auto const &
e = *ePtr;
125 std::cout << printKey(
x.first) <<
"\t" <<
typeid(
e).
name() << std::endl;
134 return removeByTypeName(
importers(), needle);
139 return removeByTypeName(
exporters(), needle);
144 printByTypeName(
importers(), [](
auto const &key) {
return key; });
148 printByTypeName(
exporters(), [](
auto const &key) {
return key->GetName(); });
TClass instances represent classes, structs and namespaces in the ROOT type system.
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
static bool registerImporter(const std::string &key, bool topPriority=true)
static bool registerExporter(const TClass *key, bool topPriority=true)
int removeImporters(const std::string &needle)
int removeExporters(const std::string &needle)
std::map< TClass const *, std::vector< std::unique_ptr< const Exporter > > > ExportMap
std::map< const std::string, std::vector< std::unique_ptr< const Importer > > > ImportMap