Main MRPT website > C++ reference for MRPT 1.5.7
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

 detail
 Auxiliary classes used internally to MRPT.
 
 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  TAuxThreadLaucher
 
struct  TCallStackBackTrace
 See: getCallStackBackTrace() More...
 
struct  TCallStackEntry
 Used in getCallStackBackTrace() More...
 
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). More...
 
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. More...
 
void BASE_IMPEXP getCallStackBackTrace (TCallStackBackTrace &out_bt)
 Returns a list of strings representing the current call stack backtrace. More...
 
mrpt::system::TTimeStamp BASE_IMPEXP buildTimestampFromParts (const mrpt::system::TTimeParts &p)
 Builds a timestamp from the parts (Parts are in UTC) More...
 
mrpt::system::TTimeStamp BASE_IMPEXP buildTimestampFromPartsLocalTime (const mrpt::system::TTimeParts &p)
 Builds a timestamp from the parts (Parts are in local time) More...
 
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. More...
 
mrpt::system::TTimeStamp BASE_IMPEXP getCurrentTime ()
 Returns the current (UTC) system time. More...
 
mrpt::system::TTimeStamp now ()
 A shortcut for system::getCurrentTime. More...
 
mrpt::system::TTimeStamp BASE_IMPEXP getCurrentLocalTime ()
 Returns the current (local) time. More...
 
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. More...
 
mrpt::system::TTimeStamp BASE_IMPEXP time_tToTimestamp (const time_t &t)
 Transform from standard "time_t" to TTimeStamp. More...
 
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). More...
 
double timestampToDouble (const mrpt::system::TTimeStamp t)
 Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of seconds). More...
 
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. More...
 
double now_double ()
 Returns the current time, as a double (fractional version of time_t) instead of a TTimeStamp. More...
 
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) More...
 
mrpt::system::TTimeStamp BASE_IMPEXP secondsToTimestamp (const double nSeconds)
 Transform a time interval (in seconds) into TTimeStamp (e.g. More...
 
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. More...
 
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. More...
 
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. More...
 
std::string BASE_IMPEXP dateToString (const mrpt::system::TTimeStamp t)
 Convert a timestamp into this textual form: YEAR/MONTH/DAY. More...
 
double BASE_IMPEXP extractDayTimeFromTimestamp (const mrpt::system::TTimeStamp t)
 Returns the number of seconds ellapsed from midnight in the given timestamp. More...
 
std::string BASE_IMPEXP timeToString (const mrpt::system::TTimeStamp t)
 Convert a timestamp into this textual form (UTC): HH:MM:SS.MMMMMM. More...
 
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. More...
 
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. More...
 
std::string BASE_IMPEXP getTempFileName ()
 Returns the name of a proposed temporary file name. More...
 
std::string BASE_IMPEXP getcwd ()
 Returns the current working directory. More...
 
std::string BASE_IMPEXP getShareMRPTDir ()
 Attempts to find the directory [PREFIX/]share/mrpt/ and returns its absolute path, or empty string if not found. More...
 
bool BASE_IMPEXP createDirectory (const std::string &dirName)
 Creates a directory. More...
 
bool BASE_IMPEXP deleteFile (const std::string &fileName)
 Deletes a single file. More...
 
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. More...
 
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. More...
 
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). More...
 
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. More...
 
std::string BASE_IMPEXP extractFileExtension (const std::string &filePath, bool ignore_gz=false)
 Extract the extension of a filename. More...
 
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. More...
 
bool BASE_IMPEXP fileExists (const std::string &fileName)
 Test if a given file (or directory) exists. More...
 
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). More...
 
std::string BASE_IMPEXP 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 BASE_IMPEXP fileNameChangeExtension (const std::string &filename, const std::string &newExtension)
 Replace the filename extension by another one. More...
 
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. More...
 
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. More...
 
std::string BASE_IMPEXP filePathSeparatorsToNative (const std::string &filePath)
 Windows: replace all '/'->'\' , in Linux/MacOS: replace all '\'->'/'. More...
 
bool BASE_IMPEXP copyFile (const std::string &sourceFile, const std::string &targetFile, std::string *outErrStr=NULL, bool copyAttribs=true)
 Copies file sourceFile to targetFile. More...
 
unsigned long BASE_IMPEXP getMemoryUsage ()
 Returns the memory occupied by this process, in bytes. More...
 
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. More...
 
void BASE_IMPEXP clearConsole ()
 Clears the console window. More...
 
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/. More...
 
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) More...
 
std::string BASE_IMPEXP find_mrpt_shared_dir ()
 Finds the "[MRPT]/share/mrpt/" directory, if available in the system. More...
 
void BASE_IMPEXP setConsoleColor (TConsoleColor color, bool changeStdErr=false)
 Changes the text color in the console for the text written from now on. More...
 
int BASE_IMPEXP executeCommand (const std::string &command, std::string *output=NULL, const std::string &mode="r")
 Execute Generic Shell Command. More...
 
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. More...
 
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. More...
 
void BASE_IMPEXP tokenize (const std::string &inString, const std::string &inDelimiters, std::vector< std::string > &outTokens, bool skipBlankTokens=true) MRPT_NO_THROWS
 
std::string BASE_IMPEXP trim (const std::string &str)
 Removes leading and trailing spaces. More...
 
