6 #ifndef HELPER_HPP_INCLUDE
7 #define HELPER_HPP_INCLUDE
27 template <
class Type,
class ...Args>
30 return std::unique_ptr<Type>(
new Type(std::forward<Args>(args)...));
55 write_file(
const std::string &path,
const std::string &contents);
63 string_split(
const std::string &str,
const std::string &delim);
70 string_join(
const std::vector<std::string> &string_list,
const std::string &delim);
148 static constexpr
int hardware_destructive_interference_size = 64;
154 get_env(
const std::string &name);
189 std::unique_ptr<cpu_set_t, std::function<void(cpu_set_t *)> >
GEOPM_PUBLIC
190 make_cpu_set(
int num_cpu,
const std::set<int> &cpu_enabled);
Definition: Helper.hpp:204
virtual ~DeprecationWarning()=default
DeprecationWarning()=delete
#define GEOPM_PUBLIC
Definition: geopm_public.h:10
void enable_fixed_counters(PlatformIO &pio)
Definition: Helper.cpp:435
bool string_ends_with(std::string str, std::string key)
Returns whether one string ends with another.
Definition: Helper.cpp:168
std::function< std::string(double)> string_format_type_to_function(int format_type)
Convert a format type enum string_format_e to a format function.
Definition: Helper.cpp:219
std::string string_join(const std::vector< std::string > &list, const std::string &delim)
Joins a vector of strings together with a delimiter.
Definition: Helper.cpp:118
std::vector< std::string > string_split(const std::string &str, const std::string &delim)
Splits a string according to a delimiter.
Definition: Helper.cpp:96
std::string get_env(const std::string &name)
Read an environment variable.
Definition: Helper.cpp:268
int string_format_function_to_type(std::function< std::string(double)> format_function)
Convert a format function to a format type enum string_format_e.
Definition: Helper.cpp:251
std::unique_ptr< Type > make_unique(Args &&...args)
Implementation of std::make_unique (C++14) for C++11. Note that this version will only work for non-a...
Definition: Helper.hpp:28
std::string read_symlink_target(const std::string &symlink_path)
Definition: Helper.cpp:408
std::string hostname(void)
Returns the current hostname as a string.
Definition: Helper.cpp:132
std::string string_format_raw64(double signal)
Format a string to represent the raw memory supporting a signal as an unsigned hexadecimal integer.
Definition: Helper.cpp:211
std::string string_format_double(double signal)
Format a string to best represent a signal encoding a double precision floating point number.
Definition: Helper.cpp:175
void write_file(const std::string &path, const std::string &contents)
Writes a string to a file. This will replace the file if it exists or create it if it does not exist.
Definition: Helper.cpp:84
std::string read_file(const std::string &path)
Reads the specified file and returns the contents in a string.
Definition: Helper.cpp:41
unsigned int pid_to_gid(const int pid)
Query for the group id associated with the process id.
Definition: Helper.cpp:308
std::string string_format_integer(double signal)
Format a string to best represent a signal encoding a decimal integer.
Definition: Helper.cpp:189
std::vector< std::string > list_directory_files(const std::string &path)
List all files in the given directory.
Definition: Helper.cpp:143
std::unique_ptr< cpu_set_t, std::function< void(cpu_set_t *)> > make_cpu_set(int num_cpu, const std::set< int > &cpu_enabled)
Wrapper around CPU_ALLOC and CPU_FREE.
Definition: Helper.cpp:320
bool has_cap_sys_admin(void)
Check if the caller has effective capability CAP_SYS_ADMIN.
Definition: Helper.cpp:380
std::string string_format_float(double signal)
Format a string to best represent a signal encoding a single precision floating point number.
Definition: Helper.cpp:182
string_format_e
Definition: Helper.hpp:89
@ STRING_FORMAT_RAW64
Definition: Helper.hpp:93
@ STRING_FORMAT_DOUBLE
Definition: Helper.hpp:90
@ STRING_FORMAT_INTEGER
Definition: Helper.hpp:91
@ STRING_FORMAT_HEX
Definition: Helper.hpp:92
std::string string_format_hex(double signal)
Format a string to best represent a signal encoding an unsigned hexadecimal integer.
Definition: Helper.cpp:201
int verbosity_level(void)
Query environment for verbosity level.
Definition: Helper.cpp:278
std::function< std::string(double)> string_format_name_to_function(const std::string &format_name)
Convert a format function to a format name to a format function.
Definition: Helper.cpp:235
unsigned int pid_to_uid(const int pid)
Query for the user id associated with the process id.
Definition: Helper.cpp:297
bool string_begins_with(const std::string &str, const std::string &key)
Returns whether one string begins with another.
Definition: Helper.cpp:163
double read_double_from_file(const std::string &path, const std::string &expected_units)
Read a file and return a double read from the file.
Definition: Helper.cpp:60