geopm  3.1.1.dev214+gba4f9f6d
GEOPM - Global Extensible Open Power Manager
Classes | Namespaces | Enumerations | Functions
Helper.hpp File Reference
#include <sched.h>
#include <stdint.h>
#include <functional>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "geopm_public.h"
Include dependency graph for Helper.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  geopm::DeprecationWarning
 

Namespaces

 geopm
 

Enumerations

enum  geopm::string_format_e { geopm::STRING_FORMAT_DOUBLE , geopm::STRING_FORMAT_INTEGER , geopm::STRING_FORMAT_HEX , geopm::STRING_FORMAT_RAW64 }
 

Functions

template<class Type , class ... Args>
std::unique_ptr< Type > geopm::make_unique (Args &&...args)
 Implementation of std::make_unique (C++14) for C++11. Note that this version will only work for non-array types. More...
 
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::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::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::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)