contur2
Loading...
Searching...
No Matches

Simulated network (LAN) device. More...

#include <network_device.h>

Inheritance diagram for contur::NetworkDevice:
Collaboration diagram for contur::NetworkDevice:

Public Member Functions

 NetworkDevice (std::size_t bufferCapacity=256)
 Constructs a network device with the given buffer capacity.
 ~NetworkDevice () override
 NetworkDevice (const NetworkDevice &)=delete
NetworkDeviceoperator= (const NetworkDevice &)=delete
 NetworkDevice (NetworkDevice &&) noexcept
NetworkDeviceoperator= (NetworkDevice &&) noexcept
DeviceId id () const noexcept override
 Returns the unique device identifier.
std::string_view name () const noexcept override
 Returns the human-readable device name.
Result< RegisterValueread () override
 Reads a value from the device.
Result< void > write (RegisterValue value) override
 Writes a value to the device.
bool isReady () const noexcept override
 Returns true if the device is ready for I/O operations.
std::size_t bufferSize () const noexcept
 Returns the number of values currently in the buffer.
bool hasData () const noexcept
 Returns true if the buffer has unread data.
Public Member Functions inherited from contur::IDevice
virtual ~IDevice ()=default

Static Public Attributes

static constexpr DeviceId NETWORK_DEVICE_ID = 2
 Default network device ID.

Private Attributes

std::unique_ptr< Impl > impl_

Additional Inherited Members

Protected Member Functions inherited from contur::IDevice
 IDevice ()=default
 IDevice (const IDevice &)=default
IDeviceoperator= (const IDevice &)=default
 IDevice (IDevice &&)=default
IDeviceoperator= (IDevice &&)=default

Detailed Description

Simulated network (LAN) device.

Writes enqueue data into an internal send buffer. Reads dequeue from a receive buffer (loopback / echo mode for simulation).

Definition at line 19 of file network_device.h.

Constructor & Destructor Documentation

◆ NetworkDevice() [1/3]

contur::NetworkDevice::NetworkDevice ( std::size_t bufferCapacity = 256)
explicit

Constructs a network device with the given buffer capacity.

Parameters
bufferCapacityMaximum number of values in the send/receive buffer.

◆ ~NetworkDevice()

contur::NetworkDevice::~NetworkDevice ( )
override

◆ NetworkDevice() [2/3]

contur::NetworkDevice::NetworkDevice ( const NetworkDevice & )
delete

◆ NetworkDevice() [3/3]

contur::NetworkDevice::NetworkDevice ( NetworkDevice && )
noexcept

Member Function Documentation

◆ bufferSize()

std::size_t contur::NetworkDevice::bufferSize ( ) const
nodiscardnoexcept

Returns the number of values currently in the buffer.

◆ hasData()

bool contur::NetworkDevice::hasData ( ) const
nodiscardnoexcept

Returns true if the buffer has unread data.

◆ id()

DeviceId contur::NetworkDevice::id ( ) const
nodiscardoverridevirtualnoexcept

Returns the unique device identifier.

Implements contur::IDevice.

◆ isReady()

bool contur::NetworkDevice::isReady ( ) const
nodiscardoverridevirtualnoexcept

Returns true if the device is ready for I/O operations.

Implements contur::IDevice.

◆ name()

std::string_view contur::NetworkDevice::name ( ) const
nodiscardoverridevirtualnoexcept

Returns the human-readable device name.

Implements contur::IDevice.

◆ operator=() [1/2]

NetworkDevice & contur::NetworkDevice::operator= ( const NetworkDevice & )
delete

◆ operator=() [2/2]

NetworkDevice & contur::NetworkDevice::operator= ( NetworkDevice && )
noexcept

◆ read()

Result< RegisterValue > contur::NetworkDevice::read ( )
nodiscardoverridevirtual

Reads a value from the device.

Returns
The read value, or an error if the device is not ready or read is unsupported.

Implements contur::IDevice.

◆ write()

Result< void > contur::NetworkDevice::write ( RegisterValue value)
nodiscardoverridevirtual

Writes a value to the device.

Parameters
valueThe value to write.
Returns
Success or an error if the device is not ready or write is unsupported.

Implements contur::IDevice.

Member Data Documentation

◆ impl_

std::unique_ptr<Impl> contur::NetworkDevice::impl_
private

Definition at line 50 of file network_device.h.

◆ NETWORK_DEVICE_ID

DeviceId contur::NetworkDevice::NETWORK_DEVICE_ID = 2
staticconstexpr

Default network device ID.

Definition at line 23 of file network_device.h.


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