Main MRPT website > C++ reference for MRPT 1.4.0
Namespaces | Classes | Typedefs | Enumerations | Functions
mrpt::system Namespace Reference

Detailed Description

This namespace provides a OS-independent interface to many useful functions: filenames manipulation, time and date, string parsing, file I/O, threading, memory allocation, etc.

See also
mrpt::system::os

Namespaces

namespace  detail
 Auxiliary classes used internally to MRPT.
 
namespace  os
 This namespace provides a OS-independent interface to low-level functions.
 

Classes

class  BlockedRange
 
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  Split
 
struct  TThreadHandle
 This structure contains the information needed to interface the threads API on each platform: More...
 
struct  TTimeParts
 The parts of a date/time (it's like the standard 'tm' but with fractions of seconds). More...
 

Typedefs

typedef uint64_t TTimeStamp
 A system independent time type, it holds the the number of 100-nanosecond intervals since January 1, 1601 (UTC).
 
typedef std::vector< Rect > ConcurrentRectVector
 

Enumerations

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

std::string BASE_IMPEXP MRPT_getVersion ()
 Returns a string describing the MRPT version.
 
mrpt::system::TTimeStamp BASE_IMPEXP buildTimestampFromParts (const mrpt::system::TTimeParts &p)
 Builds a timestamp from the parts (Parts are in UTC)
 
mrpt::system::TTimeStamp BASE_IMPEXP buildTimestampFromPartsLocalTime (const mrpt::system::TTimeParts &p)
 Builds a timestamp from the parts (Parts are in local time)
 
void BASE_IMPEXP 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.
 
mrpt::system::TTimeStamp BASE_IMPEXP getCurrentTime ()
 Returns the current (UTC) system time.
 
mrpt::system::TTimeStamp now ()
 A shortcut for system::getCurrentTime.
 
mrpt::system::TTimeStamp BASE_IMPEXP getCurrentLocalTime ()
 Returns the current (local) time.
 
mrpt::system::TTimeStamp BASE_IMPEXP time_tToTimestamp (const double &t)
 Transform from standard "time_t" (actually a double number, it can contain fractions of seconds) to TTimeStamp.
 
mrpt::system::TTimeStamp BASE_IMPEXP time_tToTimestamp (const time_t &t)
 Transform from standard "time_t" to TTimeStamp.
 
double BASE_IMPEXP timestampTotime_t (const mrpt::system::TTimeStamp &t)
 Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of seconds).
 
double timestampToDouble (const mrpt::system::TTimeStamp &t)
 Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of seconds).
 
double BASE_IMPEXP 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.
 
mrpt::system::TTimeStamp BASE_IMPEXP timestampAdd (const mrpt::system::TTimeStamp &tim, const double num_seconds)
 Shifts a timestamp the given amount of seconds (>0: forwards in time, <0: backwards)
 
mrpt::system::TTimeStamp BASE_IMPEXP secondsToTimestamp (const double &nSeconds)
 Transform a time interval (in seconds) into TTimeStamp (e.g.
 
std::string BASE_IMPEXP 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.
 
std::string BASE_IMPEXP dateTimeToString (const mrpt::system::TTimeStamp &t)
 Convert a timestamp into this textual form (UTC time): YEAR/MONTH/DAY,HH:MM:SS.MMM.
 
std::string BASE_IMPEXP dateTimeLocalToString (const mrpt::system::TTimeStamp &t)
 Convert a timestamp into this textual form (in local time): YEAR/MONTH/DAY,HH:MM:SS.MMM.
 
std::string BASE_IMPEXP dateToString (const mrpt::system::TTimeStamp &t)
 Convert a timestamp into this textual form: YEAR/MONTH/DAY.
 
double BASE_IMPEXP extractDayTimeFromTimestamp (const mrpt::system::TTimeStamp &t)
 Returns the number of seconds ellapsed from midnight in the given timestamp.
 
std::string BASE_IMPEXP timeToString (const mrpt::system::TTimeStamp &t)
 Convert a timestamp into this textual form (UTC): HH:MM:SS.MMMMMM.
 
std::string BASE_IMPEXP timeLocalToString (const mrpt::system::TTimeStamp &t, unsigned int secondFractionDigits=6)
 Convert a timestamp into this textual form (in local time): HH:MM:SS.MMMMMM.
 
std::string BASE_IMPEXP 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.
 
std::string BASE_IMPEXP getTempFileName ()
 Returns the name of a proposed temporary file name.
 
std::string BASE_IMPEXP getcwd ()
 Returns the current working directory.
 
bool BASE_IMPEXP createDirectory (const std::string &dirName)
 Creates a directory.
 
bool BASE_IMPEXP deleteFile (const std::string &fileName)
 Deletes a single file.
 
void BASE_IMPEXP 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.
 
bool BASE_IMPEXP renameFile (const std::string &oldFileName, const std::string &newFileName, std::string *error_msg=NULL)
 Renames a file - If the target path is different and the filesystem allows it, it will be moved to the new location.
 
bool BASE_IMPEXP 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).
 
