maliput_malidrive
macros.h File Reference
Include dependency graph for macros.h:
This graph shows which files directly or indirectly include this file:

Macros

#define MALIDRIVE_DEMAND(condition)   MALIPUT_DEMAND(condition)
 
#define MALIDRIVE_ABORT_MSG(msg)   MALIPUT_ABORT_MESSAGE(msg)
 
#define MALIDRIVE_IS_IN_RANGE(value, min_value, max_value)
 
#define MALIDRIVE_THROW_UNLESS(condition)   MALIPUT_THROW_UNLESS(condition)
 
#define MALIDRIVE_THROW_MESSAGE(msg)
 
#define MALIDRIVE_NO_COPY_NO_MOVE_NO_ASSIGN(Classname)   MALIPUT_NO_COPY_NO_MOVE_NO_ASSIGN(Classname)
 
#define MALIDRIVE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN(Classname)   MALIPUT_DEFAULT_COPY_AND_MOVE_AND_ASSIGN(Classname)
 
#define STR_SIMPLE(x)   #x
 
#define STR(x)   STR_SIMPLE(x)
 
#define MALIDRIVE_VALIDATE(pred, exctype, message)
 
#define MALIDRIVE_TRACE(msg)
 

Macro Definition Documentation

◆ MALIDRIVE_ABORT_MSG

#define MALIDRIVE_ABORT_MSG (   msg)    MALIPUT_ABORT_MESSAGE(msg)

◆ MALIDRIVE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN

#define MALIDRIVE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN (   Classname)    MALIPUT_DEFAULT_COPY_AND_MOVE_AND_ASSIGN(Classname)

Implements default special member functions for copy-construction, copy-assignment, move-construction, and move-assignment. Invoke this macro in the public section of the class declaration, e.g.:

class Foo {
 public:
  MALIDRIVE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN(Foo)
  // ...
};

*‍/

◆ MALIDRIVE_DEMAND

#define MALIDRIVE_DEMAND (   condition)    MALIPUT_DEMAND(condition)

Used to declare a demand. Will quit execution otherwise.

Aborts the program (via ::abort) with a message showing at least the given message (macro argument), function name, file, and line.

◆ MALIDRIVE_IS_IN_RANGE

#define MALIDRIVE_IS_IN_RANGE (   value,
  min_value,
  max_value 
)
Value:
do { \
MALIDRIVE_VALIDATE(value >= min_value, maliput::common::assertion_error, \
std::to_string(value) + " is less than " + std::to_string(min_value)); \
MALIDRIVE_VALIDATE(value <= max_value, maliput::common::assertion_error, \
std::to_string(value) + " is greater than " + std::to_string(max_value)); \
} while (0)

Throws if value is within [min_value; max_value]. It forwards the call to MALIDRIVE_VALIDATE() with a customized string stating the error.

◆ MALIDRIVE_NO_COPY_NO_MOVE_NO_ASSIGN

#define MALIDRIVE_NO_COPY_NO_MOVE_NO_ASSIGN (   Classname)    MALIPUT_NO_COPY_NO_MOVE_NO_ASSIGN(Classname)

Deletes the special member functions for copy-construction, copy-assignment, move-construction, and move-assignment. Invoke this macro in the public section of the class declaration, e.g.:

class Foo {
 public:
  MALIDRIVE_NO_COPY_NO_MOVE_NO_ASSIGN(Foo)
  // ...
};

*‍/

◆ MALIDRIVE_THROW_MESSAGE

#define MALIDRIVE_THROW_MESSAGE (   msg)
Value:
do { \
const std::string message(msg); \
MALIDRIVE_VALIDATE(false, maliput::common::assertion_error, message.c_str()); \
} while (0)

Throws with msg.

◆ MALIDRIVE_THROW_UNLESS

#define MALIDRIVE_THROW_UNLESS (   condition)    MALIPUT_THROW_UNLESS(condition)

Used to declare a conditional throw.

◆ MALIDRIVE_TRACE

#define MALIDRIVE_TRACE (   msg)
Value:
do { \
const std::string message(msg); \
maliput::log()->trace("[\"", __FILE__, "\":", __LINE__, ":", __func__, "] ", message, ""); \
} while (0)

Rely on maliput::log->trace(). Used to trace log msg and add information of file, line and function.

◆ MALIDRIVE_VALIDATE

#define MALIDRIVE_VALIDATE (   pred,
  exctype,
  message 
)
Value:
do { \
if (!(pred)) { \
std::string fullname = std::string(__FILE__); \
size_t found = fullname.find_last_of("/"); \
std::string fname = fullname; \
if (found != std::string::npos) { \
fname = fullname.substr(found + 1); \
} \
std::string errmsg(fname); \
errmsg.append(":").append(__func__).append(":").append(STR(__LINE__)); \
errmsg.append(": ").append(message); \
throw exctype(errmsg); \
} \
} while (0)

Used to validate that an argument passed into a function or method is true; if not, an exception of type exctype is thrown.

◆ STR

#define STR (   x)    STR_SIMPLE(x)

Stringify a token

◆ STR_SIMPLE

#define STR_SIMPLE (   x)    #x

Internal stringify a token

maliput::common::assertion_error
STR
#define STR(x)
Definition: macros.h:108