MRPT  1.9.9
mrpt::system Namespace Reference

Namespaces

 os
 

Classes

class  CAuxPSAPI_Loader
 This is an auxiliary class for mrpt::system::getMemoryUsage() under Windows. More...
 
class  CConsoleRedirector
 By creating an object of this class, all the output to std::cout (and std::cerr) will be redirected to a text file, and optionally also shown on the console. More...
 
class  CDirectoryExplorer
 This class allows the enumeration of the files/directories that exist into a given path. More...
 
class  CFileSystemWatcher
 This class subscribes to notifications of file system changes, thus it can be used to efficiently stay informed about changes in a directory tree. More...
 
class  CGenericMemoryPool
 A generic system for versatile memory pooling. More...
 
class  CObservable
 Inherit from this class for those objects capable of being observed by a CObserver class. More...
 
class  CObserver
 Inherit from this class to get notified about events from any CObservable object after subscribing to it. More...
 
class  COutputLogger
 Versatile class for consistent logging and management of output messages. More...
 
struct  COutputLoggerStreamWrapper
 For use in MRPT_LOG_DEBUG_STREAM(), etc. More...
 
class  CRateTimer
 A class for calling sleep() in a loop, such that the amount of sleep time will be computed to make the loop run at the desired rate (in Hz). More...
 
class  CTicTac
 A high-performance stopwatch, with typical resolution of nanoseconds. More...
 
class  CTimeLogger
 A versatile "profiler" that logs the time spent within each pair of calls to enter(X)-leave(X), among other stats. More...
 
struct  CTimeLoggerEntry
 A safe way to call enter() and leave() of a mrpt::system::CTimeLogger upon construction and destruction of this auxiliary object, making sure that leave() will be called upon exceptions, etc. More...
 
struct  CTimeLoggerSaveAtDtor
 A helper class to save CSV stats upon self destruction, for example, at the end of a program run. More...
 
class  mrptEvent
 The basic event type for the observer-observable pattern in MRPT. More...
 
class  mrptEventOnDestroy
 An event sent by any CObservable object (automatically) just before being destroyed and telling its observers to unsubscribe. More...
 
struct  TCallStackBackTrace
 See: getCallStackBackTrace() More...
 
struct  TCallStackEntry
 Used in getCallStackBackTrace() More...
 
struct  TParameters
 For usage when passing a dynamic number of (numeric) arguments to a function, by name. More...
 