std::string BASE_IMPEXP upperCase (const std::string &str)
 Returns a upper-case version of a string. More...
 
std::string BASE_IMPEXP lowerCase (const std::string &str)
 Returns an lower-case version of a string. More...
 
void BASE_IMPEXP decodeUTF8 (const std::string &strUTF8, vector_word &out_uniStr)
 Decodes a UTF-8 string into an UNICODE string. More...
 
void BASE_IMPEXP encodeUTF8 (const vector_word &input, std::string &output)
 Encodes a 2-bytes UNICODE string into a UTF-8 string. More...
 
void BASE_IMPEXP encodeBase64 (const vector_byte &inputData, std::string &outString)
 Encode a sequence of bytes as a string in base-64. More...
 
bool BASE_IMPEXP decodeBase64 (const std::string &inString, vector_byte &outData)
 Decode a base-64 string into the original sequence of bytes. More...
 
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'. More...
 
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. More...
 
bool BASE_IMPEXP strCmp (const std::string &s1, const std::string &s2)
 Return true if the two strings are equal (case sensitive) More...
 
bool BASE_IMPEXP strCmpI (const std::string &s1, const std::string &s2)
 Return true if the two strings are equal (case insensitive) More...
 
bool BASE_IMPEXP strStarts (const std::string &str, const std::string &subStr)
 Return true if "str" starts with "subStr" (case sensitive) More...
 
bool BASE_IMPEXP 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...
 
template<typename T >
TThreadHandle createThread (void(*func)(T), T param)
 Creates a new thread from a function (or static method) with one generic parameter. More...
 
template<typename T >
TThreadHandle createThreadRef (void(*func)(T &), T &param)
 
TThreadHandle createThread (void(*func)(void))
 
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. More...
 
template<typename CLASS , typename PARAM >
TThreadHandle createThreadFromObjectMethodRef (CLASS *obj, void(CLASS::*func)(PARAM &), PARAM &param)
 
template<typename CLASS >
TThreadHandle createThreadFromObjectMethod (CLASS *obj, void(CLASS::*func)(void))
 
void BASE_IMPEXP joinThread (const TThreadHandle &threadHandle)
 Waits until the given thread ends. More...
 
unsigned long BASE_IMPEXP getCurrentThreadId () MRPT_NO_THROWS
 Returns the ID of the current thread. More...
 
TThreadHandle BASE_IMPEXP getCurrentThreadHandle () MRPT_NO_THROWS
 Returns a handle to the current thread. More...
 
void BASE_IMPEXP exitThread () MRPT_NO_THROWS
 Explicit close of the current (running) thread. More...
 
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. More...
 
void BASE_IMPEXP changeThreadPriority (const TThreadHandle &threadHandle, TThreadPriority priority)
 Change the priority of the given thread - for Windows, see also changeCurrentProcessPriority() More...
 
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) More...
 
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). More...
 
unsigned int BASE_IMPEXP getNumberOfProcessors ()
 Return the number of processors ("cores"), or 1 if it cannot be determined. More...
 
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. More...
 
bool BASE_IMPEXP launchProcess (const std::string &command)
 Executes the given command (which may contain a program + arguments), and waits until it finishes. More...
 
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. More...
 
bool BASE_IMPEXP vectorToTextFile (const std::vector< double > &vec, const std::string &fileName, bool append=false, bool byRows=false)
 
bool BASE_IMPEXP vectorToTextFile (const std::vector< int > &vec, const std::string &fileName, bool append=false, bool byRows=false)
 
bool BASE_IMPEXP 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 BASE_IMPEXP vectorFromTextFile (std::vector< double > &vec, const std::string &fileName, const bool byRows=false)
 Load a std::vector from a text file (compat. More...
 
bool BASE_IMPEXP vectorToBinaryFile (const vector_byte &vec, const std::string &fileName)
 Saves a vector directly as a binary dump to a file: More...
 
bool BASE_IMPEXP loadBinaryFile (vector_byte &out_data, const std::string &fileName)
 Loads a entire file as a vector of bytes. More...
 
voidauxiliary_thread_launcher_LIN (void *param)
 
void auxiliary_thread_launcher_WIN (void *param)
 
template<typename T >
str2num (std::string const &value)
 Original code snippet found in http://stackoverflow.com/a/30357710. More...
 
template<typename T >
std::string num2str (T const &value)
 Convert number instance to string. More...
 

Typedef Documentation

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

Definition at line 80 of file parallelization.h.

Function Documentation

void* mrpt::system::auxiliary_thread_launcher_LIN ( void param)
void mrpt::system::auxiliary_thread_launcher_WIN ( void param)

Definition at line 133 of file threads.cpp.

References auxiliary_thread_launcher_LIN().

Referenced by mrpt::system::detail::createThreadImpl().

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 28 of file backtrace.cpp.

References mrpt::system::TCallStackEntry::address, mrpt::system::TCallStackBackTrace::backtrace_levels, HANDLE(), info, status, mrpt::system::TCallStackEntry::symbolName, mrpt::system::TCallStackEntry::symbolNameOriginal, and TRUE.

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.

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

Definition at line 76 of file parallelization.h.

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.8.11 for MRPT 1.5.7 Git: 2190203 Tue May 15 02:01:15 2018 +0200 at miƩ may 16 12:40:16 CEST 2018