ATLAS Offline Software
Loading...
Searching...
No Matches
Configuration.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8
9#include <nlohmann/json.hpp>
10
11#include <cstdlib>
12#include <fstream>
13#include <stdexcept>
14
15namespace columnar
16{
17 namespace TestUtils
18 {
19 void UserConfiguration ::
20 loadFromFile (const std::string& filename)
21 {
22 std::ifstream file (filename);
23 if (!file.is_open())
24 throw std::runtime_error ("failed to open configuration file: " + filename);
25
26 auto json = nlohmann::json::parse (file);
27
28 if (json.contains ("targetTime"))
29 targetTime = std::chrono::seconds (json["targetTime"].get<int>());
30 if (json.contains ("batchSize"))
31 batchSize = json["batchSize"].get<unsigned int>();
32 if (json.contains ("runToolTwice"))
33 runToolTwice = json["runToolTwice"].get<bool>();
34 if (json.contains ("skipShallowCopies"))
35 skipShallowCopies = json["skipShallowCopies"].get<bool>();
36 if (json.contains ("measureNonAccessForEmpty"))
37 measureNonAccessForEmpty = json["measureNonAccessForEmpty"].get<bool>();
38 }
39
40 UserConfiguration UserConfiguration :: fromEnvironment ()
41 {
43 const char *envPath = std::getenv ("COLUMNAR_TEST_CONFIG");
44 if (envPath != nullptr && envPath[0] != '\0')
45 config.loadFromFile (envPath);
46 return config;
47 }
48 }
49}
nlohmann::json json
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130
TFile * file