peary::utils
peary::utils
Namespaces
| Name |
|---|
| peary::utils::dispatcher_impl |
Classes
| Name | |
|---|---|
| class | peary::utils::pixel Basic pixel class. |
| struct | peary::utils::pearyRawDataWord Represents a raw data word. |
| class | peary::utils::register_t Class to represent a register configuration. |
| struct | peary::utils::SI5345_REG_T Struct to represent a register in the SI5345. |
| class | peary::utils::memory_map Class to represent a memory map. |
| class | peary::utils::dictionary Dictionary class for storing elements for lookup. |
| class | peary::utils::Dispatcher Command dispatcher class. |
| struct | peary::utils::enum_hash |
| class | peary::utils::Exception Base exception class for Peary. |
| class | peary::utils::LogicError Exception class for logic errors. |
| class | peary::utils::RuntimeError Exception class for runtime errors. |
| class | peary::utils::InvalidCommandError Exception class for invalid commands. |
| class | peary::utils::DictionaryError Exception class for dictionary errors. |
| class | peary::utils::InvalidArgumentError Exception class for invalid arguments. |
| class | peary::utils::MissingImplementationError |
| class | peary::utils::LFSR Linear Feedback Shift Register (LFSR) class. |
| struct | peary::utils::string_hash Hash for std::unordered_map. |
Types
| Name | |
|---|---|
| enum class | Polarity { LOW = 0, HIGH = 1}Enum class to represent the polarity of a signal. |
| enum class | Direction { OUT = 0, IN = 1}Enum class to represent the direction of a signal. |
| using std::map< std::pair< uint16_t, uint16_t >, std::shared_ptr< pixel > > | pearydata Map of pixel data. |
| using std::vector< pearydata > | pearydataVector Vector of pearydata. |
| using std::vector< pearyRawDataWord > | pearyRawData Represents a vector of raw data words. |
| using std::vector< pearyRawData > | pearyRawDataVector Represents a vector of raw data. |
| template <typename E ,typename V > using std::unordered_map< E, V, enum_hash< E > > | enum_hash_map |
| template <typename E > using std::unordered_set< E, enum_hash< E > > | enum_hash_set |
| template <typename V > using std::unordered_map< std::string, V, string_hash, std::equal_to<> > | string_hash_map Unordered string map using hashes for fast lookup. |
| using std::unordered_set< std::string, string_hash, std::equal_to<> > | string_hash_set Unordered string set using hashes for fast lookup. |
Functions
| Name | |
|---|---|
| template <typename T1 ,typename T2 > std::ostream & | operator«(std::ostream & os, const register_t< T1, T2 > & rg)Overloaded output operator for register_t. |
| std::string | demangle(const std::type_info & type, bool keep_namespace =true)Demangle type to human-readable form. |
| bool | check_flock(const std::string & semaphore)Function to check for lock on semaphore. |
| bool | acquire_flock(const std::string & semaphore)Function to acquire lock on semaphore. |
| void | release_flock(const std::string & semaphore)Function to release semaphore lock. |
| void | make_directories(const std::string & path)Create directories recursively. |
| void | mDelay(uint32_t ms)Delay for a specified number of milliseconds. |
| std::string | trim(const std::string & s)Trims the leading and trailing white space from a string. |
| uint8_t | reverseByte(uint8_t byte)Efficiently reverse the bit order of 8-bit word. |
| template <typename T > T | from_string(const std::string & x)Converts a string to any type. |
| std::string | from_string(const std::string & x)Converts a string to a std::string (identity function with check). |
| template <typename T > std::string | to_string(const T & x, int digits =0)Converts a value of type T to a string. |
| template <typename T > std::string | to_string(const std::vector< T > & x, const std::string & sep, int digits =0)Converts a vector of values of type T to a string, with elements separated by a specified separator. |
| template <typename T > std::string | to_string(const std::vector< T > & x, int digits =0)Converts a vector of values of type T to a string, with elements separated by commas. |
| std::string | to_string(const std::string & x, int =0)Converts a std::string to a std::string (identity function). |
| std::string | to_string(const char * x, int =0)Converts a C-style string to a std::string (identity function). |
| template <typename T > std::vector< T > & | split(const std::string & s, std::vector< T > & elems, char delim)Splits a string into a vector of elements based on a delimiter. |
| template <typename T > std::string | to_bit_string(const T data, int length =-1, bool baseprefix =false)Converts a value of type T to a binary string representation. |
| template <typename T > std::string | to_hex_string(const T i, int length =-1, bool baseprefix =true)Converts a value of type T to a hexadecimal string representation. |
| template <typename T > std::string | listVector(std::vector< T > vec, const std::string & separator =", “, bool hex =false)Converts a vector of type T to a string, with elements separated by a specified separator. |
| template <typename T1 ,typename T2 > std::string | listVector(std::vector< std::pair< T1, T2 » vec, const std::string & separator =”, “, bool hex =false)Converts a vector of pairs of type T1 and T2 to a string, with elements separated by a specified separator. |
| template <typename T1 > std::string | listVector(std::vector< std::pair< std::string, T1 » vec, const std::string & separator =”, “, bool hex =false)Converts a vector of pairs of type string and T1 to a string, with elements separated by a specified separator. |
Types Documentation
enum Polarity
| Enumerator | Value | Description |
|---|---|---|
| LOW | 0 | |
| HIGH | 1 |
Enum class to represent the polarity of a signal.
enum Direction
| Enumerator | Value | Description |
|---|---|---|
| OUT | 0 | |
| IN | 1 |
Enum class to represent the direction of a signal.
using pearydata
using peary::utils::pearydata = typedef std::map<std::pair<uint16_t, uint16_t>, std::shared_ptr<pixel> >;
Map of pixel data.
This typedef defines a map where the key is a pair of row and column indices and the value is a unique pointer to a pixel object.
using pearydataVector
using peary::utils::pearydataVector = typedef std::vector<pearydata>;
Vector of pearydata.
This typedef defines a vector that contains multiple pearydata maps.
using pearyRawData
using peary::utils::pearyRawData = typedef std::vector<pearyRawDataWord>;
Represents a vector of raw data words.
This typedef defines a vector that contains multiple raw data words.
using pearyRawDataVector
using peary::utils::pearyRawDataVector = typedef std::vector<pearyRawData>;
Represents a vector of raw data.
This typedef defines a vector that contains multiple pearyRawData vectors,
using enum_hash_map
template <typename E ,
typename V >
using peary::utils::enum_hash_map = typedef std::unordered_map<E, V, enum_hash<E> >;
Unordered enum map using hashes for fast lookup
using enum_hash_set
template <typename E >
using peary::utils::enum_hash_set = typedef std::unordered_set<E, enum_hash<E> >;
Unordered enum set using hashes for fast lookup
using string_hash_map
template <typename V >
using peary::utils::string_hash_map = typedef std::unordered_map<std::string, V, string_hash, std::equal_to<> >;
Unordered string map using hashes for fast lookup.
using string_hash_set
using peary::utils::string_hash_set = typedef std::unordered_set<std::string, string_hash, std::equal_to<> >;
Unordered string set using hashes for fast lookup.
Functions Documentation
function operator«
template <typename T1 ,
typename T2 >
std::ostream & operator<<(
std::ostream & os,
const register_t< T1, T2 > & rg
)
Overloaded output operator for register_t.
Parameters:
- os The output stream to print to
- rg The register_t object to print
Template Parameters:
- T1 The type of the register address
- T2 The type of the register mask
Print the register information to an output stream.
This function is used to print the register information to an output stream.
function demangle
inline std::string demangle(
const std::type_info & type,
bool keep_namespace =true
)
Demangle type to human-readable form.
Parameters:
- type Type info of type to demangle (use
typeid) - keep_namespace Switch to select if the namespace should be kpt or dropped
Return: String with demangled type or mangled name if demangling failed
Note: This is not portable and potentially ugly, use demangle<T>() instead if possible.
function check_flock
bool check_flock(
const std::string & semaphore
)
Function to check for lock on semaphore.
Parameters:
- semaphore The name of the semaphore to check
Return: True if the semaphore is locked, false otherwise
function acquire_flock
bool acquire_flock(
const std::string & semaphore
)
Function to acquire lock on semaphore.
Parameters:
- semaphore The name of the semaphore to lock
Return: True if the lock was acquired successfully, false otherwise
function release_flock
void release_flock(
const std::string & semaphore
)
Function to release semaphore lock.
Parameters:
- semaphore The name of the semaphore to unlock
function make_directories
void make_directories(
const std::string & path
)
Create directories recursively.
Parameters:
- path The path to the directory to be created
function mDelay
inline void mDelay(
uint32_t ms
)
Delay for a specified number of milliseconds.
Parameters:
- ms The number of milliseconds to wait
Uses usleep() to wait for the specified time in milliseconds.
function trim
std::string trim(
const std::string & s
)
Trims the leading and trailing white space from a string.
Parameters:
- s The string to be trimmed
Return: A new string with leading and trailing white space removed
function reverseByte
uint8_t reverseByte(
uint8_t byte
)
Efficiently reverse the bit order of 8-bit word.
Parameters:
- byte The byte to be reversed
Return: The byte with its bits reversed
function from_string
template <typename T >
inline T from_string(
const std::string & x
)
Converts a string to any type.
Parameters:
- x The string to be converted.
Template Parameters:
- T The type to which the string should be converted.
Return: An object of type T with the value represented in x.
function from_string
inline std::string from_string(
const std::string & x
)
Converts a string to a std::string (identity function with check).
Converts a string to a uint8_t (identity function with check).
Converts a string to a uint32_t (identity function with check).
Converts a string to a int32_t (identity function with check).
Converts a string to a uint64_t (identity function with check).
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
function to_string
template <typename T >
inline std::string to_string(
const T & x,
int digits =0
)
Converts a value of type T to a string.
Parameters:
- x The value to be converted.
- digits The number of digits to be used for formatting (default is 0, which means no padding).
Template Parameters:
- T The type of the value to be converted.
Return: A string representation of the value x, formatted with leading zeros if digits > 0.
function to_string
template <typename T >
inline std::string to_string(
const std::vector< T > & x,
const std::string & sep,
int digits =0
)
Converts a vector of values of type T to a string, with elements separated by a specified separator.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
function to_string
template <typename T >
inline std::string to_string(
const std::vector< T > & x,
int digits =0
)
Converts a vector of values of type T to a string, with elements separated by commas.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
function to_string
inline std::string to_string(
const std::string & x,
int =0
)
Converts a std::string to a std::string (identity function).
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
function to_string
inline std::string to_string(
const char * x,
int =0
)
Converts a C-style string to a std::string (identity function).
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
function split
template <typename T >
std::vector< T > & split(
const std::string & s,
std::vector< T > & elems,
char delim
)
Splits a string into a vector of elements based on a delimiter.
Parameters:
- s The string to be split.
- elems A reference to a vector where the split parts will be stored.
- delim The delimiter character used to split the string (default is ‘,’).
Template Parameters:
- T The type of the elements in the vector.
Return: A vector of elements of type T, containing the split parts of the string.
function to_bit_string
template <typename T >
std::string to_bit_string(
const T data,
int length =-1,
bool baseprefix =false
)
Converts a value of type T to a binary string representation.
Parameters:
- data The value to be converted.
- length The length of the binary string (default is -1, which means the full length of the type).
- baseprefix If true, adds a “0b” prefix to the binary string (default is false).
Template Parameters:
- T The type of the value to be converted.
Return: A string representation of the value in binary format, with leading zeros if length > 0.
function to_hex_string
template <typename T >
std::string to_hex_string(
const T i,
int length =-1,
bool baseprefix =true
)
Converts a value of type T to a hexadecimal string representation.
Parameters:
- i The value to be converted.
- length The length of the hexadecimal string (default is -1, which means the full length of the type).
- baseprefix If true, adds a “0x” prefix to the hexadecimal string (default is true).
Template Parameters:
- T The type of the value to be converted.
Return: A string representation of the value in hexadecimal format, with leading zeros if length > 0.
function listVector
template <typename T >
std::string listVector(
std::vector< T > vec,
const std::string & separator =", ",
bool hex =false
)
Converts a vector of type T to a string, with elements separated by a specified separator.
Parameters:
- vec The vector to be converted.
- separator The separator to be used between elements (default is “, “).
- hex If true, converts the elements to hexadecimal format (default is false).
Template Parameters:
- T The type of the elements in the vector.
Return: A string representation of the vector, with elements separated by the specified separator and formatted with leading
Helper function to return a printed list of an integer vector, used to shield debug code from being executed if debug level is not sufficient
function listVector
template <typename T1 ,
typename T2 >
std::string listVector(
std::vector< std::pair< T1, T2 >> vec,
const std::string & separator =", ",
bool hex =false
)
Converts a vector of pairs of type T1 and T2 to a string, with elements separated by a specified separator.
Parameters:
- vec The vector of pairs to be converted.
- separator The separator to be used between elements (default is “, “).
- hex If true, converts the elements to hexadecimal format (default is false).
Template Parameters:
- T1 The type of the first element in the pair.
- T2 The type of the second element in the pair.
Return: A string representation of the vector of pairs, with elements separated by the specified separator and formatted
function listVector
template <typename T1 >
std::string listVector(
std::vector< std::pair< std::string, T1 >> vec,
const std::string & separator =", ",
bool hex =false
)
Converts a vector of pairs of type string and T1 to a string, with elements separated by a specified separator.
Parameters:
- vec The vector of pairs to be converted.
- separator The separator to be used between elements (default is “, “).
- hex If true, converts the second element to hexadecimal format (default is false).
Template Parameters:
- T1 The type of the second element in the pair.
Return: A string representation of the vector of pairs, with elements separated by the specified separator and
Updated on 2026-01-30 at 22:01:05 +0100