std::string BASE_IMPEXP extractFileName (const std::string &filePath)
 Extract just the name (without extension) of a filename from a complete path plus name plus extension.
 
std::string BASE_IMPEXP extractFileExtension (const std::string &filePath, bool ignore_gz=false)
 Extract the extension of a filename.
 
std::string BASE_IMPEXP extractFileDirectory (const std::string &filePath)
 Extract the whole path (the directory) of a filename from a complete path plus name plus extension.
 
bool BASE_IMPEXP fileExists (const std::string &fileName)
 Test if a given file (or directory) exists.
 
bool BASE_IMPEXP directoryExists (const std::string &fileName)
 Test if a given directory exists (it fails if the given path refers to an existing file).
 
std::string BASE_IMPEXP fileNameStripInvalidChars (const std::string &filename)
 Replace invalid filename chars by underscores ('_').
 
std::string BASE_IMPEXP fileNameChangeExtension (const std::string &filename, const std::string &newExtension)
 Replace the filename extension by another one.
 
uint64_t BASE_IMPEXP getFileSize (const std::string &fileName)
 Return the size of the given file, or size_t(-1) if some error is found accessing that file.
 
time_t BASE_IMPEXP getFileModificationTime (const std::string &filename)
 Return the time of the file last modification, or "0" if the file doesn't exist.
 
std::string BASE_IMPEXP filePathSeparatorsToNative (const std::string &filePath)
 Windows: replace all '/'->'\' , in Linux/MacOS: replace all '\'->'/'.
 
bool BASE_IMPEXP copyFile (const std::string &sourceFile, const std::string &targetFile, std::string *outErrStr=NULL, bool copyAttribs=true)
 Copies file sourceFile to targetFile.
 
unsigned long BASE_IMPEXP getMemoryUsage ()
 Returns the memory occupied by this process, in bytes.
 
template<int bytes>
bool is_aligned (const void *ptr)
 
template<>
bool is_aligned< 8 > (const void *ptr)
 
template<>
bool is_aligned< 16 > (const void *ptr)
 
void BASE_IMPEXP pause (const std::string &msg=std::string("Press any key to continue...")) MRPT_NO_THROWS
 Shows the message "Press any key to continue" (or other custom message) to the current standard output and returns when a key is pressed.
 
void BASE_IMPEXP clearConsole ()
 Clears the console window.
 
std::string BASE_IMPEXP MRPT_getCompilationDate ()
 Returns the MRPT source code timestamp, according to the Reproducible-Builds specifications: https://reproducible-builds.org/specs/source-date-epoch/

 
const std::string BASE_IMPEXPgetMRPTLicense ()
 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)
 
void BASE_IMPEXP registerFatalExceptionHandlers ()
 Since MRPT 1.3.0 this function does nothing.
 
void BASE_IMPEXP setConsoleColor (TConsoleColor color, bool changeStdErr=false)
 Changes the text color in the console for the text written from now on.
 
template<typename Body >
static void parallel_for (const BlockedRange &range, const Body &body)
 
template<typename Iterator , typename Body >
static void parallel_do (Iterator first, Iterator last, const Body &body)
 
template<typename Body >
static void parallel_reduce (const BlockedRange &range, Body &body)
 
char BASE_IMPEXPstrtok (char *str, const char *strDelimit, char **context) MRPT_NO_THROWS
 An OS-independent method for tokenizing a string.
 
void BASE_IMPEXP tokenize (const std::string &inString, const std::string &inDelimiters, std::deque< std::string > &outTokens, bool skipBlankTokens=true) MRPT_NO_THROWS
 Tokenizes a string according to a set of delimiting characters.
 
void BASE_IMPEXP tokenize (const std::string &inString, const std::string &inDelimiters, std::vector< std::string > &outTokens, bool skipBlankTokens=true) MRPT_NO_THROWS
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::string BASE_IMPEXP trim (const std::string &str)
 Removes leading and trailing spaces.
 
std::string BASE_IMPEXP upperCase (const std::string &str)
 Returns a lower-case version of a string.
 
std::string BASE_IMPEXP lowerCase (const std::string &str)
 Returns an upper-case version of a string.
 
void BASE_IMPEXP decodeUTF8 (const std::string &strUTF8, vector_word &out_uniStr)
 Decodes a UTF-8 string into an UNICODE string.
 
void BASE_IMPEXP encodeUTF8 (const vector_word &input, std::string &output)
 Encodes a 2-bytes UNICODE string into a UTF-8 string.
 
void BASE_IMPEXP encodeBase64 (const vector_byte &inputData, std::string &outString)
 Encode a sequence of bytes as a string in base-64.
 
bool BASE_IMPEXP decodeBase64 (const std::string &inString, vector_byte &outData)
 Decode a base-64 string into the original sequence of bytes.
 
std::string BASE_IMPEXP 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'.
 
std::string BASE_IMPEXP 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.
 
bool BASE_IMPEXP strCmp (const std::string &s1, const std::string &s2)
 Return true if the two strings are equal (case sensitive)
 
bool BASE_IMPEXP strCmpI (const std::string &s1, const std::string &s2)
 Return true if the two strings are equal (case insensitive)
 
