#include <senf/Socket/FileHandle.hh>
senf::FileHandle provides a simple wrapper for arbitrary file handles. It exposes only a minimal interface which does not include reading or writing (since some filehandles are not readable or writable or only using special function calls like sendto).
The FileHandle class provides handle/body handling and uses automatic reference counting. The senf::FileHandle instance is very lightweight and should be used like a built-in type.
It is not possible to use the senf::FileHandle class directly since it does not have any public constructor. The FileHandle class is however the baseclass of all handle classes of the socket library.
Definition at line 111 of file FileHandle.hh.
Public Member Functions |
|
void | close () |
Close filehandle. |
|
void | terminate () |
Close filehandle ignoring error conditions. |
|
bool | readable () const |
Check, whether a read on the handle would not block < (ignoring blocking state). |
|
bool | waitReadable (senf::ClockService::clock_type timeout=-1) const |
Wait, until read on the handle would not block (ignoring < blocking state). |
|
bool | writeable () const |
Check, whether a write on the handle would not block < (ignoring blocking state). |
|
bool | waitWriteable (senf::ClockService::clock_type timeout=-1) const |
Wait, until a write on the handle would not block < (ignoring blocking state). |
|
bool | oobReadable () const |
Check, whether a read of prioritized data on the handle < would not block (ignoring blocking state). |
|
bool | waitOOBReadable (senf::ClockService::clock_type timeout=-1) const |
Wait, until read of prioritized data on the handle does < not block (ignoring blocking state). |
|
bool | blocking () const |
Return current blocking state. |
|
void | blocking (bool status) |
Set blocking state. |
|
bool | eof () const |
Check EOF condition. |
|
bool | valid () const |
Check filehandle validity. |
|
bool | boolean_test () const |
Short for valid() && ! eof(). |
|
int | fd () const |
Return the raw FileHandle. |
|
Static Public Member Functions |
|
static FileHandle | cast_static (FileHandle handle) |
static FileHandle | cast_dynamic (FileHandle handle) |
Related Functions |
|
(Note that these are not member functions.) |
|
int | retrieve_filehandle (FileHandle handle) |
Adapt FileHandle to senf::scheduler. |
|
Structors and default members |
|
FileHandle () | |
~FileHandle () | |
Protected Member Functions |
|
FileHandle (std::auto_ptr< FileBody > body) | |
create new FileHandle instance |
|
FileHandle (FileBody::ptr body) | |
FileBody & | body () |
Access body. |
|
FileBody const & | body () const |
Access body in const context. |
|
void | fd (int fd) |
Set raw filehandle. |
|
Static Protected Member Functions |
|
static FileBody & | body (FileHandle &handle) |
Access body of another FileHandle instance. |
|
static FileBody const & | body (FileHandle const &handle) |
Access body of another < FileHandle instance in const context. |
senf::FileHandle:: | ||||
FileHandle | () | |||
Definition at line 207 of file FileHandle.cci.
senf::FileHandle:: | ||||
~FileHandle | () | |||
Definition at line 211 of file FileHandle.cci.
senf::FileHandle:: | ||||
FileHandle | ( | std::auto_ptr< FileBody > | body | ) |
create new FileHandle instance
The FileHandle instance will take over ownership over the given FileBody instance which must have been allocated using new
. To configure the FileHandle behavior, A derived class may provide any class derived from FileBody here.
Definition at line 217 of file FileHandle.cci.
senf::FileHandle:: | ||||
FileHandle | ( | FileBody::ptr | body | ) |
Definition at line 221 of file FileHandle.cci.
void senf::FileHandle:: | ||||
blocking | ( | bool | status | ) |
Set blocking state.
Definition at line 178 of file FileHandle.cci.
bool senf::FileHandle:: | ||||
blocking | () | |||
Return current blocking state.
Definition at line 172 of file FileHandle.cci.
senf::FileBody const & senf::FileHandle:: | ||||
body | ( | FileHandle const & | handle | ) |
Access body of another < FileHandle instance in const context.
Definition at line 230 of file FileHandle.cci.
senf::FileBody & senf::FileHandle:: | ||||
body | ( | FileHandle & | handle | ) |
Access body of another FileHandle instance.
Definition at line 225 of file FileHandle.cci.
senf::FileBody const & senf::FileHandle:: | ||||
body | () | |||
Access body in const context.
Reimplemented in senf::SocketHandle< SPolicy >, senf::SocketHandle< DVBFrontendSocketProtocol::Policy >, senf::SocketHandle< SocketProtocol::Policy >, and senf::SocketHandle< SPolicy >.
Definition at line 119 of file FileHandle.cci.
senf::FileBody & senf::FileHandle:: | ||||
body | () | |||
Access body.
Reimplemented in senf::SocketHandle< SPolicy >, senf::SocketHandle< DVBFrontendSocketProtocol::Policy >, senf::SocketHandle< SocketProtocol::Policy >, and senf::SocketHandle< SPolicy >.
Definition at line 113 of file FileHandle.cci.
bool senf::FileHandle:: | ||||
boolean_test | () | |||
This is called when using a FileHandle instance in a boolean context
See the performance comments for the eof() member
Definition at line 195 of file FileHandle.cci.
senf::FileHandle senf::FileHandle:: | ||||
cast_dynamic | ( | FileHandle | handle | ) |
For internal use only.
Reimplemented in senf::ClientSocketHandle< SPolicy >, senf::ProtocolClientSocketHandle< SocketProtocol >, senf::ProtocolServerSocketHandle< SocketProtocol >, senf::ServerSocketHandle< SPolicy >, senf::SocketHandle< SPolicy >, senf::ClientSocketHandle< DVBFrontendSocketProtocol::Policy >, senf::ClientSocketHandle< SocketProtocol::Policy >, senf::ProtocolClientSocketHandle< DVBFrontendSocketProtocol >, senf::ServerSocketHandle< SocketProtocol::Policy >, senf::SocketHandle< DVBFrontendSocketProtocol::Policy >, senf::SocketHandle< SocketProtocol::Policy >, and senf::SocketHandle< SPolicy >.
Definition at line 245 of file FileHandle.cci.
senf::FileHandle senf::FileHandle:: | ||||
cast_static | ( | FileHandle | handle | ) |
For internal use only.
Reimplemented in senf::ClientSocketHandle< SPolicy >, senf::ProtocolClientSocketHandle< SocketProtocol >, senf::ProtocolServerSocketHandle< SocketProtocol >, senf::ServerSocketHandle< SPolicy >, senf::SocketHandle< SPolicy >, senf::ClientSocketHandle< DVBFrontendSocketProtocol::Policy >, senf::ClientSocketHandle< SocketProtocol::Policy >, senf::ProtocolClientSocketHandle< DVBFrontendSocketProtocol >, senf::ServerSocketHandle< SocketProtocol::Policy >, senf::SocketHandle< DVBFrontendSocketProtocol::Policy >, senf::SocketHandle< SocketProtocol::Policy >, and senf::SocketHandle< SPolicy >.
Definition at line 240 of file FileHandle.cci.
void senf::FileHandle:: | ||||
close | () | |||
bool senf::FileHandle:: | ||||
eof | () | |||
Check EOF condition.
Depending on the socket type, this might never return true
.
This member is somewhat problematic performance wise if called frequently since it relies on virtual functions. However, since the eof() handling is extremely protocol dependent, a policy based implementation does not seam feasible.
Definition at line 183 of file FileHandle.cci.
void senf::FileHandle:: | ||||
fd | ( | int | fd | ) |
Set raw filehandle.
Definition at line 235 of file FileHandle.cci.
int senf::FileHandle:: | ||||
fd | () | |||
Return the raw FileHandle.
Definition at line 201 of file FileHandle.cci.
bool senf::FileHandle:: | ||||
oobReadable | () | |||
Check, whether a read of prioritized data on the handle < would not block (ignoring blocking state).
Definition at line 160 of file FileHandle.cci.
bool senf::FileHandle:: | ||||
readable | () | |||
Check, whether a read on the handle would not block < (ignoring blocking state).
Definition at line 136 of file FileHandle.cci.
void senf::FileHandle:: | ||||
terminate | () | |||
Close filehandle ignoring error conditions.
Definition at line 131 of file FileHandle.cci.
bool senf::FileHandle:: | ||||
valid | () | |||
Check filehandle validity.
Any operation besides valid() will fail on an invalid FileHandle
Definition at line 189 of file FileHandle.cci.
bool senf::FileHandle:: | ||||
waitOOBReadable | ( | senf::ClockService::clock_type |
timeout = -1
|
) |
Wait, until read of prioritized data on the handle does < not block (ignoring blocking state).
[in] | timeout | max time to wait, default is to wait forever. |
true
, if handle became readable for out-of-band data or false
on timeout.Definition at line 166 of file FileHandle.cci.
bool senf::FileHandle:: | ||||
waitReadable | ( | senf::ClockService::clock_type |
timeout = -1
|
) |
Wait, until read on the handle would not block (ignoring < blocking state).
[in] | timeout | max time to wait, default is to wait forever. |
true
, if handle became readable or false
on timeout.Definition at line 142 of file FileHandle.cci.
bool senf::FileHandle:: | ||||
waitWriteable | ( | senf::ClockService::clock_type |
timeout = -1
|
) |
Wait, until a write on the handle would not block < (ignoring blocking state).
[in] | timeout | max time to wait, default is to wait forever. |
true
, if handle became writable or false
on timeout.Definition at line 154 of file FileHandle.cci.
bool senf::FileHandle:: | ||||
writeable | () | |||
Check, whether a write on the handle would not block < (ignoring blocking state).
Definition at line 148 of file FileHandle.cci.