|
Open Model Railroad Network (OpenMRN)
|
HubPort that connects a select-aware device to a strongly typed Hub. More...
#include <HubDeviceSelect.hxx>
Classes | |
| class | WriteFlow |
| State flow implementing select-aware fd writes. More... | |
Public Member Functions | |
| HubDeviceSelect (HFlow *hub, const char *path, Notifiable *on_error=nullptr) | |
| Creates a select-aware hub port for the device specified by ‘path’. | |
| HubDeviceSelect (HFlow *hub, int fd, Notifiable *on_error=nullptr) | |
| Creates a select-aware hub port for the opened device specified by ‘fd’. | |
| virtual | ~HubDeviceSelect () |
| If the barrier has not been called yet, will notify it inline. | |
| HFlow * | hub () |
| HFlow::port_type * | write_port () |
| void | unregister_write_port () |
| Removes the current write port from the registry of the source hub. | |
| bool | write_done () |
Public Member Functions inherited from FdHubPortInterface | |
| int | fd () |
Public Member Functions inherited from Service | |
| Service (ExecutorBase *e) | |
| Constructor. | |
| ~Service () | |
| Destructor. | |
| ExecutorBase * | executor () |
Protected Types | |
| typedef StateFlow< typename HFlow::buffer_type, QList< 1 > > | WriteFlowBase |
| Base stateflow for the WriteFlow. | |
Protected Member Functions | |
| void | report_write_error () override |
| The assumption here is that the write flow still has entries in its queue that need to be removed. | |
| void | report_read_error () override |
| Callback from the ReadFlow when the read call has seen an error. | |
| void | close_fd () |
Protected Member Functions inherited from FdHubPortService | |
| FdHubPortService (ExecutorBase *exec, int fd) | |
| Constructor. | |
Protected Member Functions inherited from FdHubPortInterface | |
| FdHubPortInterface (int fd) | |
Protected Attributes | |
| HFlow * | hub_ |
| Hub whose data we are trying to send. | |
| ReadFlow | readFlow_ |
| StateFlow for reading data from the fd. Woken when data arrives. | |
| WriteFlow | writeFlow_ |
| StateFlow for writing data to the fd. | |
| bool | isRegistered_ |
| True when the write flow is registered in the hub. | |
Protected Attributes inherited from FdHubPortService | |
| BarrierNotifiable | barrier_ |
| This notifiable will be called (if not NULL) upon read or write error. | |
Protected Attributes inherited from FdHubPortInterface | |
| int | fd_ {-1} |
| The device file descriptor. | |
Additional Inherited Members | |
Private Member Functions inherited from Atomic | |
| void | lock () |
| void | unlock () |
HubPort that connects a select-aware device to a strongly typed Hub.
The device is given by either the path to the device or the fd to an opened device instance or socket. The device will be put to nonblocking mode and all processing will be performed in the executor of the hub, by using ExecutorBase::select(). No additional threads are started.
Reads and writes will be performed in the units defined by the type of the hub: for string-typed hubs in 64 bytes units; for hubs of specific structures (such as CAN frame, dcc Packets or dcc Feedback structures) in the units ofthe size of the structure.
Definition at line 298 of file HubDeviceSelect.hxx.
|
protected |
Base stateflow for the WriteFlow.
Definition at line 413 of file HubDeviceSelect.hxx.
|
inline |
Creates a select-aware hub port for the device specified by ‘path’.
Definition at line 303 of file HubDeviceSelect.hxx.
|
inline |
Creates a select-aware hub port for the opened device specified by ‘fd’.
It can be a hardware device, socket or pipe.
| hub | the hub to open the port on |
| fd | the filedes to read/write data from/to. |
| on_error | notifiable that will be called when a write or read error is encountered. |
Definition at line 327 of file HubDeviceSelect.hxx.
|
inlinevirtual |
If the barrier has not been called yet, will notify it inline.
Definition at line 348 of file HubDeviceSelect.hxx.
|
inlineprotected |
Definition at line 497 of file HubDeviceSelect.hxx.
|
inline |
Definition at line 371 of file HubDeviceSelect.hxx.
|
inlineoverrideprotectedvirtual |
Callback from the ReadFlow when the read call has seen an error.
The read count will already have been taken out of the barrier, and the read flow in terminated state.
Implements FdHubPortService.
Definition at line 491 of file HubDeviceSelect.hxx.
|
inlineoverrideprotectedvirtual |
The assumption here is that the write flow still has entries in its queue that need to be removed.
Implements FdHubPortService.
Definition at line 481 of file HubDeviceSelect.hxx.
|
inline |
Removes the current write port from the registry of the source hub.
Definition at line 383 of file HubDeviceSelect.hxx.
|
inline |
Definition at line 406 of file HubDeviceSelect.hxx.
|
inline |
Definition at line 377 of file HubDeviceSelect.hxx.
|
protected |
Hub whose data we are trying to send.
Definition at line 520 of file HubDeviceSelect.hxx.
|
protected |
True when the write flow is registered in the hub.
Used to synchronize different and concurrent shutdown paths. Protected by Atomic this.
Definition at line 528 of file HubDeviceSelect.hxx.
|
protected |
StateFlow for reading data from the fd. Woken when data arrives.
Definition at line 522 of file HubDeviceSelect.hxx.
|
protected |
StateFlow for writing data to the fd.
Woken by data to send or the fd being writeable.
Definition at line 525 of file HubDeviceSelect.hxx.