struct  TTimeParts
 The parts of a date/time (it's like the standard 'tm' but with fractions of seconds). More...
 

Typedefs

using output_logger_callback_t = std::function< void(const std::string &msg, const mrpt::system::VerbosityLevel level, const std::string &loggerName, const mrpt::Clock::time_point &timestamp)>
 Callback types for use with mrpt::system::COuputLogger. More...
 
using TTimeStamp = mrpt::Clock::time_point
 A system independent time type, it holds the the number of 100-nanosecond intervals since January 1, 1601 (UTC) as a mrpt::Clock::time_point (uint64_t). More...
 
using TParametersDouble = TParameters< double >
 See the generic template mrpt::system::TParameters. More...
 
using TParametersString = TParameters< std::string >
 See the generic template mrpt::system::TParameters. More...
 

Enumerations

enum  VerbosityLevel {
  LVL_DEBUG = 0, LVL_INFO, LVL_WARN, LVL_ERROR,
  NUMBER_OF_VERBOSITY_LEVELS
}
 Enumeration of available verbosity levels. More...
 
enum  TConsoleColor { CONCOL_NORMAL = 0, CONCOL_BLUE = 1, CONCOL_GREEN = 2, CONCOL_RED = 4 }
 For use in setConsoleColor. More...
 
enum  TProcessPriority { ppIdle = 0, ppNormal, ppHigh, ppVeryHigh }
 The type for cross-platform process (application) priorities. More...
 
enum  TThreadPriority {
  tpLowests = -15, tpLower = -2, tpLow = -1, tpNormal = 0,
  tpHigh = 1, tpHigher = 2, tpHighest = 15
}
 The type for cross-platform thread priorities. More...
 

Functions

void getCallStackBackTrace (TCallStackBackTrace &out_bt)
 Returns a list of strings representing the current call stack backtrace. More...
 
uint16_t compute_CRC16 (const std::vector< uint8_t > &data, const uint16_t gen_pol=0x8005)
 Computes the CRC16 checksum of a block of data. More...
 
uint16_t compute_CRC16 (const uint8_t *data, const size_t len, const uint16_t gen_pol=0x8005)
 
uint32_t compute_CRC32 (const std::vector< uint8_t > &data, const uint32_t gen_pol=0xEDB88320L)
 Computes the CRC32 checksum of a block of data. More...
 
uint32_t compute_CRC32 (const uint8_t *data, const size_t len, const uint32_t gen_pol=0xEDB88320L)
 
mrpt::system::TTimeStamp buildTimestampFromParts (const mrpt::system::TTimeParts &p)
 Builds a timestamp from the parts (Parts are in UTC) More...
 
mrpt::system::TTimeStamp buildTimestampFromPartsLocalTime (const mrpt::system::TTimeParts &p)
 Builds a timestamp from the parts (Parts are in local time) More...
 
void timestampToParts (TTimeStamp t, TTimeParts &p, bool localTime=false)
 Gets the individual parts of a date/time (days, hours, minutes, seconds) - UTC time or local time. More...
 
mrpt::system::TTimeStamp getCurrentTime ()
 Returns the current (UTC) system time. More...
 
mrpt::system::TTimeStamp now ()
 A shortcut for system::getCurrentTime. More...
 
mrpt::system::TTimeStamp time_tToTimestamp (const double t)
 Transform from standard "time_t" (actually a double number, it can contain fractions of seconds) to TTimeStamp. More...
 
mrpt::system::TTimeStamp time_tToTimestamp (const time_t &t)
 Transform from standard "time_t" to TTimeStamp. More...
 
double timestampTotime_t (const mrpt::system::TTimeStamp t) noexcept
 Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of seconds). More...
 
double timestampToDouble (const mrpt::system::TTimeStamp t) noexcept
 Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of seconds). More...
 
double timeDifference (const mrpt::system::TTimeStamp t_first, const mrpt::system::TTimeStamp t_later)
 Returns the time difference from t1 to t2 (positive if t2 is posterior to t1), in seconds. More...
 
double now_double ()
 Returns the current time, as a double (fractional version of time_t) instead of a TTimeStamp. More...
 
mrpt::system::TTimeStamp timestampAdd (const mrpt::system::TTimeStamp tim, const double num_seconds)
 Shifts a timestamp the given amount of seconds (>0: forwards in time, <0: backwards) More...
 
std::string formatTimeInterval (const double timeSeconds)
 Returns a formated string with the given time difference (passed as the number of seconds), as a string [H]H:MM:SS.MILISECS. More...
 
std::string dateTimeToString (const mrpt::system::TTimeStamp t)
 Convert a timestamp into this textual form (UTC time): YEAR/MONTH/DAY,HH:MM:SS.MMM. More...
 
std::string dateTimeLocalToString (const mrpt::system::TTimeStamp t)
 Convert a timestamp into this textual form (in local time): YEAR/MONTH/DAY,HH:MM:SS.MMM. More...
 
std::string dateToString (const mrpt::system::TTimeStamp t)
 Convert a timestamp into this textual form: YEAR/MONTH/DAY. More...
 
double extractDayTimeFromTimestamp (const mrpt::system::TTimeStamp t)
 Returns the number of seconds ellapsed from midnight in the given timestamp. More...
 
std::string timeToString (const mrpt::system::TTimeStamp t)
 Convert a timestamp into this textual form (UTC): HH:MM:SS.MMMMMM. More...
 
std::string timeLocalToString (const mrpt::system::TTimeStamp t, unsigned int secondFractionDigits=6)
 Convert a timestamp into this textual form (in local time): HH:MM:SS.MMMMMM. More...
 
