iceoryx_hoofs 2.0.3
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Friends | List of all members
iox::posix::NamedPipe Class Reference
Inheritance diagram for iox::posix::NamedPipe:
Inheritance graph
[legend]
Collaboration diagram for iox::posix::NamedPipe:
Collaboration graph
[legend]

Public Types

using Message_t = cxx::string< MAX_MESSAGE_SIZE >
 
using MessageQueue_t = concurrent::LockFreeQueue< Message_t, MAX_NUMBER_OF_MESSAGES >
 
- Public Types inherited from DesignPattern::Creation< NamedPipe, IpcChannelError >
using CreationPattern_t = Creation< NamedPipe, IpcChannelError >
 
using result_t = iox::cxx::expected< NamedPipe, IpcChannelError >
 
using errorType_t = IpcChannelError
 

Public Member Functions

 NamedPipe (const NamedPipe &)=delete
 
NamedPipeoperator= (const NamedPipe &)=delete
 
 NamedPipe () noexcept
 For compatibility with IpcChannel alias, default ctor which creates an uninitialized NamedPipe.
 
 NamedPipe (NamedPipe &&rhs) noexcept
 
NamedPipeoperator= (NamedPipe &&rhs) noexcept
 
cxx::expected< IpcChannelError > destroy () noexcept
 destroys an initialized named pipe. More...
 
cxx::expected< bool, IpcChannelError > isOutdated () noexcept
 for compatibility with IpcChannelError More...
 
cxx::expected< IpcChannelError > trySend (const std::string &message) const noexcept
 tries to send a message via the named pipe. if the pipe is full IpcChannelError::TIMEOUT is returned More...
 
cxx::expected< IpcChannelError > send (const std::string &message) const noexcept
 sends a message via the named pipe. if the pipe is full this call is blocking until the message could be delivered More...
 
cxx::expected< IpcChannelError > timedSend (const std::string &message, const units::Duration &timeout) const noexcept
 sends a message via the named pipe. More...
 
cxx::expected< std::string, IpcChannelError > tryReceive () const noexcept
 tries to receive a message via the named pipe. if the pipe is empty IpcChannelError::TIMEOUT is returned More...
 
cxx::expected< std::string, IpcChannelError > receive () const noexcept
 receives a message via the named pipe. if the pipe is empty this call is blocking until a message was received More...
 
cxx::expected< std::string, IpcChannelError > timedReceive (const units::Duration &timeout) const noexcept
 receives a message via the named pipe. More...
 
- Public Member Functions inherited from DesignPattern::Creation< NamedPipe, IpcChannelError >
 Creation (Creation &&rhs) noexcept
 
 Creation (const Creation &rhs) noexcept=default
 
Creationoperator= (Creation &&rhs) noexcept
 
Creationoperator= (const Creation &rhs) noexcept=default
 
bool isInitialized () const noexcept
 returns true if the object was constructed successfully, otherwise false
 

Static Public Member Functions

static cxx::expected< bool, IpcChannelError > unlinkIfExists (const IpcChannelName_t &name) noexcept
 removes a named pipe artifact from the system More...
 
- Static Public Member Functions inherited from DesignPattern::Creation< NamedPipe, IpcChannelError >
static result_t create (Targs &&... args) noexcept
 factory method which guarantees that either a working object is produced or an error value describing the error during construction More...
 
static result_t verify (NamedPipe &&newObject) noexcept
 verifies if a class was created successfully More...
 
static iox::cxx::expected< IpcChannelError > placementCreate (void *const memory, Targs &&... args) noexcept
 factory method which guarantees that either a working object is produced or an error value describing the error during construction More...
 

Static Public Attributes

static constexpr uint64_t MAX_MESSAGE_SIZE = 4U * 1024U
 
static constexpr uint64_t MAX_NUMBER_OF_MESSAGES = 10U
 
static constexpr uint64_t NULL_TERMINATOR_SIZE = 0U
 
static constexpr units::Duration CYCLE_TIME = units::Duration::fromMilliseconds(10)
 
static constexpr const char NAMED_PIPE_PREFIX [] = "iox_np_"
 

Friends

class DesignPattern::Creation< NamedPipe, IpcChannelError >
 

Additional Inherited Members

- Protected Attributes inherited from DesignPattern::Creation< NamedPipe, IpcChannelError >
bool m_isInitialized
 
IpcChannelError m_errorValue
 

Member Function Documentation

◆ destroy()

cxx::expected< IpcChannelError > iox::posix::NamedPipe::destroy ( )
noexcept

destroys an initialized named pipe.

Returns
is always successful

◆ isOutdated()

cxx::expected< bool, IpcChannelError > iox::posix::NamedPipe::isOutdated ( )
noexcept

for compatibility with IpcChannelError

Returns
always false

◆ receive()

cxx::expected< std::string, IpcChannelError > iox::posix::NamedPipe::receive ( ) const
noexcept

receives a message via the named pipe. if the pipe is empty this call is blocking until a message was received

Returns
on success a string containing the message, otherwise an error which describes the failure

◆ send()

cxx::expected< IpcChannelError > iox::posix::NamedPipe::send ( const std::string &  message) const
noexcept

sends a message via the named pipe. if the pipe is full this call is blocking until the message could be delivered

Parameters
[in]messagethe message which should be sent, is not allowed to be longer then MAX_MESSAGE_SIZE
Returns
success when message was sent otherwise an error which describes the failure

◆ timedReceive()

cxx::expected< std::string, IpcChannelError > iox::posix::NamedPipe::timedReceive ( const units::Duration &  timeout) const
noexcept

receives a message via the named pipe.

Parameters
[in]timeoutthe timeout on how long this method should retry to receive a message
Returns
on success a string containing the message, otherwise an error which describes the failure

◆ timedSend()

cxx::expected< IpcChannelError > iox::posix::NamedPipe::timedSend ( const std::string &  message,
const units::Duration &  timeout 
) const
noexcept

sends a message via the named pipe.

Parameters
[in]messagethe message which should be sent, is not allowed to be longer then MAX_MESSAGE_SIZE
[in]timeoutthe timeout on how long this method should retry to send the message
Returns
success when message was sent otherwise an error which describes the failure

◆ tryReceive()

cxx::expected< std::string, IpcChannelError > iox::posix::NamedPipe::tryReceive ( ) const
noexcept

tries to receive a message via the named pipe. if the pipe is empty IpcChannelError::TIMEOUT is returned

Returns
on success a string containing the message, otherwise an error which describes the failure

◆ trySend()

cxx::expected< IpcChannelError > iox::posix::NamedPipe::trySend ( const std::string &  message) const
noexcept

tries to send a message via the named pipe. if the pipe is full IpcChannelError::TIMEOUT is returned

Returns
on failure an error which describes the failure

◆ unlinkIfExists()

static cxx::expected< bool, IpcChannelError > iox::posix::NamedPipe::unlinkIfExists ( const IpcChannelName_t &  name)
staticnoexcept

removes a named pipe artifact from the system

Returns
true if the artifact was removed, false when no artifact was found and IpcChannelError::INTERNAL_LOGIC_ERROR when shm_unlink failed

The documentation for this class was generated from the following file: