34 static bool isAlreadySetup =
false;
39 isAlreadySetup =
true;
41 std::stringstream exportkeys;
42 exportkeys << RooFitHS3_wsexportkeys;
48 static bool isAlreadySetup =
false;
53 isAlreadySetup =
true;
55 std::stringstream factoryexpressions;
56 factoryexpressions << RooFitHS3_wsfactoryexpressions;
70 static std::map<const std::string, std::vector<std::unique_ptr<const Exporter>>> toAdd;
85 for (
auto &item : exportersToAdd()) {
88 auto &toAdd = item.second;
91 auto nullIt = std::find(toAdd.begin(), toAdd.end(),
nullptr);
93 if (nullIt == toAdd.end()) {
94 throw std::runtime_error(
"toAdd does not contain nullptr separator");
98 exporters.insert(
exporters.end(), std::make_move_iterator(nullIt + 1), std::make_move_iterator(toAdd.end()));
101 exporters.insert(
exporters.begin(), std::make_move_iterator(toAdd.begin()), std::make_move_iterator(nullIt));
105 exportersToAdd().clear();
106 return exportersImpl();
113 return _factoryExpressions;
123bool registerImporter(
const std::string &key, std::unique_ptr<const Importer>
f,
bool topPriority)
126 vec.insert(topPriority ?
vec.begin() :
vec.end(), std::move(
f));
133 vec.insert(topPriority ?
vec.begin() :
vec.end(), std::move(
f));
137bool registerExporter(
const std::string &key, std::unique_ptr<const Exporter>
f,
bool topPriority)
139 auto &
vec = exportersToAdd()[key];
144 vec.emplace_back(
nullptr);
146 vec.insert(topPriority ?
vec.begin() :
vec.end(), std::move(
f));
153int removeByTypeName(Map &
map,
const std::string &needle)
156 for (
auto &element :
map) {
157 for (
size_t i = element.second.size(); i > 0; --i) {
158 auto *imp = element.second[i - 1].get();
159 std::string
name(
typeid(*imp).name());
160 if (
name.find(needle) != std::string::npos) {
161 element.second.erase(element.second.begin() + i - 1);
169template <
class Map,
class KeyPr
inter>
170void printByTypeName(Map &map, KeyPrinter printKey)
172 for (
const auto &
x : map) {
173 for (
const auto &ePtr :
x.second) {
175 auto const &
e = *ePtr;
176 std::cout << printKey(
x.first) <<
"\t" <<
typeid(
e).
name() << std::endl;
185 return removeByTypeName(
importers(), needle);
190 return removeByTypeName(
exporters(), needle);
195 printByTypeName(
importers(), [](
auto const &key) {
return key; });
199 printByTypeName(
exporters(), [](
auto const &key) {
return key->GetName(); });
205 std::ifstream infile(fname);
206 if (!infile.is_open()) {
207 std::cerr <<
"unable to read file '" << fname <<
"'" << std::endl;
219 for (
const auto &cl :
n.children()) {
220 std::string key = cl.key();
221 if (!cl.has_child(
"class")) {
222 std::cerr <<
"error for entry '" << key <<
"': 'class' key is required!" << std::endl;
225 std::string classname(cl[
"class"].val());
228 std::cerr <<
"unable to find class " << classname <<
", skipping." << std::endl;
233 if (!cl.has_child(
"arguments")) {
234 std::cerr <<
"class " << classname <<
" seems to have no arguments attached, skipping" << std::endl;
237 for (
const auto &arg : cl[
"arguments"].children()) {
238 ex.arguments.push_back(arg.val());
240 factoryExpressions[key] =
ex;
254 std::cout << it.first;
255 std::cout <<
" " << it.second.tclass->GetName();
256 for (
auto v : it.second.arguments) {
257 std::cout <<
" " <<
v;
259 std::cout << std::endl;
270 std::ifstream infile(fname);
271 if (!infile.is_open()) {
272 std::cerr <<
"unable to read file '" << fname <<
"'" << std::endl;
284 for (
const auto &cl :
n.children()) {
285 std::string classname = cl.key();
288 std::cerr <<
"unable to find class " << classname <<
", skipping." << std::endl;
292 auto *
type = cl.find(
"type");
293 auto *proxies = cl.find(
"proxies");
295 std::cerr <<
"class " << classname <<
"has not type key set, skipping" << std::endl;
299 std::cerr <<
"class " << classname <<
"has no proxies identified, skipping" << std::endl;
303 for (
const auto &k : proxies->children()) {
304 ex.proxies[k.key()] = k.val();
320 std::cout << it.first->GetName() <<
": " << it.second.type;
321 for (
const auto &kv : it.second.proxies) {
322 std::cout <<
" " << kv.first <<
"=" << kv.second;
324 std::cout << std::endl;
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
static std::unique_ptr< JSONTree > create()
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)
void loadFactoryExpressions(std::istream &is)
void setupFactoryExpressions()
ImportExpressionMap & importExpressions()
static bool registerExporter(const TClass *key, bool topPriority=true)
void clearFactoryExpressions()
int removeImporters(const std::string &needle)
int removeExporters(const std::string &needle)
std::map< TClass const *, std::vector< std::unique_ptr< const Exporter > > > ExportMap
void loadExportKeys(std::istream &is)
std::map< const std::string, ImportExpression > ImportExpressionMap
void printFactoryExpressions()
ExportKeysMap & exportKeys()
std::map< TClass const *, ExportKeys > ExportKeysMap
std::map< const std::string, std::vector< std::unique_ptr< const Importer > > > ImportMap