nidas  v1.2-1520
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
nidas::core::UnixIOChannel Class Reference

Simple implementation of an IOChannel, over an opened file descriptor. More...

#include <UnixIOChannel.h>

Inheritance diagram for nidas::core::UnixIOChannel:
Inheritance graph
[legend]

Public Member Functions

 UnixIOChannel (const std::string &name, int fd)
 Constructor. More...
 
 ~UnixIOChannel ()
 Destructor. More...
 
UnixIOChannelclone () const
 Clone invokes default copy constructor. More...
 
void requestConnection (IOChannelRequester *rqstr) throw (nidas::util::IOException)
 RequestConnection just returns connected immediately. More...
 
IOChannelconnect () throw (nidas::util::IOException)
 Pretty simple, we're connected already. More...
 
void setNonBlocking (bool val) throw (nidas::util::IOException)
 Set the state of O_NONBLOCK with fcntl system call. More...
 
bool isNonBlocking () const throw (nidas::util::IOException)
 Do fcntl to determine value of O_NONBLOCK flag. More...
 
virtual bool isNewInput () const
 Some IOChannels, namely FileSet, which opens successive files, need to indicate when a read is from the start of a new file. More...
 
size_t read (void *buf, size_t len) throw (nidas::util::IOException)
 Do the actual hardware read. More...
 
size_t write (const void *buf, size_t len) throw (nidas::util::IOException)
 Do the actual hardware write. More...
 
size_t write (const struct iovec *iov, int iovcnt) throw (nidas::util::IOException)
 Do the actual hardware write. More...
 
void close () throw (nidas::util::IOException)
 
int getFd () const
 
const std::string & getName () const
 
void setName (const std::string &val)
 
void fromDOMElement (const xercesc::DOMElement *) throw (nidas::util::InvalidParameterException)
 Initialize myself from a xercesc::DOMElement. More...
 
virtual void setRequestType (enum McSocketRequest)
 
virtual enum McSocketRequest getRequestType () const
 
virtual int getReconnectDelaySecs () const
 
virtual const ConnectionInfogetConnectionInfo () const
 What is the IP address of the host at the other end of the connection. More...
 
virtual void setConnectionInfo (const ConnectionInfo &val)
 
virtual size_t getBufferSize () const throw ()
 Return suggested buffer length. More...
 
virtual void flush () throw (nidas::util::IOException)
 Default flush implementation does nothing. More...
 
virtual dsm_time_t createFile (dsm_time_t t, bool exact)
 Request that an IOChannel open a new file, with a name based on a time. More...
 
virtual bool writeNidasHeader () const
 Should the NIDAS header be written to this IOChannel? NIDAS headers are not written to DatagramSockets, because there is no guarantee they will get there. More...
 
virtual void setDSMConfig (const DSMConfig *val)
 What DSM is this IOChannel connected to? More...
 
virtual const DSMConfiggetDSMConfig () const
 What DSM is this IOChannel connected to? May be NULL. More...
 
virtual xercesc::DOMElement * toDOMParent (xercesc::DOMElement *parent, bool complete) const throw (xercesc::DOMException)
 Create a DOMElement and append it to the parent. More...
 
virtual xercesc::DOMElement * toDOMElement (xercesc::DOMElement *node, bool complete) const throw (xercesc::DOMException)
 Add my content into a DOMElement. More...
 

Static Public Member Functions

static IOChannelcreateIOChannel (const xercesc::DOMElement *node) throw (nidas::util::InvalidParameterException)
 
static const XMLCh * getNamespaceURI ()
 

Protected Member Functions

 UnixIOChannel (const UnixIOChannel &x)
 Constructor. More...
 

Protected Attributes

std::string _name
 
int _fd
 
bool _newInput
 

Detailed Description

Simple implementation of an IOChannel, over an opened file descriptor.

Constructor & Destructor Documentation

nidas::core::UnixIOChannel::UnixIOChannel ( const std::string &  name,
int  fd 
)
inline

Constructor.

Referenced by clone().

nidas::core::UnixIOChannel::~UnixIOChannel ( )
inline

Destructor.

Does not close the device.

nidas::core::UnixIOChannel::UnixIOChannel ( const UnixIOChannel x)
inlineprotected

Constructor.

Member Function Documentation

UnixIOChannel* nidas::core::UnixIOChannel::clone ( ) const
inlinevirtual

Clone invokes default copy constructor.

Implements nidas::core::IOChannel.

References UnixIOChannel().

void nidas::core::UnixIOChannel::close ( )
throw (nidas::util::IOException
)
inlinevirtual

Implements nidas::core::IOChannel.

References _fd, and getName().

Referenced by HeaderUtil::run().

IOChannel* nidas::core::UnixIOChannel::connect ( )
throw (nidas::util::IOException
)
inlinevirtual

Pretty simple, we're connected already.

Implements nidas::core::IOChannel.

virtual dsm_time_t nidas::core::IOChannel::createFile ( dsm_time_t  t,
bool  exact 
)
inlinevirtualinherited

Request that an IOChannel open a new file, with a name based on a time.

This should be implemented by derived classes which write to disk files. Other derived classes (e.g. sockets) can just use this default implementation - basically ignoring the request.

Parameters
tTime to use when creating file name.
exactUse exact time when creating file name, else the time is adjusted to an even time interval.

Reimplemented in nidas::core::FileSet.

Referenced by nidas::core::IOStream::createFile().