std::string intervalFormat (const double seconds)
 This function implements time interval formatting: Given a time in seconds, it will return a string describing the interval with the most appropriate unit. More...
 
std::ostream & operator<< (std::ostream &o, const TTimeStamp &t)
 Textual representation of a TTimeStamp as the plain number in time_since_epoch().count() More...
 
std::string getTempFileName ()
 Returns the name of a proposed temporary file name. More...
 
std::string getcwd ()
 Returns the current working directory. More...
 
std::string getShareMRPTDir ()
 Attempts to find the directory [PREFIX/]share/mrpt/ and returns its absolute path, or empty string if not found. More...
 
bool createDirectory (const std::string &dirName)
 Creates a directory. More...
 
bool deleteFile (const std::string &fileName)
 Deletes a single file. More...
 
void deleteFiles (const std::string &s)
 Delete one or more files, especified by the (optional) path and the file name (including '?' or '*') - Use forward slash ('/') for directories for compatibility between Windows and Linux, since they will be internally traslated into backward slashes ('\') if MRPT is compiled under Windows. More...
 
bool renameFile (const std::string &oldFileName, const std::string &newFileName, std::string *error_msg=nullptr)
 Renames a file - If the target path is different and the filesystem allows it, it will be moved to the new location. More...
 
bool deleteFilesInDirectory (const std::string &s, bool deleteDirectoryAsWell=false)
 Delete all the files in a given directory (nothing done if directory does not exists, or path is a file). More...
 
std::string extractFileName (const std::string &filePath)
 Extract just the name (without extension) of a filename from a complete path plus name plus extension. More...
 
std::string extractFileExtension (const std::string &filePath, bool ignore_gz=false)
 Extract the extension of a filename. More...
 
std::string extractFileDirectory (const std::string &filePath)
 Extract the whole path (the directory) of a filename from a complete path plus name plus extension. More...
 
bool fileExists (const std::string &fileName)
 Test if a given file (or directory) exists. More...
 
bool directoryExists (const std::string &fileName)
 Test if a given directory exists (it fails if the given path refers to an existing file). More...
 
std::string fileNameStripInvalidChars (const std::string &filename, const char replacement_to_invalid_chars='_')
 Replace invalid filename chars by underscores ('_') or any other user-given char. More...
 
std::string fileNameChangeExtension (const std::string &filename, const std::string &newExtension)
 Replace the filename extension by another one. More...
 
uint64_t getFileSize (const std::string &fileName)
 Return the size of the given file, or size_t(-1) if some error is found accessing that file. More...
 
time_t getFileModificationTime (const std::string &filename)
 Return the time of the file last modification, or "0" if the file doesn't exist. More...
 
std::string filePathSeparatorsToNative (const std::string &filePath)
 Windows: replace all '/'->'\' , in Linux/MacOS: replace all '\'->'/'. More...
 
bool copyFile (const std::string &sourceFile, const std::string &targetFile, std::string *outErrStr=nullptr, bool copyAttribs=true)
 Copies file sourceFile to targetFile. More...
 
std::string md5 (const std::string &str)
 Computes the md5 of a block of data. More...
 
std::string md5 (const std::vector< uint8_t > &str)
 Computes the md5 of a block of data. More...
 
std::string md5 (const unsigned char *data, const size_t len)
 Computes the md5 of a block of data. More...
 
unsigned long getMemoryUsage ()
 Returns the memory occupied by this process, in bytes. More...
 
template<std::size_t alignment, typename T , typename = std::enable_if_t<std::is_pointer<T>::value>>
bool is_aligned (T ptr)
 
void pause (const std::string &msg=std::string("Press any key to continue...")) noexcept
 Shows the message "Press any key to continue" (or other custom message) to the current standard output and returns when a key is pressed. More...
 
void clearConsole ()
 Clears the console window. More...
 
std::string MRPT_getCompilationDate ()
 Returns the MRPT source code timestamp, according to the Reproducible-Builds specifications: https://reproducible-builds.org/specs/source-date-epoch/. More...
 
std::string MRPT_getVersion ()
 Returns a string describing the MRPT version. More...
 
const std::stringgetMRPTLicense ()
 Returns a const ref to a text with the same text that appears at the beginning of each MRPT file (useful for displaying the License text in GUIs) More...
 
std::string find_mrpt_shared_dir ()
 Finds the "[MRPT]/share/mrpt/" directory, if available in the system. More...
 
void setConsoleColor (TConsoleColor color, bool changeStdErr=false)
 Changes the text color in the console for the text written from now on. More...
 
int executeCommand (const std::string &command, std::string *output=nullptr, const std::string &mode="r")
 Execute Generic Shell Command. More...
 
bool launchProcess (const std::string &command)
 Executes the given command (which may contain a program + arguments), and waits until it finishes. More...
 
void changeCurrentThreadPriority (TThreadPriority priority)
 Change the priority of the current thread - for Windows, see also changeCurrentProcessPriority() More...
 
void changeCurrentProcessPriority (TProcessPriority priority)
 Change the priority of the given process (it applies to all the threads, plus independent modifiers for each thread). More...
 
char * strtok (char *str, const char *strDelimit, char **context) noexcept
 An OS-independent method for tokenizing a string. More...
 
template<class OUT_CONTAINER >
void tokenize (const std::string &inString, const std::string &inDelimiters, OUT_CONTAINER &outTokens, bool skipBlankTokens=true) noexcept
 Tokenizes a string according to a set of delimiting characters. More...
 
template void tokenize< std::deque< std::string > > (const std::string &inString, const std::string &inDelimiters, std::deque< std::string > &outTokens, bool skipBlankTokens) noexcept
 
template void tokenize< std::vector< std::string > > (const std::string &inString, const std::string &inDelimiters, std::vector< std::string > &outTokens, bool skipBlankTokens) noexcept
 
std::string trim (const std::string &str)
 Removes leading and trailing spaces. More...
 
std::string upperCase (const std::string &str)
 Returns a upper-case version of a string. More...
 
std::string lowerCase (const std::string &str)
 Returns an lower-case version of a string. More...
 
void decodeUTF8 (const std::string &strUTF8, std::vector< uint16_t > &out_uniStr)
 Decodes a UTF-8 string into an UNICODE string. More...
 
void encodeUTF8 (const std::vector< uint16_t > &input, std::string &output)
 Encodes a 2-bytes UNICODE string into a UTF-8 string. More...
 
void encodeBase64 (const std::vector< uint8_t > &inputData, std::string &outString)
 Encode a sequence of bytes as a string in base-64. More...
 
bool decodeBase64 (const std::string &inString, std::vector< uint8_t > &outData)
 Decode a base-64 string into the original sequence of bytes. More...
 
std::string unitsFormat (const double val, int nDecimalDigits=2, bool middle_space=true)
 This function implements formatting with the appropriate SI metric unit prefix: 1e-12->'p', 1e-9->'n', 1e-6->'u', 1e-3->'m', 1->'', 1e3->'K', 1e6->'M', 1e9->'G', 1e12->'T'. More...
 
std::string rightPad (const std::string &str, const size_t total_len, bool truncate_if_larger=false)
 Enlarge the string with spaces up to the given length. More...
 
bool strCmp (const std::string &s1, const std::string &s2)
 Return true if the two strings are equal (case sensitive) More...
 
bool strCmpI (const std::string &s1, const std::string &s2)
 Return true if the two strings are equal (case insensitive) More...
 
bool strStarts (const std::string &str, const std::string &subStr)
 Return true if "str" starts with "subStr" (case sensitive) More...
 
bool strStartsI (const std::string &str, const std::string &subStr)
 Return true if "str" starts with "subStr" (case insensitive) More...
 
template<typename T >
std::string sprintf_container (const char *fmt, const T &V)
 Generates a string for a container in the format [A,B,C,...], and the fmt string for each vector element. More...
 
void stringListAsString (const std::vector< std::string > &lst, std::string &out, const std::string &newline="\")
 Convert a string list to one single string with new-lines. More...
 
void stringListAsString (const std::deque< std::string > &lst, std::string &out, const std::string &newline="\")
 
bool vectorToTextFile (const std::vector< float > &vec, const std::string &fileName, bool append=false, bool byRows=false)
 A useful function for debugging, which saves a std::vector into a text file (compat. More...
 
bool vectorToTextFile (const std::vector< double > &vec, const std::string &fileName, bool append=false, bool byRows=false)
 
bool vectorToTextFile (const std::vector< int > &vec, const std::string &fileName, bool append=false, bool byRows=false)
 
bool vectorToTextFile (const std::vector< size_t > &vec, const std::string &fileName, bool append=false, bool byRows=false)
 
template<class EIGEN_MATRIX >
bool vectorToTextFile (const EIGEN_MATRIX &vec, const std::string &fileName)
 
bool vectorFromTextFile (std::vector< double > &vec, const std::string &fileName, const bool byRows=false)
 Load a std::vector from a text file (compat. More...
 
Auxiliary stuff for the global profiler used in MRPT_START / MRPT_END

macros.

void global_profiler_enter (const char *func_name) noexcept
 
void global_profiler_leave (const char *func_name) noexcept
 
mrpt::system::CTimeLoggerglobal_profiler_getref () noexcept
 
template<typename T >
str2num (std::string const &value)
 Original code snippet found in http://stackoverflow.com/a/30357710. More...
 

Typedef Documentation

◆ output_logger_callback_t

using mrpt::system::output_logger_callback_t = typedef std::function<void( const std::string& msg, const mrpt::system::VerbosityLevel level, const std::string& loggerName, const mrpt::Clock::time_point& timestamp)>

Callback types for use with mrpt::system::COuputLogger.

Definition at line 40 of file system/COutputLogger.h.

◆ TParametersDouble

See the generic template mrpt::system::TParameters.

Definition at line 141 of file TParameters.h.

◆ TParametersString

See the generic template mrpt::system::TParameters.

Definition at line 143 of file TParameters.h.

Enumeration Type Documentation

◆ VerbosityLevel

Enumeration of available verbosity levels.

See also
COutputLogger
Enumerator
LVL_DEBUG 
LVL_INFO 
LVL_WARN 
LVL_ERROR 
NUMBER_OF_VERBOSITY_LEVELS 

Definition at line 27 of file system/COutputLogger.h.

Function Documentation

◆ getCallStackBackTrace()

void mrpt::system::getCallStackBackTrace ( TCallStackBackTrace out_bt)

Returns a list of strings representing the current call stack backtrace.

If possible, human-readable names are used for functions.

Definition at line 32 of file backtrace.cpp.

References mrpt::system::TCallStackEntry::address, mrpt::system::TCallStackBackTrace::backtrace_levels, status, mrpt::system::TCallStackEntry::symbolName, mrpt::system::TCallStackEntry::symbolNameOriginal, and TRUE.

◆ global_profiler_enter()

void mrpt::system::global_profiler_enter ( const char *  func_name)
noexcept

Definition at line 54 of file CTimeLogger.cpp.

References mrpt::system::CTimeLogger::enter(), and global_profiler.

Here is the call graph for this function:

◆ global_profiler_getref()

CTimeLogger & mrpt::system::global_profiler_getref ( )
noexcept

Definition at line 53 of file CTimeLogger.cpp.

References global_profiler.

◆ global_profiler_leave()

void mrpt::system::global_profiler_leave ( const char *  func_name)
noexcept

Definition at line 58 of file CTimeLogger.cpp.

References global_profiler, and mrpt::system::CTimeLogger::leave().

Here is the call graph for this function:



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 765b969e7 Sun Sep 22 19:55:28 2019 +0200 at dom sep 22 20:00:14 CEST 2019