MRPT  2.0.5
Classes | Modules | Typedefs | Enumerations | Functions
[mrpt-core]

Detailed Description

Core functions for MRPT.

Back to list of all libraries | See all modules

Library `mrpt-core`

[New in MRPT 2.0.0]

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

    sudo apt install libmrpt-core-dev

See: Using MRPT from your CMake project

Nested exceptions

See: core_exceptions_example/test.cpp

#include <iostream>
{
}
{
}
{
}
int main()
{
try
{
return 0;
}
catch (const std::exception& e)
{
std::cerr << mrpt::exception_to_str(e);
return -1;
}
}

Output:

==== MRPT exception ====
/home/jlblanco/code/mrpt/samples/core_exceptions_example/test.cpp:20: [void test_except_3rd_lvl()] Aw!
/home/jlblanco/code/mrpt/samples/core_exceptions_example/test.cpp:21: [void test_except_3rd_lvl()] Called from here.
/home/jlblanco/code/mrpt/samples/core_exceptions_example/test.cpp:28: [void test_except_2nd_lvl()] Called from here.
/home/jlblanco/code/mrpt/samples/core_exceptions_example/test.cpp:35: [void test_except_toplevel()] Called from here.
Collaboration diagram for [mrpt-core]:

Classes

class  mrpt::Clock
 Clock that is compatible with MRPT TTimeStamp representation. More...
 
class  mrpt::cpu::internal::CPU_analyzer
 Auxiliary class. More...
 
class  mrpt::LockHelper< T >
 Auxiliary helper structure for mrpt::lockHelper() More...
 
struct  mrpt::safe_ptr_basic< T >
 A wrapper class for pointers that can be safely copied with "=" operator without problems. More...
 
struct  mrpt::safe_ptr< T >
 A wrapper class for pointers that can be safely copied with "=" operator without problems. More...
 
struct  mrpt::non_copiable_ptr_basic< T >
 A wrapper class for pointers that can NOT be copied with "=" operator, raising an exception at runtime if a copy is attempted. More...
 
struct  mrpt::non_copiable_ptr< T >
 A wrapper class for pointers that can NOT be copied with "=" operator, raising an exception at runtime if a copy is attempted. More...
 
struct  mrpt::ignored_copy_ptr< T >
 A wrapper class for pointers whose copy operations from other objects of the same type are ignored, that is, doing "a=b;" has no effect neiter on "a" or "b". More...
 
struct  mrpt::copiable_NULL_ptr_basic< T >
 A wrapper class for pointers that, if copied with the "=" operator, should be set to nullptr in the copy. More...
 
struct  mrpt::copiable_NULL_ptr< T >
 A wrapper class for pointers that, if copied with the "=" operator, should be set to nullptr in the new copy. More...
 