IOChannel * IOChannel::createIOChannel ( const xercesc::DOMElement *  node)
throw (nidas::util::InvalidParameterException
)
staticinherited
virtual void nidas::core::IOChannel::flush ( )
throw (nidas::util::IOException
)
inlinevirtualinherited
void nidas::core::UnixIOChannel::fromDOMElement ( const xercesc::DOMElement *  )
throw (nidas::util::InvalidParameterException
)
inlinevirtual

Initialize myself from a xercesc::DOMElement.

Implements nidas::core::DOMable.

virtual size_t nidas::core::IOChannel::getBufferSize ( ) const
throw (
)
inlinevirtualinherited
virtual const ConnectionInfo& nidas::core::IOChannel::getConnectionInfo ( ) const
inlinevirtualinherited

What is the IP address of the host at the other end of the connection.

If this IOChannel is not a socket then return INADDR_ANY, using the default constructor of an Inet4Address. Socket subclasses should override this.

Referenced by nidas::dynld::SampleInputStream::setIOChannel().

virtual const DSMConfig* nidas::core::IOChannel::getDSMConfig ( ) const
inlinevirtualinherited

What DSM is this IOChannel connected to? May be NULL.

Referenced by nidas::core::FileSet::setDir(), and nidas::core::FileSet::setFileName().

int nidas::core::UnixIOChannel::getFd ( ) const
inlinevirtual

Implements nidas::core::IOChannel.

References _fd.

const std::string& nidas::core::UnixIOChannel::getName ( ) const
inlinevirtual

Implements nidas::core::IOChannel.

References _name.

Referenced by close(), isNonBlocking(), read(), and write().

static const XMLCh* nidas::core::DOMable::getNamespaceURI ( )
inlinestaticinherited
virtual int nidas::core::IOChannel::getReconnectDelaySecs ( ) const
inlinevirtualinherited
virtual enum McSocketRequest nidas::core::IOChannel::getRequestType ( ) const
inlinevirtualinherited
virtual bool nidas::core::UnixIOChannel::isNewInput ( ) const
inlinevirtual

Some IOChannels, namely FileSet, which opens successive files, need to indicate when a read is from the start of a new file.

This method is used by code which may need to do special things at the beginning of a file, like read a SampleInputHeader.

Reimplemented from nidas::core::IOChannel.

References _newInput.

bool UnixIOChannel::isNonBlocking ( ) const
throw (nidas::util::IOException
)
virtual

Do fcntl to determine value of O_NONBLOCK flag.

Implements nidas::core::IOChannel.

References _fd, and getName().

size_t nidas::core::UnixIOChannel::read ( void *  buf,
size_t  len 
)
throw (nidas::util::IOException
)
inlinevirtual

Do the actual hardware read.

Implements nidas::core::IOChannel.

References _fd, _newInput, getName(), and len.

void nidas::core::UnixIOChannel::requestConnection ( IOChannelRequester rqstr)
throw (nidas::util::IOException
)
inlinevirtual

RequestConnection just returns connected immediately.

Implements nidas::core::IOChannel.

virtual void nidas::core::IOChannel::setConnectionInfo ( const ConnectionInfo val)
inlinevirtualinherited
virtual void nidas::core::IOChannel::setDSMConfig ( const DSMConfig val)
inlinevirtualinherited
void nidas::core::UnixIOChannel::setName ( const std::string &  val)
inlinevirtual

Implements nidas::core::IOChannel.

References _name.

void UnixIOChannel::setNonBlocking ( bool  val)
throw (nidas::util::IOException
)
virtual

Set the state of O_NONBLOCK with fcntl system call.

Implements nidas::core::IOChannel.

virtual void nidas::core::IOChannel::setRequestType ( enum McSocketRequest  )
inlinevirtualinherited
xercesc::DOMElement * DOMable::toDOMElement ( xercesc::DOMElement *  node,
bool  complete 
) const
throw (xercesc::DOMException
)
virtualinherited
xercesc::DOMElement * DOMable::toDOMParent ( xercesc::DOMElement *  parent,
bool  complete 
) const
throw (xercesc::DOMException
)
virtualinherited
size_t nidas::core::UnixIOChannel::write ( const void *  buf,
size_t  len 
)
throw (nidas::util::IOException
)
inlinevirtual

Do the actual hardware write.

Implements nidas::core::IOChannel.

References _fd, _newInput, getName(), and len.

size_t nidas::core::UnixIOChannel::write ( const struct iovec *  iov,
int  iovcnt 
)
throw (nidas::util::IOException
)
inlinevirtual

Do the actual hardware write.

Implements nidas::core::IOChannel.

References _fd, _newInput, and getName().

virtual bool nidas::core::IOChannel::writeNidasHeader ( ) const
inlinevirtualinherited

Should the NIDAS header be written to this IOChannel? NIDAS headers are not written to DatagramSockets, because there is no guarantee they will get there.

Reimplemented in nidas::core::DatagramSocket.

Referenced by nidas::dynld::SampleInputStream::setIOChannel().

Member Data Documentation

int nidas::core::UnixIOChannel::_fd
protected

Referenced by close(), getFd(), isNonBlocking(), read(), and write().

std::string nidas::core::UnixIOChannel::_name
protected

Referenced by getName(), and setName().

bool nidas::core::UnixIOChannel::_newInput
protected

Referenced by isNewInput(), read(), and write().


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