nidas v1.2.3
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Attributes | Static Private 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.
 
 ~UnixIOChannel ()
 Destructor.
 
UnixIOChannelclone () const
 Clone invokes default copy constructor.
 
void requestConnection (IOChannelRequester *rqstr)
 RequestConnection just returns connected immediately.
 
IOChannelconnect ()
 Pretty simple, we're connected already.
 
void setNonBlocking (bool val)
 Set the state of O_NONBLOCK with fcntl system call.
 
bool isNonBlocking () const
 Do fcntl to determine value of O_NONBLOCK flag.
 
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.
 
size_t read (void *buf, size_t len)
 Do the actual hardware read.
 
size_t write (const void *buf, size_t len)
 Do the actual hardware write.
 
size_t write (const struct iovec *iov, int iovcnt)
 Do the actual hardware write.
 
void close ()
 
int getFd () const
 
const std::string & getName () const
 
void setName (const std::string &val)
 
void fromDOMElement (const xercesc::DOMElement *)
 
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.
 
virtual void setConnectionInfo (const ConnectionInfo &val)
 
virtual size_t getBufferSize () const
 Return suggested buffer length.
 
virtual void flush ()
 Default flush implementation does nothing.
 
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.
 
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.
 
virtual void setDSMConfig (const DSMConfig *val)
 What DSM is this IOChannel connected to?
 
virtual const DSMConfiggetDSMConfig () const
 What DSM is this IOChannel connected to? May be NULL.
 
virtual void addSampleTag (const nidas::core::SampleTag *)
 The special NetcdfRPCChannel subclass needs a way to add a SampleTag to the IOChannel through a virtual base class.
 
virtual xercesc::DOMElement * toDOMParent (xercesc::DOMElement *parent, bool complete) const
 Create a DOMElement and append it to the parent.
 
virtual xercesc::DOMElement * toDOMElement (xercesc::DOMElement *node, bool complete) const
 Add my content into a DOMElement.
 

Static Public Member Functions

static IOChannelcreateIOChannel (const xercesc::DOMElement *node)
 
static const XMLChgetNamespaceURI ()
 

Protected Member Functions

 UnixIOChannel (const UnixIOChannel &x)
 Constructor.
 

Protected Attributes

std::string _name
 
int _fd
 
bool _newInput
 

Private Attributes

const DSMConfig_dsm
 
ConnectionInfo _conInfo
 

Static Private Attributes

static XMLChnamespaceURI = 0
 

Detailed Description

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

Constructor & Destructor Documentation

◆ UnixIOChannel() [1/2]

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

Constructor.

Referenced by clone().

◆ ~UnixIOChannel()

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

Destructor.

Does not close the device.

◆ UnixIOChannel() [2/2]

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

Constructor.

Member Function Documentation

◆ addSampleTag()

void IOChannel::addSampleTag ( const nidas::core::SampleTag * )
virtualinherited

The special NetcdfRPCChannel subclass needs a way to add a SampleTag to the IOChannel through a virtual base class.

This method does nothing and serves no purpose except for that class.

◆ clone()

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

Clone invokes default copy constructor.

Implements nidas::core::IOChannel.

References UnixIOChannel().

◆ close()

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

Implements nidas::core::IOChannel.

References _fd, close(), and getName().

Referenced by close().

◆ connect()

IOChannel * nidas::core::UnixIOChannel::connect ( )
inlinevirtual

Pretty simple, we're connected already.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

◆ createFile()

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.
Exceptions
nidas::util::IOException

Reimplemented in nidas::core::FileSet.

References nidas::core::getSample().

Referenced by nidas::core::IOStream::createFile(), and nidas::core::SampleOutputBase::createNextFile().

◆ createIOChannel()

IOChannel * IOChannel::createIOChannel ( const xercesc::DOMElement * node)
staticinherited

◆ flush()

virtual void nidas::core::IOChannel::flush ( )
inlinevirtualinherited

