MostlyHarmless 0.0.1
 
Loading...
Searching...
No Matches
marvin::utils Namespace Reference

Utility helper functions and classes. More...

Classes

class  RandomGenerator
 A class for (pseudo) random number generation. More...
 
struct  Range
 POD type that represents a range of values, for classes requiring a min and a max. More...
 
class  SmoothedValue
 A utility class to smooth discrete values over a given period. More...
 

Typedefs

using Random = RandomGenerator<std::mt19937>
 

Enumerations

enum class  SmoothingType { Linear , Exponential }
 Enum to configure SmoothedValue to either use linear smoothing, or exponential (lowpass) smoothing. More...
 

Functions

template<typename T>
void writeToCsv (const std::string &path, std::span< T > data)
 
std::optional< std::string > getCurrentExecutablePath ()
 
bool readBinaryFile (const std::string &path, std::vector< char > &data)
 
template<NumericType T>
bool operator== (const Range< T > &lhs, const Range< T > &rhs)
 
template<NumericType T>
bool operator!= (const Range< T > &lhs, const Range< T > &rhs)
 
template<NumericType T>
Range< T > operator+ (const Range< T > &other, T constant)
 
template<NumericType T>
Range< T > operator- (const Range< T > &other, T constant)
 
template<NumericType T>
Range< T > operator* (const Range< T > &other, T constant)
 
template<NumericType T>
Range< T > operator/ (const Range< T > &other, T constant)
 

Detailed Description

Utility helper functions and classes.

Typedef Documentation

◆ Random

using marvin::utils::Random = RandomGenerator<std::mt19937>

Enumeration Type Documentation

◆ SmoothingType

enum class marvin::utils::SmoothingType
strong

Enum to configure SmoothedValue to either use linear smoothing, or exponential (lowpass) smoothing.

Enumerator
Linear 
Exponential 

Function Documentation

◆ getCurrentExecutablePath()

std::optional< std::string > marvin::utils::getCurrentExecutablePath ( )
nodiscard

Attemps to retrieve the full path to the current executable file.

Returns
An optional containing the full path to the current executable file if no errors occured, std::nullopt otherwise.

◆ operator!=()

template<NumericType T>
bool marvin::utils::operator!= ( const Range< T > & lhs,
const Range< T > & rhs )

Inequality operator overload for Range<T>

Parameters
lhsA const lvalue ref of type Range<T>.
rhsA const rvalue ref of type Range<T>.
Returns
true if lhs.min != rhs.min or lhs.max != rhs.max, false otherwise.

◆ operator*()

template<NumericType T>
Range< T > marvin::utils::operator* ( const Range< T > & other,
T constant )

◆ operator+()

template<NumericType T>
Range< T > marvin::utils::operator+ ( const Range< T > & other,
T constant )

◆ operator-()

template<NumericType T>
Range< T > marvin::utils::operator- ( const Range< T > & other,
T constant )

◆ operator/()

template<NumericType T>
Range< T > marvin::utils::operator/ ( const Range< T > & other,
T constant )

◆ operator==()

template<NumericType T>
bool marvin::utils::operator== ( const Range< T > & lhs,
const Range< T > & rhs )

Equality operator overload for Range<T>.

Parameters
lhsa const lvalue ref of type Range<T>
rhsa const lvalue ref of type Range<T>
Returns
true if lhs.min == rhs.min, and lhs.max == rhs.max, false otherwise.

◆ readBinaryFile()

bool marvin::utils::readBinaryFile ( const std::string & path,
std::vector< char > & data )

◆ writeToCsv()

template<typename T>
void marvin::utils::writeToCsv ( const std::string & path,
std::span< T > data )

Writes the contents of an array-like to a CSV file. The resulting CSV will be single dimensional, with each element as a column.

Parameters
pathThe full path to the destination file.
dataThe data to write to the destination file.