geopm  3.1.1.dev214+gba4f9f6d
GEOPM - Global Extensible Open Power Manager
Namespaces | Functions
Helper.cpp File Reference
#include "geopm/Helper.hpp"
#include <unistd.h>
#include <limits.h>
#include <dirent.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <linux/capability.h>
#include <sys/syscall.h>
#include <cmath>
#include <climits>
#include <cinttypes>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <map>
#include <string>
#include <iostream>
#include "geopm_field.h"
#include "geopm/Exception.hpp"
#include "geopm/PlatformIO.hpp"
#include "geopm/PlatformTopo.hpp"
Include dependency graph for Helper.cpp:

Namespaces

 geopm
 

Functions

std::string geopm::read_file (const std::string &path)
 Reads the specified file and returns the contents in a string. More...
 
double geopm::read_double_from_file (const std::string &path, const std::string &expected_units)
 Read a file and return a double read from the file. More...
 
void geopm::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. More...
 
std::vector< std::string > geopm::string_split (const std::string &str, const std::string &delim)
 Splits a string according to a delimiter. More...
 
std::string geopm::string_join (const std::vector< std::string > &string_list, const std::string &delim)
 Joins a vector of strings together with a delimiter. More...
 
std::string geopm::hostname (void)
 Returns the current hostname as a string. More...
 
std::vector< std::string > geopm::list_directory_files (const std::string &path)
 List all files in the given directory. More...
 
bool geopm::string_begins_with (const std::string &str, const std::string &key)
 Returns whether one string begins with another. More...
 
bool geopm::string_ends_with (std::string str, std::string key)
 Returns whether one string ends with another. More...
 
std::string geopm::string_format_double (double signal)
 Format a string to best represent a signal encoding a double precision floating point number. More...
 
std::string geopm::string_format_float (double signal)
 Format a string to best represent a signal encoding a single precision floating point number. More...
 
std::string geopm::string_format_integer (double signal)
 Format a string to best represent a signal encoding a decimal integer. More...
 
std::string geopm::string_format_hex (double signal)
 Format a string to best represent a signal encoding an unsigned hexadecimal integer. More...
 
std::string geopm::string_format_raw64 (double signal)
 Format a string to represent the raw memory supporting a signal as an unsigned hexadecimal integer. More...
 
std::function< std::string(double)> geopm::string_format_type_to_function (int format_type)
 Convert a format type enum string_format_e to a format function. More...
 
std::function< std::string(double)> geopm::string_format_name_to_function (const std::string &format_name)
 Convert a format function to a format name to a format function. More...
 
int geopm::string_format_function_to_type (std::function< std::string(double)> format_function)
 Convert a format function to a format type enum string_format_e. More...
 
std::string geopm::get_env (const std::string &name)
 Read an environment variable. More...
 
int geopm::verbosity_level (void)
 Query environment for verbosity level. More...
 
unsigned int geopm::pid_to_uid (const int pid)
 Query for the user id associated with the process id. More...
 
unsigned int geopm::pid_to_gid (const int pid)
 Query for the group id associated with the process id. More...
 
std::unique_ptr< cpu_set_t, std::function< void(cpu_set_t *)> > geopm::make_cpu_set (int num_cpu, const std::set< int > &cpu_enabled)
 Wrapper around CPU_ALLOC and CPU_FREE. More...
 
bool geopm::has_cap_sys_admin (void)
 Check if the caller has effective capability CAP_SYS_ADMIN. More...
 
bool geopm::has_cap_sys_admin (int pid)
 Check if the pid has effective capability CAP_SYS_ADMIN. More...
 
std::string geopm::read_symlink_target (const std::string &symlink_path)
 
void geopm::enable_fixed_counters (PlatformIO &pio)