Skip to content

Commit

Permalink
iox-eclipse-iceoryx#1969 Make iceoryx compile
Browse files Browse the repository at this point in the history
  • Loading branch information
elBoberido committed May 5, 2023
1 parent 35e9c79 commit 180e03a
Show file tree
Hide file tree
Showing 79 changed files with 214 additions and 202 deletions.
2 changes: 1 addition & 1 deletion iceoryx_dust/include/iceoryx_dust/design/creation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class Creation
/// @return returns an expected which either contains the object in a valid
/// constructed state or an error value stating why the construction failed.
template <typename... Targs>
static iox::expected<ErrorType> placementCreate(void* const memory, Targs&&... args) noexcept;
static iox::expected<void, ErrorType> placementCreate(void* const memory, Targs&&... args) noexcept;

Creation() noexcept = default;
Creation(Creation&& rhs) noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ Creation<DerivedClass, ErrorType>::verify(DerivedClass&& newObject) noexcept

template <typename DerivedClass, typename ErrorType>
template <typename... Targs>
inline iox::expected<ErrorType> Creation<DerivedClass, ErrorType>::placementCreate(void* const memory,
Targs&&... args) noexcept
inline iox::expected<void, ErrorType> Creation<DerivedClass, ErrorType>::placementCreate(void* const memory,
Targs&&... args) noexcept
{
auto newClass = static_cast<DerivedClass*>(memory);
new (newClass) DerivedClass(std::forward<Targs>(args)...);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class MessageQueue : public DesignPattern::Creation<MessageQueue, IpcChannelErro

/// @brief send a message to queue using std::string.
/// @return true if sent without errors, false otherwise
expected<IpcChannelError> send(const std::string& msg) const noexcept;
expected<void, IpcChannelError> send(const std::string& msg) const noexcept;

/// @todo iox-#1693 zero copy receive with receive(iox::string&); iox::string would be the buffer for mq_receive

Expand All @@ -85,7 +85,7 @@ class MessageQueue : public DesignPattern::Creation<MessageQueue, IpcChannelErro
expected<std::string, IpcChannelError> timedReceive(const units::Duration& timeout) const noexcept;

/// @brief try to send a message to the queue for a given timeout duration using std::string
expected<IpcChannelError> timedSend(const std::string& msg, const units::Duration& timeout) const noexcept;
expected<void, IpcChannelError> timedSend(const std::string& msg, const units::Duration& timeout) const noexcept;

static expected<bool, IpcChannelError> isOutdated() noexcept;

Expand All @@ -97,12 +97,12 @@ class MessageQueue : public DesignPattern::Creation<MessageQueue, IpcChannelErro

expected<mqd_t, IpcChannelError> open(const IpcChannelName_t& name, const IpcChannelSide channelSide) noexcept;

expected<IpcChannelError> close() noexcept;
expected<IpcChannelError> unlink() noexcept;
expected<void, IpcChannelError> close() noexcept;
expected<void, IpcChannelError> unlink() noexcept;
error<IpcChannelError> createErrorFromErrnum(const int32_t errnum) const noexcept;
static error<IpcChannelError> createErrorFromErrnum(const IpcChannelName_t& name, const int32_t errnum) noexcept;
static expected<IpcChannelName_t, IpcChannelError> sanitizeIpcChannelName(const IpcChannelName_t& name) noexcept;
expected<IpcChannelError> destroy() noexcept;
expected<void, IpcChannelError> destroy() noexcept;

private:
IpcChannelName_t m_name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,20 @@ class NamedPipe : public DesignPattern::Creation<NamedPipe, IpcChannelError>

/// @brief tries to send a message via the named pipe. if the pipe is full IpcChannelError::TIMEOUT is returned
/// @return on failure an error which describes the failure
expected<IpcChannelError> trySend(const std::string& message) const noexcept;
expected<void, IpcChannelError> trySend(const std::string& message) const noexcept;

/// @brief sends a message via the named pipe. if the pipe is full this call is blocking until the message could be
/// delivered
/// @param[in] message the message which should be sent, is not allowed to be longer then MAX_MESSAGE_SIZE
/// @return success when message was sent otherwise an error which describes the failure
expected<IpcChannelError> send(const std::string& message) const noexcept;
expected<void, IpcChannelError> send(const std::string& message) const noexcept;

/// @brief sends a message via the named pipe.
/// @param[in] message the message which should be sent, is not allowed to be longer then MAX_MESSAGE_SIZE
/// @param[in] timeout the timeout on how long this method should retry to send the message
/// @return success when message was sent otherwise an error which describes the failure
expected<IpcChannelError> timedSend(const std::string& message, const units::Duration& timeout) const noexcept;
expected<void, IpcChannelError> timedSend(const std::string& message,
const units::Duration& timeout) const noexcept;

/// @brief tries to receive a message via the named pipe. if the pipe is empty IpcChannelError::TIMEOUT is returned
/// @return on success a string containing the message, otherwise an error which describes the failure
Expand Down Expand Up @@ -119,7 +120,7 @@ class NamedPipe : public DesignPattern::Creation<NamedPipe, IpcChannelError>

/// @brief destroys an initialized named pipe.
/// @return is always successful
expected<IpcChannelError> destroy() noexcept;
expected<void, IpcChannelError> destroy() noexcept;

private:
optional<SharedMemoryObject> m_sharedMemory;
Expand Down
11 changes: 6 additions & 5 deletions iceoryx_dust/source/posix_wrapper/message_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ expected<bool, IpcChannelError> MessageQueue::unlinkIfExists(const IpcChannelNam
return success<bool>(mqCall->errnum != ENOENT);
}

expected<IpcChannelError> MessageQueue::destroy() noexcept
expected<void, IpcChannelError> MessageQueue::destroy() noexcept
{
if (m_mqDescriptor != INVALID_DESCRIPTOR)
{
Expand All @@ -177,7 +177,7 @@ expected<IpcChannelError> MessageQueue::destroy() noexcept
return success<void>();
}

expected<IpcChannelError> MessageQueue::send(const std::string& msg) const noexcept
expected<void, IpcChannelError> MessageQueue::send(const std::string& msg) const noexcept
{
const uint64_t messageSize = msg.size() + NULL_TERMINATOR_SIZE;
if (messageSize > static_cast<uint64_t>(m_attributes.mq_msgsize))
Expand Down Expand Up @@ -248,7 +248,7 @@ expected<mqd_t, IpcChannelError> MessageQueue::open(const IpcChannelName_t& name
return success<mqd_t>(mqCall->value);
}

expected<IpcChannelError> MessageQueue::close() noexcept
expected<void, IpcChannelError> MessageQueue::close() noexcept
{
auto mqCall = posixCall(mq_close)(m_mqDescriptor).failureReturnValue(ERROR_CODE).evaluate();

Expand All @@ -260,7 +260,7 @@ expected<IpcChannelError> MessageQueue::close() noexcept
return success<void>();
}

expected<IpcChannelError> MessageQueue::unlink() noexcept
expected<void, IpcChannelError> MessageQueue::unlink() noexcept
{
if (m_channelSide == IpcChannelSide::CLIENT)
{
Expand Down Expand Up @@ -302,7 +302,8 @@ expected<std::string, IpcChannelError> MessageQueue::timedReceive(const units::D
return success<std::string>(std::string(&(message[0])));
}

expected<IpcChannelError> MessageQueue::timedSend(const std::string& msg, const units::Duration& timeout) const noexcept
expected<void, IpcChannelError> MessageQueue::timedSend(const std::string& msg,
const units::Duration& timeout) const noexcept
{
const uint64_t messageSize = msg.size() + NULL_TERMINATOR_SIZE;
if (messageSize > static_cast<uint64_t>(m_attributes.mq_msgsize))
Expand Down
10 changes: 5 additions & 5 deletions iceoryx_dust/source/posix_wrapper/named_pipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ IpcChannelName_t NamedPipe::convertName(const Prefix& p, const IpcChannelName_t&
return channelName;
}

expected<IpcChannelError> NamedPipe::destroy() noexcept
expected<void, IpcChannelError> NamedPipe::destroy() noexcept
{
if (m_isInitialized)
{
Expand All @@ -209,7 +209,7 @@ expected<bool, IpcChannelError> NamedPipe::unlinkIfExists(const IpcChannelName_t
return success<bool>(*result);
}

expected<IpcChannelError> NamedPipe::trySend(const std::string& message) const noexcept
expected<void, IpcChannelError> NamedPipe::trySend(const std::string& message) const noexcept
{
if (!m_isInitialized)
{
Expand All @@ -233,7 +233,7 @@ expected<IpcChannelError> NamedPipe::trySend(const std::string& message) const n
return error<IpcChannelError>(IpcChannelError::TIMEOUT);
}

expected<IpcChannelError> NamedPipe::send(const std::string& message) const noexcept
expected<void, IpcChannelError> NamedPipe::send(const std::string& message) const noexcept
{
if (!m_isInitialized)
{
Expand All @@ -252,8 +252,8 @@ expected<IpcChannelError> NamedPipe::send(const std::string& message) const noex
return success<>();
}

expected<IpcChannelError> NamedPipe::timedSend(const std::string& message,
const units::Duration& timeout) const noexcept
expected<void, IpcChannelError> NamedPipe::timedSend(const std::string& message,
const units::Duration& timeout) const noexcept
{
if (!m_isInitialized)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ class mutex

/// @brief Locks the mutex.
/// @return When it fails it returns an enum describing the error.
expected<MutexLockError> lock() noexcept;
expected<void, MutexLockError> lock() noexcept;

/// @brief Unlocks the mutex.
/// @return When it fails it returns an enum describing the error.
expected<MutexUnlockError> unlock() noexcept;
expected<void, MutexUnlockError> unlock() noexcept;

/// @brief Tries to lock the mutex.
/// @return If the lock was acquired MutexTryLock::LOCK_SUCCEEDED will be returned otherwise
Expand Down Expand Up @@ -222,7 +222,7 @@ class MutexBuilder
/// @brief Initializes a provided uninitialized mutex
/// @param[in] uninitializedMutex the uninitialized mutex which should be initialized
/// @return On failure MutexError which explains the error
expected<MutexCreationError> create(optional<mutex>& uninitializedMutex) noexcept;
expected<void, MutexCreationError> create(optional<mutex>& uninitializedMutex) noexcept;
};
} // namespace posix
} // namespace iox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ class SemaphoreInterface
/// @brief Increments the semaphore by one
/// @return Fails when the value of the semaphore overflows or when the
/// semaphore was removed from outside the process
expected<SemaphoreError> post() noexcept;
expected<void, SemaphoreError> post() noexcept;

/// @brief Decrements the semaphore by one. When the semaphore value is zero
/// it blocks until the semaphore value is greater zero
/// @return Fails when semaphore was removed from outside the process
expected<SemaphoreError> wait() noexcept;
expected<void, SemaphoreError> wait() noexcept;

/// @brief Tries to decrement the semaphore by one. When the semaphore value is zero
/// it returns false otherwise it returns true and decrement the value by one.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,13 @@ class UnixDomainSocket
/// @brief send a message using std::string.
/// @param msg to send
/// @return IpcChannelError if error occured
expected<IpcChannelError> send(const std::string& msg) const noexcept;
expected<void, IpcChannelError> send(const std::string& msg) const noexcept;

/// @brief try to send a message for a given timeout duration using std::string
/// @param msg to send
/// @param timout for the send operation
/// @return IpcChannelError if error occured
expected<IpcChannelError> timedSend(const std::string& msg, const units::Duration& timeout) const noexcept;
expected<void, IpcChannelError> timedSend(const std::string& msg, const units::Duration& timeout) const noexcept;

/// @brief receive message using std::string.
/// @return received message. In case of an error, IpcChannelError is returned and msg is empty.
Expand All @@ -117,13 +117,13 @@ class UnixDomainSocket
const size_t maxMsgSize = MAX_MESSAGE_SIZE,
const uint64_t maxMsgNumber = 10U) noexcept;

expected<IpcChannelError> destroy() noexcept;
expected<void, IpcChannelError> destroy() noexcept;

expected<IpcChannelError> initalizeSocket() noexcept;
expected<void, IpcChannelError> initalizeSocket() noexcept;

IpcChannelError convertErrnoToIpcChannelError(const int32_t errnum) const noexcept;

expected<IpcChannelError> closeFileDescriptor() noexcept;
expected<void, IpcChannelError> closeFileDescriptor() noexcept;

private:
static constexpr int32_t ERROR_CODE = -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class FileLock
void invalidate() noexcept;

static FileLockError convertErrnoToFileLockError(const int32_t errnum, const FilePath_t& fileLockPath) noexcept;
expected<FileLockError> closeFileDescriptor() noexcept;
expected<void, FileLockError> closeFileDescriptor() noexcept;
};

class FileLockBuilder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class NamedSemaphoreBuilder
/// @param[in] uninitializedSemaphore since the semaphore is not movable the user has to provide
/// memory to store the semaphore into - packed in an optional
/// @return an error describing the failure or success
expected<SemaphoreError> create(optional<NamedSemaphore>& uninitializedSemaphore) const noexcept;
expected<void, SemaphoreError> create(optional<NamedSemaphore>& uninitializedSemaphore) const noexcept;
};
} // namespace posix
} // namespace iox
Expand Down
3 changes: 2 additions & 1 deletion iceoryx_hoofs/include/iceoryx_hoofs/posix_wrapper/thread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ class ThreadBuilder
/// @param[in] uninitializedThread is an iox::optional where the thread is stored
/// @param[in] callable is the callable that is invoked by the thread
/// @return an error describing the failure or success
expected<ThreadError> create(optional<Thread>& uninitializedThread, const Thread::callable_t& callable) noexcept;
expected<void, ThreadError> create(optional<Thread>& uninitializedThread,
const Thread::callable_t& callable) noexcept;
};

} // namespace posix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class UnnamedSemaphoreBuilder
/// @param[in] uninitializedSemaphore since the semaphore is not movable the user has to provide
/// memory to store the semaphore into - packed in an optional
/// @return an error describing the failure or success
expected<SemaphoreError> create(optional<UnnamedSemaphore>& uninitializedSemaphore) const noexcept;
expected<void, SemaphoreError> create(optional<UnnamedSemaphore>& uninitializedSemaphore) const noexcept;
};
} // namespace posix
} // namespace iox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ inline expected<access_rights, FileStatError> FileManagementInterface<Derived>::
}

