[mrpt-system]

An OS abstraction layer and other miscellaneous functionality: filesystem, date and time, memory handling and much more.

Library mrpt-system

[New in MRPT 2.0.0]

This C++ library is part of MRPT and can be installed in Debian-based systems with:

sudo apt install libmrpt-system-dev

Read also how to import MRPT into your CMake scripts.

Library contents

// structs

struct mrpt::system::CTimeLoggerEntry;
struct mrpt::system::CTimeLoggerSaveAtDtor;

// classes

class mrpt::system::CConsoleRedirector;
class mrpt::system::CControlledRateTimer;
class mrpt::system::CDirectoryExplorer;
class mrpt::system::CFileSystemWatcher;
class mrpt::system::CObservable;
class mrpt::system::CObserver;
class mrpt::system::COutputLogger;
class mrpt::system::CRateTimer;
class mrpt::system::CTicTac;
class mrpt::system::CTimeLogger;
class mrpt::system::mrptEvent;
class mrpt::system::mrptEventOnDestroy;

// global functions

std::string mrpt::system::progress(
    const double progressRatio0to1,
    const std::size_t barLength,
    bool encloseInSquareBrackets = true
    );

void mrpt::system::thread_name(const std::string& name, std::thread& theThread);
void mrpt::system::thread_name(const std::string& name);
std::string mrpt::system::thread_name(std::thread& theThread);
std::string mrpt::system::thread_name();

Global Functions

std::string mrpt::system::progress(
    const double progressRatio0to1,
    const std::size_t barLength,
    bool encloseInSquareBrackets = true
    )

Build an text incremental progress bar with UNICODE block elements, for example:

50%  => "[████    ]"

See example: system_progress_bar/test.cpp

#include <mrpt/core/exceptions.h>
#include <mrpt/system/progress.h>

#include <iostream>
#include <thread>

void TestProgressBar()
{
    const int end = 400;
    const size_t barWidth = 30;

    for (int i = 0; i <= end; i++)
    {
        double p = double(i) / end;

        std::cout << "Progress: " << mrpt::system::progress(p, barWidth)
                  << mrpt::format(" %5.02f%%", 100 * p) << "\r";
        std::cout.flush();
        std::this_thread::sleep_for(std::chrono::milliseconds(5));
    }
    std::cout << std::endl;
}

(New in MRPT 2.2.1)

void mrpt::system::thread_name(const std::string& name, std::thread& theThread)

Sets the name of the given thread; useful for debuggers.

New in MRPT 2.0.4

void mrpt::system::thread_name(const std::string& name)

Sets the name of the current thread; useful for debuggers.

New in MRPT 2.0.4

std::string mrpt::system::thread_name(std::thread& theThread)

Gets the name of the given thread; useful for debuggers.

New in MRPT 2.0.4

std::string mrpt::system::thread_name()

Gets the name of the current thread; useful for debuggers.

New in MRPT 2.0.4