Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
util.h
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file util.h
1
// TRENTO: Reduced Thickness Event-by-event Nuclear Topology
2
// Copyright 2015 Jonah E. Bernhard, J. Scott Moreland
3
// MIT License
4
5
#ifndef UTIL_H
6
#define UTIL_H
7
8
#include <iostream>
9
#include <sstream>
10
11
#include <boost/filesystem.hpp>
12
#include <boost/program_options/variables_map.hpp>
13
14
#include "../src/fwd_decl.h"
15
16
// testing utilities
17
18
// Factory function; create a dummy boost::program_options::variables_map.
19
VarMap
make_var_map
(std::map<std::string, boost::any>&&
args
);
20
21
// redirect stdout to a stringstream and safely restore upon destruction
22
struct
capture_stdout
{
23
capture_stdout
() {
24
// replace stdout buffer
25
cout_orig
= std::cout.rdbuf(
stream
.rdbuf());
26
}
27
28
~capture_stdout
() {
29
// restore stdout to working state
30
std::cout.rdbuf(
cout_orig
);
31
}
32
33
std::streambuf*
cout_orig
;
34
std::stringstream
stream
;
35
};
36
37
// path that deletes itself when it goes out of scope
38
struct
temporary_path
{
39
temporary_path
(
const
fs::path
& ext =
fs::path
{})
40
:
path
(
41
fs::temp_directory_path() /
42
fs::unique_path().replace_extension(ext)
43
)
44
{}
45
~temporary_path
() {
46
fs::remove_all(
path
);
47
}
48
const
fs::path
path
;
49
};
50
51
#endif // UTIL_H
JETSCAPE
blob
main
external_packages
trento
test
util.h
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:18:24
using
1.8.2 with
sPHENIX GitHub integration