iceoryx2
C++ Language Bindings
Loading...
Searching...
No Matches
posix_call.hpp File Reference
#include "iox2/legacy/detail/platform_correction.hpp"
#include "iox2/bb/detail/attributes.hpp"
#include "iox2/legacy/expected.hpp"
#include <cstdint>
#include "iox2/legacy/detail/posix_call.inl"

Go to the source code of this file.

Classes

struct  iox2::legacy::PosixCallResult< T >
 result of a posix call More...
 
struct  iox2::legacy::detail::PosixCallDetails< ReturnType >
 
class  iox2::legacy::PosixCallEvaluator< ReturnType >
 class which is created by the verificator to evaluate the result of a posix call More...
 
class  iox2::legacy::PosixCallVerificator< ReturnType >
 class which verifies the return value of a posix function call More...
 
class  iox2::legacy::PosixCallBuilder< ReturnType, FunctionArguments >
 

Namespaces

namespace  iox2
 
namespace  iox2::legacy
 
namespace  iox2::legacy::detail
 

Macros

#define IOX2_POSIX_CALL(f)
 Calling a posix function with automated error handling. If the posix function returns void you do not need to use 'IOX2_POSIX_CALL' since it cannot fail, (see: man errno). We use a builder pattern to create a design which sets the usage contract so that it cannot be used in the wrong way.
 

Functions

template<typename ReturnType , typename... FunctionArguments>
PosixCallBuilder< ReturnType, FunctionArguments... > iox2::legacy::detail::createPosixCallBuilder (ReturnType(*IOX2_POSIX_CALL)(FunctionArguments...), const char *posixFunctionName, const char *file, const int32_t line, const char *callingFunction) noexcept
 

Variables

static constexpr uint32_t iox2::legacy::POSIX_CALL_ERROR_STRING_SIZE = 128U
 
static constexpr uint64_t iox2::legacy::POSIX_CALL_EINTR_REPETITIONS = 5U
 
static constexpr int32_t iox2::legacy::POSIX_CALL_INVALID_ERRNO = -1
 

Macro Definition Documentation

◆ IOX2_POSIX_CALL

#define IOX2_POSIX_CALL (   f)
Value:
&(f), \
(#f), \
__FILE__, \
__LINE__, \
__PRETTY_FUNCTION__)
PosixCallBuilder< ReturnType, FunctionArguments... > createPosixCallBuilder(ReturnType(*IOX2_POSIX_CALL)(FunctionArguments...), const char *posixFunctionName, const char *file, const int32_t line, const char *callingFunction) noexcept

Calling a posix function with automated error handling. If the posix function returns void you do not need to use 'IOX2_POSIX_CALL' since it cannot fail, (see: man errno). We use a builder pattern to create a design which sets the usage contract so that it cannot be used in the wrong way.

IOX2_POSIX_CALL(sem_timedwait)(handle, timeout)
.successReturnValue(0)
.ignoreErrnos(ETIMEDOUT) // can be a comma separated list of errnos
.evaluate()
.and_then([](auto & result){
IOX2_LOG(Info, result.value); // return value of sem_timedwait
IOX2_LOG(Info, result.errno); // errno which was set by sem_timedwait
})
.or_else([](auto & result){
IOX2_LOG(Info, result.value); // return value of sem_timedwait
IOX2_LOG(Info, result.errno); // errno which was set by sem_timedwait
})
// when your posix call signals failure with one specific return value use
// .failureReturnValue(_) instead of .successReturnValue(_)
// when your posix call signals failure by returning the errno value instead of setting the errno use
// .returnValueMatchesErrno() instead of .successReturnValue(_)
#define IOX2_LOG(level, msg_stream)
Macro for logging.
Definition logging.hpp:63
#define IOX2_POSIX_CALL(f)
Calling a posix function with automated error handling. If the posix function returns void you do not...

Definition at line 198 of file posix_call.hpp.