Modules

 Funtions in #include <mrpt/core/bits_math.h>
 
 Templates to declare integers by byte count (in
 #include <mrpt/core/integer_select.h>)
 
 Round functions (in #include <mrpt/core/round.h>)
 

Typedefs

template<class T >
using mrpt::optional_ref = std::optional< std::reference_wrapper< T > >
 Shorter name for std::optional<std::reference_wrapper<T>> More...
 

Enumerations

enum  mrpt::cpu::feature : unsigned int {
  mrpt::cpu::feature::MMX = 0, mrpt::cpu::feature::POPCNT, mrpt::cpu::feature::SSE, mrpt::cpu::feature::SSE2,
  mrpt::cpu::feature::SSE3, mrpt::cpu::feature::SSSE3, mrpt::cpu::feature::SSE4_1, mrpt::cpu::feature::SSE4_2,
  mrpt::cpu::feature::AVX, mrpt::cpu::feature::AVX2, mrpt::cpu::feature::FEATURE_COUNT
}
 OS-portable set of CPU feature definitions, for usage in mrpt::cpu::supports. More...
 

Functions

template<class VECTOR_T >
void mrpt::vector_strong_clear (VECTOR_T &v)
 Like calling a std::vector<>'s clear() method, but really forcing deallocating the memory. More...
 
template<std::size_t N, typename F >
void mrpt::for_ (F func)
 constexpr for loop. More...
 
bool mrpt::cpu::supports (feature f) noexcept
 Returns true if the current CPU (and OS) supports the given CPU feature. More...
 
void mrpt::cpu::overrideDetectedFeature (feature f, bool newValue) noexcept
 Blindly enables/disables a CPU feature flag in the list of detected features to be reported in subsequent calls to mrpt::cpu::supports(). More...
 
std::string mrpt::cpu::features_as_string () noexcept
 Returns a string with detected features: "MMX:1 SSE2:0 etc.". More...
 
std::string mrpt::demangle (const std::string &symbolName)
 Demangle a C++ symbol name (works on both Windows and Unices) More...
 
std::string mrpt::exception_to_str (const std::exception &e)
 Builds a nice textual representation of a nested exception, which if generated using MRPT macros (THROW_EXCEPTION,...) in between MRPT_START/MRPT_END macros, will contain function names and line numbers across the call stack at the original throw point. More...
 
std::string mrpt::format_impl (const char *fmt,...) MRPT_printf_format_check(1
 A std::string version of C sprintf. More...
 
template<typename T >
std::string mrpt::to_string (T v)
 Just like std::to_string(), but with an overloaded version for std::string arguments. More...
 
template<typename T >
mrpt::from_string (const std::string &s, const T &defValue=T{}, bool throw_on_error=true)
 Converts from string to any data type that supports reading (>>) from a text stream. More...
 
template<class T >
mrpt::get_env (const std::string &varname, const T &defValue=T())
 Reads an environment variable, with a default value if not present. More...
 
template<class T >
LockHelper< T > mrpt::lockHelper (T &t)
 Syntactic sugar to easily create a locker to any kind of std::mutex. More...
 
void mrpt::reverseBytesInPlace (bool &v_in_out)
 Reverse the order of the bytes of a given type (useful for transforming btw little/big endian) More...
 
void mrpt::reverseBytesInPlace (uint8_t &v_in_out)
 
void mrpt::reverseBytesInPlace (int8_t &v_in_out)
 
void mrpt::reverseBytesInPlace (uint16_t &v_in_out)
 
void mrpt::reverseBytesInPlace (int16_t &v_in_out)
 
void mrpt::reverseBytesInPlace (uint32_t &v_in_out)
 
void mrpt::reverseBytesInPlace (int32_t &v_in_out)
 
void mrpt::reverseBytesInPlace (uint64_t &v_in_out)
 
void mrpt::reverseBytesInPlace (int64_t &v_in_out)
 
void mrpt::reverseBytesInPlace (float &v_in_out)
 
void mrpt::reverseBytesInPlace (double &v_in_out)
 
void mrpt::reverseBytesInPlace (long double &v_in_out)
 
void mrpt::reverseBytesInPlace (std::chrono::time_point< mrpt::Clock > &v_in_out)
 
template<class T >
void mrpt::reverseBytes (const T &v_in, T &v_out)
 Reverse the order of the bytes of a given type (useful for transforming btw little/big endian) More...
 
template<class T >
mrpt::reverseBytes (const T &v_in)
 
template<class T >
mrpt::toNativeEndianness (const T &v_in)
 
template<typename enum_t , typename underlying_t = typename std::underlying_type<enum_t>::type>
void mrpt::reverseBytesInPlace_enum (enum_t &v)
 

Typedef Documentation

◆ optional_ref

template<class T >
using mrpt::optional_ref = typedef std::optional<std::reference_wrapper<T> >

Shorter name for std::optional<std::reference_wrapper<T>>

Definition at line 20 of file optional_ref.h.

Enumeration Type Documentation

◆ feature

enum mrpt::cpu::feature : unsigned int
strong

OS-portable set of CPU feature definitions, for usage in mrpt::cpu::supports.

Enumerator
MMX 
POPCNT 
SSE 
SSE2 
SSE3 
SSSE3 
SSE4_1 
SSE4_2 
AVX 
AVX2 
FEATURE_COUNT 

Definition at line 21 of file cpu.h.

Function Documentation

◆ demangle()

std::string mrpt::demangle ( const std::string &  symbolName)

Demangle a C++ symbol name (works on both Windows and Unices)

Examples:
containers_parameters_example/test.cpp.

Definition at line 30 of file demangle.cpp.

Referenced by mrpt::containers::Parameters::asRef(), mrpt::system::getCallStackBackTrace(), and mrpt::containers::internal::implAsGetter().

Here is the caller graph for this function:

◆ exception_to_str()

std::string mrpt::exception_to_str ( const std::exception &  e)

Builds a nice textual representation of a nested exception, which if generated using MRPT macros (THROW_EXCEPTION,...) in between MRPT_START/MRPT_END macros, will contain function names and line numbers across the call stack at the original throw point.

See example of use in [mrpt-core] Uses C++11 throw_with_nested(), rethrow_if_nested().

Examples:
comms_http_client/test.cpp, containers_parameters_example/test.cpp, core_exceptions_example/test.cpp, rtti_example1/test.cpp, serialization_json_example/test.cpp, and serialization_stl/test.cpp.

Definition at line 59 of file exceptions.cpp.

References mrpt::internal::impl_excep_to_str().

Referenced by catch(), mrpt::gui::CDisplayWindowGUI::drawContents(), mrpt::gui::MRPT2NanoguiGLCanvas::drawGL(), generic_icp_slam_test(), generic_kf_slam_test(), generic_pf_test(), generic_rbpf_slam_test(), mrpt::obs::CRawlog::getActionObservationPair(), mrpt::obs::CRawlog::getActionObservationPairOrObservation(), mrpt::obs::CRawlog::loadFromRawLogFile(), mrpt::obs::CRawlog::readActionObservationPair(), mrpt::gui::CGlCanvasBase::renderCanvas(), mrpt::obs::CRawlog::saveToRawLogFile(), mrpt::apps::RawlogGrabberApp::SensorThread(), mrpt::apps::ICP_SLAM_App_Live::SensorThread(), TEST(), mrpt::comms::CClientTCPSocket::~CClientTCPSocket(), mrpt::config::CConfigFile::~CConfigFile(), mrpt::hwdrivers::CHokuyoURG::~CHokuyoURG(), mrpt::system::CObservable::~CObservable(), mrpt::opengl::CRenderizableShaderTexturedTriangles::~CRenderizableShaderTexturedTriangles(), mrpt::comms::CSerialPort::~CSerialPort(), mrpt::system::CTimeLoggerEntry::~CTimeLoggerEntry(), mrpt::system::CTimeLoggerSaveAtDtor::~CTimeLoggerSaveAtDtor(), and ModulesRegistry::~ModulesRegistry().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ features_as_string()

std::string mrpt::cpu::features_as_string ( )
noexcept

Returns a string with detected features: "MMX:1 SSE2:0 etc.".

Definition at line 95 of file cpu.cpp.

References mrpt::cpu::AVX, mrpt::cpu::AVX2, mrpt::format(), mrpt::cpu::internal::CPU_analyzer::Instance(), mrpt::cpu::MMX, mrpt::cpu::POPCNT, mrpt::cpu::SSE, mrpt::cpu::SSE2, mrpt::cpu::SSE3, mrpt::cpu::SSE4_1, mrpt::cpu::SSE4_2, and mrpt::cpu::SSSE3.

Referenced by TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ for_()

template<std::size_t N, typename F >
void mrpt::for_ ( func)

constexpr for loop.

Example:

mrpt::for_<10>( [&](auto i) { std::cout << i.value << " "; } );
Note
(New in MRPT 2.0.5)
Credits to SO.

Definition at line 39 of file constexpr_for.h.

References mrpt::internal::for_().

Here is the call graph for this function:

◆ format_impl()

std::string mrpt::format_impl ( const char *  fmt,
  ... 
)

A std::string version of C sprintf.

You can call this to obtain a std::string using printf-like syntax.

Definition at line 16 of file format.cpp.

References mrpt::system::os::vsnprintf().

Referenced by mrpt::format().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ from_string()

template<typename T >
T mrpt::from_string ( const std::string &  s,
const T &  defValue = T{},
bool  throw_on_error = true 
)
inline

Converts from string to any data type that supports reading (>>) from a text stream.

In case of error, the given default value is returned, or an exception raised.

Definition at line 32 of file from_string.h.

◆ get_env()

template<class T >
T mrpt::get_env ( const std::string &  varname,
const T &  defValue = T() 
)
inline

Reads an environment variable, with a default value if not present.

Definition at line 21 of file get_env.h.

◆ lockHelper()

template<class T >
LockHelper<T> mrpt::lockHelper ( T &  t)

◆ overrideDetectedFeature()

void mrpt::cpu::overrideDetectedFeature ( feature  f,
bool  newValue 
)
inlinenoexcept

Blindly enables/disables a CPU feature flag in the list of detected features to be reported in subsequent calls to mrpt::cpu::supports().

Could be used to disable a given CPU feature for benchmarking dynamically-dispatched functions.

Note
Enabling a feature that is not actually supported by the current CPU would probably lead to program crashes.

Definition at line 91 of file cpu.h.

References mrpt::cpu::internal::CPU_analyzer::Instance().

Here is the call graph for this function:

◆ reverseBytes() [1/2]

template<class T >
void mrpt::reverseBytes ( const T &  v_in,
T &  v_out 
)
inline

Reverse the order of the bytes of a given type (useful for transforming btw little/big endian)

Definition at line 39 of file reverse_bytes.h.

References mrpt::reverseBytesInPlace().

Referenced by get_binary_item(), and TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reverseBytes() [2/2]

template<class T >
T mrpt::reverseBytes ( const T &  v_in)
inline

Definition at line 46 of file reverse_bytes.h.

References mrpt::reverseBytesInPlace().

Here is the call graph for this function:

◆ reverseBytesInPlace() [1/13]

void mrpt::reverseBytesInPlace ( bool &  v_in_out)

Reverse the order of the bytes of a given type (useful for transforming btw little/big endian)

Definition at line 93 of file reverse_bytes.cpp.

Referenced by mrpt::obs::gnss::nv_oem6_header_t::fixEndianness(), mrpt::obs::gnss::nv_oem6_short_header_t::fixEndianness(), mrpt::obs::gnss::fixEndianness(), mrpt::obs::gnss::Message_NV_OEM6_VERSION::fixEndianness(), mrpt::serialization::CArchive::ReadBufferFixEndianness(), mrpt::reverseBytes(), mrpt::reverseBytesInPlace_enum(), mrpt::img::CCanvas::selectTextFont(), TEST(), and mrpt::toNativeEndianness().

Here is the caller graph for this function:

◆ reverseBytesInPlace() [2/13]

void mrpt::reverseBytesInPlace ( uint8_t &  v_in_out)

Definition at line 98 of file reverse_bytes.cpp.

◆ reverseBytesInPlace() [3/13]

void mrpt::reverseBytesInPlace ( int8_t &  v_in_out)

Definition at line 102 of file reverse_bytes.cpp.

◆ reverseBytesInPlace() [4/13]

void mrpt::reverseBytesInPlace ( uint16_t &  v_in_out)

Definition at line 107 of file reverse_bytes.cpp.

References reverseBytesInPlace_2b().

Here is the call graph for this function:

◆ reverseBytesInPlace() [5/13]

void mrpt::reverseBytesInPlace ( int16_t &  v_in_out)

Definition at line 112 of file reverse_bytes.cpp.

References reverseBytesInPlace_2b().

Here is the call graph for this function:

◆ reverseBytesInPlace() [6/13]

void mrpt::reverseBytesInPlace ( uint32_t &  v_in_out)

Definition at line 117 of file reverse_bytes.cpp.

References reverseBytesInPlace_4b().

Here is the call graph for this function:

◆ reverseBytesInPlace() [7/13]

void mrpt::reverseBytesInPlace ( int32_t &  v_in_out)

Definition at line 122 of file reverse_bytes.cpp.

References reverseBytesInPlace_4b().

Here is the call graph for this function:

◆ reverseBytesInPlace() [8/13]

void mrpt::reverseBytesInPlace ( uint64_t &  v_in_out)

Definition at line 127 of file reverse_bytes.cpp.

References reverseBytesInPlace_8b().

Here is the call graph for this function:

◆ reverseBytesInPlace() [9/13]

void mrpt::reverseBytesInPlace ( int64_t &  v_in_out)

Definition at line 132 of file reverse_bytes.cpp.

References reverseBytesInPlace_8b().

Here is the call graph for this function:

◆ reverseBytesInPlace() [10/13]

void mrpt::reverseBytesInPlace ( float &  v_in_out)

Definition at line 137 of file reverse_bytes.cpp.

References reverseBytesInPlace_4b().

Here is the call graph for this function:

◆ reverseBytesInPlace() [11/13]

void mrpt::reverseBytesInPlace ( double &  v_in_out)

Definition at line 142 of file reverse_bytes.cpp.

References reverseBytesInPlace_8b().

Here is the call graph for this function:

◆ reverseBytesInPlace() [12/13]

void mrpt::reverseBytesInPlace ( long double &  v_in_out)

◆ reverseBytesInPlace() [13/13]

void mrpt::reverseBytesInPlace ( std::chrono::time_point< mrpt::Clock > &  v_in_out)

Definition at line 147 of file reverse_bytes.cpp.

References reverseBytesInPlace_8b(), and val.

Here is the call graph for this function:

◆ reverseBytesInPlace_enum()

template<typename enum_t , typename underlying_t = typename std::underlying_type<enum_t>::type>
void mrpt::reverseBytesInPlace_enum ( enum_t &  v)
inline

Definition at line 68 of file reverse_bytes.h.

References mrpt::reverseBytesInPlace().

Referenced by mrpt::obs::gnss::fixEndianness().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ supports()

bool mrpt::cpu::supports ( feature  f)
inlinenoexcept

Returns true if the current CPU (and OS) supports the given CPU feature.

Definition at line 75 of file cpu.h.

References mrpt::cpu::internal::CPU_analyzer::Instance().

Referenced by my_img_to_grayscale(), mrpt::obs::detail::range2XYZ_LUT(), mrpt::round(), mrpt::round_long(), mrpt::img::CImage::scaleHalf(), mrpt::tfest::se2_l2(), and TEST().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_string()

template<typename T >
std::string mrpt::to_string ( v)

Just like std::to_string(), but with an overloaded version for std::string arguments.

Definition at line 36 of file format.h.

References mrpt::to_string().

Referenced by mrpt::internal::asrt_fail(), mrpt::hwdrivers::CIMUIntersense::doProcess(), mrpt::hwdrivers::CSkeletonTracker::doProcess(), mrpt::internal::exception_line_msg(), mrpt::vision::CFeatureLines::extractLines(), mrpt::internal::impl_excep_to_str(), mrpt::comms::net::Ping(), mrpt::graphs::CDirectedGraph< CPOSE, EDGE_ANNOTATIONS >::saveAsDot(), mrpt::system::CTimeLogger::saveToCSVFile(), mrpt::system::CTimeLogger::saveToMFile(), mrpt::io::CPipeBaseEndPoint::serialize(), TEST(), mrpt::typemeta::TEnumType< ENUMTYPE >::value2name(), and mrpt::config::CConfigFileBase::write().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toNativeEndianness()

template<class T >
T mrpt::toNativeEndianness ( const T &  v_in)
inline

Definition at line 54 of file reverse_bytes.h.

References mrpt::reverseBytesInPlace().

Referenced by mrpt::obs::CObservationVelodyneScan::laser_return_t::distance(), mrpt::obs::CObservationVelodyneScan::TVelodyneRawPacket::gps_timestamp(), mrpt::obs::CObservationVelodyneScan::TVelodynePositionPacket::gps_timestamp(), mrpt::obs::CObservationVelodyneScan::raw_block_t::header(), mrpt::obs::CObservationVelodyneScan::raw_block_t::rotation(), and mrpt::obs::CObservationVelodyneScan::TVelodynePositionPacket::unused2().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vector_strong_clear()

template<class VECTOR_T >
void mrpt::vector_strong_clear ( VECTOR_T &  v)
inline

Like calling a std::vector<>'s clear() method, but really forcing deallocating the memory.

Definition at line 18 of file bits_mem.h.

Referenced by mrpt::maps::CSimplePointsMap::internal_clear(), mrpt::maps::CWeightedPointsMap::internal_clear(), mrpt::maps::CPointsMapXYZI::internal_clear(), mrpt::maps::CColouredPointsMap::internal_clear(), mrpt::obs::CObservation3DRangeScan::points3D_convertToExternalStorage(), mrpt::obs::CObservation3DRangeScan::resizePoints3DVectors(), and mrpt::obs::CObservation3DRangeScan::unload().

Here is the caller graph for this function:



Page generated by Doxygen 1.8.14 for MRPT 2.0.5 Git: fc2d69e97 Fri Jul 10 18:20:57 2020 +0200 at vie jul 10 18:30:13 CEST 2020