Default flush implementation does nothing.

Exceptions
nidas::util::IOException

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

◆ fromDOMElement()

void nidas::core::UnixIOChannel::fromDOMElement ( const xercesc::DOMElement * )
inlinevirtual

◆ getBufferSize()

virtual size_t nidas::core::IOChannel::getBufferSize ( ) const
inlinevirtualinherited

◆ getConnectionInfo()

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.

References nidas::core::IOChannel::_conInfo.

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

◆ getDSMConfig()

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

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

References nidas::core::IOChannel::_dsm.

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

◆ getFd()

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

Implements nidas::core::IOChannel.

References _fd.

◆ getName()

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

Implements nidas::core::IOChannel.

References _name.

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

◆ getNamespaceURI()

static const XMLCh * nidas::core::DOMable::getNamespaceURI ( )
inlinestaticinherited

◆ getReconnectDelaySecs()

virtual int nidas::core::IOChannel::getReconnectDelaySecs ( ) const
inlinevirtualinherited

◆ getRequestType()

virtual enum McSocketRequest nidas::core::IOChannel::getRequestType ( ) const
inlinevirtualinherited

◆ isNewInput()

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.

◆ isNonBlocking()

bool UnixIOChannel::isNonBlocking ( ) const
virtual

Do fcntl to determine value of O_NONBLOCK flag.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

References _fd, and getName().

◆ read()

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

Do the actual hardware read.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

References _fd, _newInput, getName(), nidas::core::getSample(), len, and read().

Referenced by read().

◆ requestConnection()

void nidas::core::UnixIOChannel::requestConnection ( IOChannelRequester * rqstr)
inlinevirtual

RequestConnection just returns connected immediately.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

◆ setConnectionInfo()

virtual void nidas::core::IOChannel::setConnectionInfo ( const ConnectionInfo & val)
inlinevirtualinherited

◆ setDSMConfig()

virtual void nidas::core::IOChannel::setDSMConfig ( const DSMConfig * val)
inlinevirtualinherited

◆ setName()

void nidas::core::UnixIOChannel::setName ( const std::string & val)
inlinevirtual

◆ setNonBlocking()

void UnixIOChannel::setNonBlocking ( bool val)
virtual

Set the state of O_NONBLOCK with fcntl system call.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

References _fd, getName(), and nidas::core::getSample().

◆ setRequestType()

virtual void nidas::core::IOChannel::setRequestType ( enum McSocketRequest )
inlinevirtualinherited

◆ toDOMElement()

xercesc::DOMElement * DOMable::toDOMElement ( xercesc::DOMElement * node,
bool complete ) const
virtualinherited

◆ toDOMParent()

xercesc::DOMElement * DOMable::toDOMParent ( xercesc::DOMElement * parent,
bool complete ) const
virtualinherited

Create a DOMElement and append it to the parent.

Exceptions
xercesc::DOMException

Reimplemented in nidas::core::DSMConfig, nidas::core::DSMSensor, nidas::core::Project, nidas::core::SampleTag, nidas::core::Site, nidas::core::ServerSocket, and nidas::core::Variable.

◆ write() [1/2]

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

Do the actual hardware write.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

References _fd, _newInput, getName(), and nidas::core::getSample().

◆ write() [2/2]

size_t nidas::core::UnixIOChannel::write ( const void * buf,
size_t len )
inlinevirtual

Do the actual hardware write.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

References _fd, _newInput, getName(), nidas::core::getSample(), len, and write().

Referenced by write().

◆ writeNidasHeader()

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

◆ _conInfo

ConnectionInfo nidas::core::IOChannel::_conInfo
privateinherited

◆ _dsm

const DSMConfig* nidas::core::IOChannel::_dsm
privateinherited

◆ _fd

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

◆ _name

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

Referenced by getName(), and setName().

◆ _newInput

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

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

◆ namespaceURI

XMLCh * DOMable::namespaceURI = 0
staticprivateinherited

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