#include <conexus/endpoint.h>
Inheritance diagram for Conexus::Endpoint:
read/write methods are pure virtual methods in this base class and it is the responsibility of all children to provide proper implementations that may go beyond the traditional read(2) and write(2) functions standard in Linux/Unix.
Children are also responsible for maintenance of the file descriptor member m_fd and the integer state value m_state.
This class inherits from propertymm::Object and thus makes some properties available via the propertymm framework as well as providing direct accessor methods.
Public Types | |
typedef boost::shared_ptr< Endpoint > | pointer |
typedef enum Conexus::Endpoint::EndpointState | EndpointState |
These enumerations are used in the socket class methods, and use is also encouraged in children. | |
enum | EndpointState { NOSTATE = 0x00, CLOSED = 1<<0, OPENED = 1<<1, LASTENDPOINTSTATE = OPENED, UNCHANGED = ~0x00 } |
These enumerations are used in the socket class methods, and use is also encouraged in children. More... | |
Public Member Functions | |
Endpoint (bool close_on_destruction=true) | |
Default constructor setting state to 0 and file descriptor to -1 (which should be an invalid fd on just about every POSIX system. | |
virtual | ~Endpoint () |
Destructor does nothing. | |
virtual void | open ()=0 throw (open_error) |
Will attempt to open the object without any additional information. | |
virtual void | close (bool force=false)=0 throw (close_error) |
virtual ssize_t | write (const void *data, size_t size, IOMETHOD block=BLOCK)=0 throw (write_error) |
A pure virtual method that must be reimplemented by children to perform whatever actions necessary to ensure writing/transmission of a block of data pointed to by data and of size bytes. | |
virtual ssize_t | write (Data data, IOMETHOD block=BLOCK) |
Write data according to virtual method defined by children. | |
virtual ssize_t | write (CData data, IOMETHOD block=BLOCK) |
Write constant data according to virtual method defined by children. | |
virtual Data | read (size_t s=0)=0 throw (read_error) |
A pure virtual method that must be reimplemented by children to perform whatever actions necessary to read a block of data. | |
virtual void | change_state (unsigned long new_state) throw (state_error) |
It is intended that children will provide their own implementation of this method to take into account the actions necessary for any additional states they may introduce. | |
void | set_close_on_destruction (bool value) |
bool | close_on_destruction () const |
void | close_and_reopen (unsigned long state=UNCHANGED) |
Close the I/O point and reopen to a new (or same state). | |
sigc::signal< void > | signal_opened () |
sigc::signal< void > | signal_closed () |
sigc::signal< void, bool, bool > | signal_read_write_block_changed () |
bool | is_open () |
bool | is_closed () |
bool | is_read_blocked () |
bool | is_write_blocked () |
virtual void | block_read (bool read_block=true) |
virtual void | block_write (bool write_block=true) |
virtual void | block_read_write (bool read_block=true, bool write_block=true) |
unsigned long | state () |
virtual const std::string & | object_type () |
Protected Member Functions | |
virtual void | set_state_opened () |
virtual void | set_state_closed () |
Protected Attributes | |
bool | m_close_on_destruction |
long unsigned | m_state |
bool | m_readable |
bool | m_writable |
bool | m_read_blocked |
bool | m_write_blocked |
sigc::signal< void > | m_signal_opened |
sigc::signal< void > | m_signal_closed |
sigc::signal< void, bool, bool > | m_signal_read_write_block_changed |
|
These enumerations are used in the socket class methods, and use is also encouraged in children.
|
|
Default constructor setting state to 0 and file descriptor to -1 (which should be an invalid fd on just about every POSIX system. This constructor simply sets the values according to the parameters and performs no real actions with the file descriptor. |
|
Destructor does nothing. It will not call close() upon the file descriptor or perform any other cleanup; these are the responsibility of the children. |
|
It is intended that children will provide their own implementation of this method to take into account the actions necessary for any additional states they may introduce. This method as implemented recognizes the OPEN, CLOSE and UNCHANGED states and calls the virtual open, close (or no call) as is appropriate. This method does not actually modify the m_state member. It is the responsibility of the called virtual methods open() and close() to actually perform the modification.
|
|
Close the I/O point and reopen to a new (or same state). If state is UNCHANGED will reopen to the previous state. close and reopen is accomplished by calling change_state(CLOSED) and then change_state(new_state), not by calling close directly. |
|
A pure virtual method that must be reimplemented by children to perform whatever actions necessary to read a block of data. Children may utilize the parameter s or may choose to ignore the parameter entirely.
Implemented in Conexus::IPv4::TCP, Conexus::IPv4::UDP, Conexus::IPv6::TCP, Conexus::IPv6::UDP, Conexus::RWFileDescriptor, and Conexus::TTY. |
|
Write constant data according to virtual method defined by children.
|
|
Write data according to virtual method defined by children.
|
|
A pure virtual method that must be reimplemented by children to perform whatever actions necessary to ensure writing/transmission of a block of data pointed to by data and of size bytes.
Implemented in Conexus::RWFileDescriptor. |