rmw  master
C API providing a middleware abstraction layer which is used to implement the rest of ROS.
Macros
macros.hpp File Reference
#include <iostream>
#include <sstream>
#include <string>
#include "rcutils/snprintf.h"
#include "rmw/allocators.h"
#include "rmw/error_handling.h"
#include "rmw/impl/config.h"
#include "rmw/impl/cpp/demangle.hpp"
Include dependency graph for macros.hpp:

Go to the source code of this file.

Macros

#define RMW_TRY_PLACEMENT_NEW(Destination, BufferForNew, FailureAction, Type, ...)
 
#define RMW_TRY_DESTRUCTOR(Statement, Type, FailureAction)
 
#define RMW_TRY_DESTRUCTOR_FROM_WITHIN_FAILURE(Statement, Type)
 
#define RMW_CHECK_TYPE_IDENTIFIERS_MATCH(ElementName, ElementTypeID, ExpectedTypeID, OnFailure)
 

Macro Definition Documentation

◆ RMW_TRY_PLACEMENT_NEW

#define RMW_TRY_PLACEMENT_NEW (   Destination,
  BufferForNew,
  FailureAction,
  Type,
  ... 
)
Value:
try { \
Destination = new(BufferForNew) Type(__VA_ARGS__); \
} catch (const std::exception & exception) { \
RMW_SET_ERROR_MSG( \
( \
std::string("caught C++ exception ") + rmw::impl::cpp::demangle(exception) + \
" constructing " #Type ": " + exception.what() \
).c_str()); \
FailureAction; \
} catch (...) { \
RMW_SET_ERROR_MSG("caught unknown C++ exception constructing " #Type); \
FailureAction; \
}

◆ RMW_TRY_DESTRUCTOR

#define RMW_TRY_DESTRUCTOR (   Statement,
  Type,
  FailureAction 
)
Value:
try { \
Statement; \
} catch (const std::exception & exception) { \
RMW_SET_ERROR_MSG( \
( \
std::string("caught C++ exception in destructor of " #Type ": ") + \
rmw::impl::cpp::demangle(exception) + ": " + exception.what() \
).c_str()); \
FailureAction; \
} catch (...) { \
RMW_SET_ERROR_MSG("caught unknown C++ exception in destructor of " #Type); \
FailureAction; \
}

◆ RMW_TRY_DESTRUCTOR_FROM_WITHIN_FAILURE

#define RMW_TRY_DESTRUCTOR_FROM_WITHIN_FAILURE (   Statement,
  Type 
)
Value:
try { \
Statement; \
} catch (const std::exception & exception) { \
std::stringstream ss; \
ss << "caught C++ exception in destructor of " #Type " while handling a failure: " \
<< rmw::impl::cpp::demangle(exception) << ": " << exception.what() \
<< ", at: " << __FILE__ << ":" << __LINE__ << '\n'; \
(std::cerr << ss.str()).flush(); \
} catch (...) { \
std::stringstream ss; \
ss << "caught unknown C++ exception in destructor of " #Type << \
" while handling a failure at: " << __FILE__ << ":" << __LINE__ << '\n'; \
(std::cerr << ss.str()).flush(); \
}

◆ RMW_CHECK_TYPE_IDENTIFIERS_MATCH

#define RMW_CHECK_TYPE_IDENTIFIERS_MATCH (   ElementName,
  ElementTypeID,
  ExpectedTypeID,
  OnFailure 
)
std::string
std::exception
rmw::impl::cpp::demangle
std::string demangle(const T &instance)
Return the demangle name of the instance of type T.
Definition: demangle.hpp:39
std::cerr
std::flush
T flush(T... args)
std::exception::what
T what(T... args)