bool BASE_IMPEXP strStarts (const std::string &str, const std::string &subStr)
 Return true if "str" starts with "subStr" (case sensitive)
 
bool BASE_IMPEXP strStartsI (const std::string &str, const std::string &subStr)
 Return true if "str" starts with "subStr" (case insensitive)
 
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.
 
template<typename T >
TThreadHandle createThread (void(*func)(T), T param)
 Creates a new thread from a function (or static method) with one generic parameter.
 
template<typename T >
TThreadHandle createThreadRef (void(*func)(T &), T &param)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
TThreadHandle createThread (void(*func)(void))
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename CLASS , typename PARAM >
TThreadHandle createThreadFromObjectMethod (CLASS *obj, void(CLASS::*func)(PARAM), PARAM param)
 Creates a new thread running a non-static method (so it will have access to "this") from another method of the same class - with one generic parameter.
 
template<typename CLASS , typename PARAM >
TThreadHandle createThreadFromObjectMethodRef (CLASS *obj, void(CLASS::*func)(PARAM &), PARAM &param)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename CLASS >
TThreadHandle createThreadFromObjectMethod (CLASS *obj, void(CLASS::*func)(void))
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void BASE_IMPEXP joinThread (const TThreadHandle &threadHandle)
 Waits until the given thread ends.
 
unsigned long BASE_IMPEXP getCurrentThreadId () MRPT_NO_THROWS
 Returns the ID of the current thread.
 
TThreadHandle BASE_IMPEXP getCurrentThreadHandle () MRPT_NO_THROWS
 Returns a handle to the current thread.
 
void BASE_IMPEXP exitThread () MRPT_NO_THROWS
 Explicit close of the current (running) thread.
 
void BASE_IMPEXP getCurrentThreadTimes (time_t &creationTime, time_t &exitTime, double &cpuTime)
 Returns the creation and exit times of the current thread and its CPU time consumed.
 
void BASE_IMPEXP changeThreadPriority (const TThreadHandle &threadHandle, TThreadPriority priority)
 Change the priority of the given thread - for Windows, see also changeCurrentProcessPriority()
 
void BASE_IMPEXP terminateThread (TThreadHandle &threadHandle) MRPT_NO_THROWS
 Terminate a thread, giving it no choice to delete objects, etc (use only as a last resource)
 
void BASE_IMPEXP changeCurrentProcessPriority (TProcessPriority priority)
 Change the priority of the given process (it applies to all the threads, plus independent modifiers for each thread).
 
unsigned int BASE_IMPEXP getNumberOfProcessors ()
 Return the number of processors ("cores"), or 1 if it cannot be determined.
 
void BASE_IMPEXP sleep (int time_ms) MRPT_NO_THROWS
 An OS-independent method for sending the current thread to "sleep" for a given period of time.
 
bool BASE_IMPEXP launchProcess (const std::string &command)
 Executes the given command (which may contain a program + arguments), and waits until it finishes.
 
bool BASE_IMPEXP 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.
 
bool BASE_IMPEXP vectorToTextFile (const std::vector< double > &vec, const std::string &fileName, bool append=false, bool byRows=false)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool BASE_IMPEXP vectorToTextFile (const std::vector< int > &vec, const std::string &fileName, bool append=false, bool byRows=false)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool BASE_IMPEXP vectorToTextFile (const std::vector< size_t > &vec, const std::string &fileName, bool append=false, bool byRows=false)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<class EIGEN_MATRIX >
bool vectorToTextFile (const EIGEN_MATRIX &vec, const std::string &fileName)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
bool BASE_IMPEXP vectorFromTextFile (std::vector< double > &vec, const std::string &fileName, const bool byRows=false)
 Load a std::vector from a text file (compat.
 
bool BASE_IMPEXP vectorToBinaryFile (const vector_byte &vec, const std::string &fileName)
 Saves a vector directly as a binary dump to a file:
 
bool BASE_IMPEXP loadBinaryFile (vector_byte &out_data, const std::string &fileName)
 Loads a entire file as a vector of bytes.
 

Typedef Documentation

◆ ConcurrentRectVector

typedef std::vector<Rect> mrpt::system::ConcurrentRectVector

Definition at line 80 of file parallelization.h.

Function Documentation

◆ parallel_do()

template<typename Iterator , typename Body >
static void mrpt::system::parallel_do ( Iterator  first,
Iterator  last,
const Body &  body 
)
inlinestatic

Definition at line 83 of file parallelization.h.

◆ parallel_for()

template<typename Body >
static void mrpt::system::parallel_for ( const BlockedRange range,
const Body &  body 
)
inlinestatic

Definition at line 76 of file parallelization.h.

◆ parallel_reduce()

template<typename Body >
static void mrpt::system::parallel_reduce ( const BlockedRange range,
Body &  body 
)
inlinestatic

Definition at line 92 of file parallelization.h.




Page generated by Doxygen 1.9.6 for MRPT 1.4.0 SVN: at Tue Jan 17 22:27:43 UTC 2023