template <typename Derived>
inline expected<FileSetOwnerError> FileManagementInterface<Derived>::set_ownership(const Ownership ownership) noexcept
inline expected<void, FileSetOwnerError>
FileManagementInterface<Derived>::set_ownership(const Ownership ownership) noexcept
{
const auto& derived_this = *static_cast<const Derived*>(this);
auto result = details::set_owner(derived_this.get_file_handle(), ownership.uid(), ownership.gid());
Expand All @@ -64,7 +65,7 @@ inline expected<FileSetOwnerError> FileManagementInterface<Derived>::set_ownersh
}

template <typename Derived>
inline expected<FileSetPermissionError>
inline expected<void, FileSetPermissionError>
FileManagementInterface<Derived>::set_permissions(const access_rights permissions) noexcept
{
const auto& derived_this = *static_cast<const Derived*>(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ enum class FileSetPermissionError
namespace details
{
expected<iox_stat, FileStatError> get_file_status(const int fildes) noexcept;
expected<FileSetOwnerError> set_owner(const int fildes, const uid_t uid, const gid_t gid) noexcept;
expected<FileSetPermissionError> set_permissions(const int fildes, const access_rights perms) noexcept;
expected<void, FileSetOwnerError> set_owner(const int fildes, const uid_t uid, const gid_t gid) noexcept;
expected<void, FileSetPermissionError> set_permissions(const int fildes, const access_rights perms) noexcept;
} // namespace details

/// @brief Represents the POSIX owners (user and group) of a file.
Expand Down Expand Up @@ -118,7 +118,7 @@ struct FileManagementInterface
/// @brief Sets the owners of the underlying file descriptor.
/// @param[in] owner the new owners of the file descriptor
/// @return On failure a 'FileSetOwnerError' describing the error.
expected<FileSetOwnerError> set_ownership(const Ownership owner) noexcept;
expected<void, FileSetOwnerError> set_ownership(const Ownership owner) noexcept;

/// @brief Returns the permissions of the underlying file descriptor.
/// @return On failure a 'FileStatError' describing the error otherwise 'access_rights'.
Expand All @@ -127,7 +127,7 @@ struct FileManagementInterface
/// @brief Sets the permissions of the underlying file descriptor.
/// @param[in] permissions the new permissions of the file descriptor
/// @return On failure a 'FileSetPermissionError' describing the error.
expected<FileSetPermissionError> set_permissions(const access_rights permissions) noexcept;
expected<void, FileSetPermissionError> set_permissions(const access_rights permissions) noexcept;

/// @brief Returns the size of the corresponding file.
/// @return On failure a 'FileStatError' describing the error otherwise the size.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ expected<iox_stat, FileStatError> get_file_status(const int fildes) noexcept
return iox::success<iox_stat>(file_status);
}

expected<FileSetOwnerError> set_owner(const int fildes, const uid_t uid, const gid_t gid) noexcept
expected<void, FileSetOwnerError> set_owner(const int fildes, const uid_t uid, const gid_t gid) noexcept
{
auto result = posix::posixCall(iox_fchown)(fildes, uid, gid).failureReturnValue(-1).evaluate();

Expand Down Expand Up @@ -80,7 +80,7 @@ expected<FileSetOwnerError> set_owner(const int fildes, const uid_t uid, const g
return iox::success<>();
}

expected<FileSetPermissionError> set_permissions(const int fildes, const access_rights perms) noexcept
expected<void, FileSetPermissionError> set_permissions(const int fildes, const access_rights perms) noexcept
{
auto result = posix::posixCall(iox_fchmod)(fildes, perms.value()).failureReturnValue(-1).evaluate();

Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/posix/filesystem/include/iox/file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class File : public FileManagementInterface<File>
explicit File(const int file_descriptor, const posix::AccessMode access_mode) noexcept;
void close_fd() noexcept;

expected<FileOffsetError> set_offset(const uint64_t offset) const noexcept;
expected<void, FileOffsetError> set_offset(const uint64_t offset) const noexcept;

private:
static constexpr int INVALID_FILE_DESCRIPTOR{-1};
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/posix/filesystem/source/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ expected<bool, FileRemoveError> File::remove(const FilePath& file) noexcept
}
}

expected<FileOffsetError> File::set_offset(const uint64_t offset) const noexcept
expected<void, FileOffsetError> File::set_offset(const uint64_t offset) const noexcept
{
auto result = posix::posixCall(iox_lseek)(m_file_descriptor, static_cast<iox_off_t>(offset), IOX_SEEK_SET)
.failureReturnValue(-1)
Expand Down
2 changes: 1 addition & 1 deletion iceoryx_hoofs/source/posix_wrapper/file_lock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ FileLock::~FileLock() noexcept
}
}

expected<FileLockError> FileLock::closeFileDescriptor() noexcept
expected<void, FileLockError> FileLock::closeFileDescriptor() noexcept
{
if (m_fd != INVALID_FD)
{
Expand Down
Loading

0 comments on commit 180e03a

Please sign in to comment.