nidas v1.2.3
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
nidas::core::IOChannel Class Referenceabstract

A channel for Input or Output of data. More...

#include <IOChannel.h>

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

Public Member Functions

 IOChannel ()
 
 IOChannel (const IOChannel &x)
 
IOChanneloperator= (const IOChannel &rhs)
 
virtual ~IOChannel ()
 
virtual IOChannelclone () const =0
 Derived classes must provide clone.
 
virtual void setName (const std::string &val)=0
 
virtual const std::string & getName () const =0
 
virtual void setRequestType (enum McSocketRequest)
 
virtual enum McSocketRequest getRequestType () const
 
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.
 
virtual void requestConnection (IOChannelRequester *)=0
 After the IOChannel is configured, a user of IOChannel calls requestConnection to get things started.
 
virtual int getReconnectDelaySecs () const
 
virtual void setNonBlocking (bool val)=0
 
virtual bool isNonBlocking () const =0
 
virtual IOChannelconnect ()=0
 Establish a connection.
 
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 size_t read (void *buf, size_t len)=0
 Physical read method which must be implemented in derived classes.
 
virtual size_t write (const void *buf, size_t len)=0
 Physical write method which must be implemented in derived classes.
 
virtual size_t write (const struct iovec *iov, int iovcnt)=0
 Physical write method which must be implemented in derived classes.
 
virtual void flush ()
 Default flush implementation does nothing.
 
virtual void close ()=0
 
virtual int getFd () const =0
 
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 void fromDOMElement (const xercesc::DOMElement *)=0
 Initialize myself from a xercesc::DOMElement.
 
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 ()
 

Private Attributes

const DSMConfig_dsm
 
ConnectionInfo _conInfo
 

Static Private Attributes

static XMLChnamespaceURI = 0
 

Detailed Description

A channel for Input or Output of data.

Constructor & Destructor Documentation

◆ IOChannel() [1/2]

IOChannel::IOChannel ( )

◆ IOChannel() [2/2]

nidas::core::IOChannel::IOChannel ( const IOChannel & x)
inline

◆ ~IOChannel()

virtual nidas::core::IOChannel::~IOChannel ( )
inlinevirtual

Member Function Documentation

◆ addSampleTag()

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

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()

virtual IOChannel * nidas::core::IOChannel::clone ( ) const
pure virtual

◆ close()

virtual void nidas::core::IOChannel::close ( )
pure virtual

◆ connect()

virtual IOChannel * nidas::core::IOChannel::connect ( )
pure virtual

◆ createFile()

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

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)
static

◆ flush()

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

Default flush implementation does nothing.

Exceptions
nidas::util::IOException

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

◆ fromDOMElement()

virtual void nidas::core::DOMable::fromDOMElement ( const xercesc::DOMElement * )
pure virtualinherited

◆ getBufferSize()

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

◆ getConnectionInfo()

virtual const ConnectionInfo & nidas::core::IOChannel::getConnectionInfo ( ) const
inlinevirtual

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 _conInfo.

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

◆ getDSMConfig()

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

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

References _dsm.

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

◆ getFd()

virtual int nidas::core::IOChannel::getFd ( ) const
pure virtual

◆ getName()

virtual const std::string & nidas::core::IOChannel::getName ( ) const
pure virtual

◆ getNamespaceURI()

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

◆ getReconnectDelaySecs()

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

◆ getRequestType()

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

◆ isNewInput()

virtual bool nidas::core::IOChannel::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 in nidas::core::DatagramSocket, nidas::core::FileSet, nidas::core::McSocket, nidas::core::McSocketUDP, nidas::core::Socket, and nidas::core::UnixIOChannel.

Referenced by nidas::core::IOStream::read(), nidas::core::IOStream::read(), and nidas::core::IOStream::readUntil().

◆ isNonBlocking()

virtual bool nidas::core::IOChannel::isNonBlocking ( ) const
pure virtual

◆ operator=()

IOChannel & nidas::core::IOChannel::operator= ( const IOChannel & rhs)
inline

References _dsm.

◆ read()

virtual size_t nidas::core::IOChannel::read ( void * buf,
size_t len )
pure virtual

Physical read method which must be implemented in derived classes.

Returns the number of bytes written, which may be less than the number requested.

Exceptions
nidas::util::IOException

Implemented in nidas::core::McSocket, nidas::core::McSocketUDP, nidas::core::MultipleUDPSockets, nidas::core::ServerSocket, nidas::core::DatagramSocket, nidas::core::FileSet, nidas::core::Socket, and nidas::core::UnixIOChannel.

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

◆ requestConnection()

virtual void nidas::core::IOChannel::requestConnection ( IOChannelRequester * )
pure virtual

After the IOChannel is configured, a user of IOChannel calls requestConnection to get things started.

It is like opening a device, but in the case of server sockets, it just starts a thread to wait on connections. Only when the IOChannelRequester::connected() method is called back is the channel actually open and ready for IO. The IOChannel* returned by IOChannelRequester::connected may be another instance of an IOChannel.

Exceptions
nidas::util::IOException

Implemented in nidas::core::FileSet, nidas::core::UnixIOChannel, nidas::core::DatagramSocket, nidas::core::McSocket, nidas::core::McSocketUDP, nidas::core::Socket, and nidas::core::ServerSocket.

Referenced by nidas::dynld::SampleInputStream::requestConnection(), and nidas::core::SampleOutputBase::requestConnection().

◆ setConnectionInfo()

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

◆ setDSMConfig()

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

◆ setName()

virtual void nidas::core::IOChannel::setName ( const std::string & val)
pure virtual

◆ setNonBlocking()

virtual void nidas::core::IOChannel::setNonBlocking ( bool val)
pure virtual

◆ setRequestType()

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

◆ 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]

virtual size_t nidas::core::IOChannel::write ( const struct iovec * iov,
int iovcnt )
pure virtual

Physical write method which must be implemented in derived classes.

Returns the number of bytes written, which may be less than the number requested.

Exceptions
nidas::util::IOException

Implemented in nidas::core::McSocket, nidas::core::McSocketUDP, nidas::core::ServerSocket, nidas::core::DatagramSocket, nidas::core::FileSet, nidas::core::MultipleUDPSockets, nidas::core::Socket, and nidas::core::UnixIOChannel.

◆ write() [2/2]

virtual size_t nidas::core::IOChannel::write ( const void * buf,
size_t len )
pure virtual

◆ writeNidasHeader()

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

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
private

◆ _dsm

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

◆ namespaceURI

XMLCh * DOMable::namespaceURI = 0
staticprivateinherited

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