nidas v1.2.3
Classes | Public Member Functions | Static Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
nidas::core::McSocketUDP Class Reference

Implementation of an IOChannel, using nidas::util::McSocket<nidas::util::DatagramSocket> to establish a pair of communicating UDP sockets. More...

#include <McSocketUDP.h>

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

Classes

class  MyMcSocket
 

Public Member Functions

 McSocketUDP ()
 Constructor.
 
 McSocketUDP (const McSocketUDP &)
 Copy constructor.
 
 ~McSocketUDP ()
 
McSocketUDPclone () const
 Derived classes must provide clone.
 
void setRequestType (enum McSocketRequest val)
 
enum McSocketRequest getRequestType () const
 
bool isRequester () const
 Does this McSocket request connections, or does it listen for incoming connections.
 
void setRequester (bool val)
 
void setName (const std::string &val)
 
const std::string & getName () const
 
void requestConnection (IOChannelRequester *service)
 
IOChannelconnect ()
 
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 connected (nidas::util::DatagramSocket *sock, const nidas::util::Inet4PacketInfoX &pktinfo)
 
void setNonBlocking (bool val)
 Do setNonBlocking(val) on underlying socket.
 
bool isNonBlocking () const
 Return isNonBlocking() of underlying socket.
 
size_t read (void *, size_t)
 A McSocketUDP shouldn't be used to do any actual reads or writes, it just sets up the connection.
 
size_t write (const void *, size_t)
 A McSocketUDP shouldn't be used to do any actual reads or writes, it just sets up the connection.
 
size_t write (const struct iovec *, int)
 A McSocketUDP shouldn't be used to do any actual reads or writes, it just sets up the connection.
 
void close ()
 
int getFd () const
 
void fromDOMElement (const xercesc::DOMElement *)
 
void setInet4McastSocketAddress (const nidas::util::Inet4SocketAddress &val)
 
const nidas::util::Inet4SocketAddressgetInet4McastSocketAddress () 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 Attributes

IOChannelRequester_iochanRequester
 
MyMcSocket _mcsocket
 

Private Member Functions

McSocketUDPoperator= (const McSocketUDP &)
 No assignment.
 

Private Attributes

std::string _name
 
bool _amRequester
 
bool _firstRead
 
bool _newInput
 
bool _nonBlocking
 
const DSMConfig_dsm
 
ConnectionInfo _conInfo
 

Static Private Attributes

static XMLChnamespaceURI = 0
 

Detailed Description

Implementation of an IOChannel, using nidas::util::McSocket<nidas::util::DatagramSocket> to establish a pair of communicating UDP sockets.

Implementation of an IOChannel, using McSocket to establish connections

Constructor & Destructor Documentation

◆ McSocketUDP() [1/2]

McSocketUDP::McSocketUDP ( )

Constructor.

References setName().

Referenced by clone().

◆ McSocketUDP() [2/2]

McSocketUDP::McSocketUDP ( const McSocketUDP & x)

Copy constructor.

Should only be called before nidas::util::Socket is connected.

◆ ~McSocketUDP()

nidas::core::McSocketUDP::~McSocketUDP ( )
inline

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

McSocketUDP * McSocketUDP::clone ( ) const
virtual

Derived classes must provide clone.

Implements nidas::core::IOChannel.

Reimplemented in nidas::core::MultipleUDPSockets.

References McSocketUDP().

◆ close()

void McSocketUDP::close ( )
virtual

◆ connect()

IOChannel * McSocketUDP::connect ( )
virtual

◆ connected()

void McSocketUDP::connected ( nidas::util::DatagramSocket * sock,
const nidas::util::Inet4PacketInfoX & pktinfo )
virtual

◆ 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 McSocketUDP::fromDOMElement ( const xercesc::DOMElement * node)
virtual

◆ 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 McSocketUDP::getFd ( ) const
virtual

◆ getInet4McastSocketAddress()

const nidas::util::Inet4SocketAddress & nidas::core::McSocketUDP::getInet4McastSocketAddress ( ) const
inline

◆ getName()

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

◆ getNamespaceURI()

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

◆ getReconnectDelaySecs()

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

◆ getRequestType()

enum McSocketRequest nidas::core::McSocketUDP::getRequestType ( ) const
inlinevirtual

◆ isNewInput()

virtual bool nidas::core::McSocketUDP::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 nidas::core::McSocketUDP::isNonBlocking ( ) const
inlinevirtual

Return isNonBlocking() of underlying socket.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

References _nonBlocking.

Referenced by connect(), nidas::core::MultipleUDPSockets::connect(), and connected().

◆ isRequester()

bool nidas::core::McSocketUDP::isRequester ( ) const
inline

Does this McSocket request connections, or does it listen for incoming connections.

References _amRequester.

Referenced by connect(), fromDOMElement(), and requestConnection().

◆ operator=()

McSocketUDP & nidas::core::McSocketUDP::operator= ( const McSocketUDP & )
private

No assignment.

◆ read()

size_t nidas::core::McSocketUDP::read ( void * ,
size_t  )
inlinevirtual

A McSocketUDP shouldn't be used to do any actual reads or writes, it just sets up the connection.

The returned IOChannel should be used to read/write. Calling this method will fail with an assert.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

Reimplemented in nidas::core::MultipleUDPSockets.

References nidas::core::getSample().

◆ requestConnection()

void McSocketUDP::requestConnection ( IOChannelRequester * service)
virtual

◆ setConnectionInfo()

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

◆ setDSMConfig()

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

◆ setInet4McastSocketAddress()

void nidas::core::McSocketUDP::setInet4McastSocketAddress ( const nidas::util::Inet4SocketAddress & val)
inline

◆ setName()

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

◆ setNonBlocking()

void nidas::core::McSocketUDP::setNonBlocking ( bool val)
inlinevirtual

Do setNonBlocking(val) on underlying socket.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

References _nonBlocking, and nidas::core::getSample().

Referenced by fromDOMElement(), and nidas::core::MultipleUDPSockets::fromDOMElement().

◆ setRequester()

void nidas::core::McSocketUDP::setRequester ( bool val)
inline

◆ setRequestType()

void nidas::core::McSocketUDP::setRequestType ( enum McSocketRequest val)
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]

size_t nidas::core::McSocketUDP::write ( const struct iovec * ,
int  )
inlinevirtual

A McSocketUDP shouldn't be used to do any actual reads or writes, it just sets up the connection.

The returned IOChannel should be used to read/write. Calling this method will fail with an assert.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

Reimplemented in nidas::core::MultipleUDPSockets.

References nidas::core::getSample().

◆ write() [2/2]

size_t nidas::core::McSocketUDP::write ( const void * ,
size_t  )
inlinevirtual

A McSocketUDP shouldn't be used to do any actual reads or writes, it just sets up the connection.

The returned IOChannel should be used to read/write. Calling this method will fail with an assert.

Exceptions
nidas::util::IOException

Implements nidas::core::IOChannel.

Reimplemented in nidas::core::MultipleUDPSockets.

References nidas::core::getSample().

◆ 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

◆ _amRequester

bool nidas::core::McSocketUDP::_amRequester
private

Referenced by isRequester(), and setRequester().

◆ _conInfo

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

◆ _dsm

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

◆ _firstRead

bool nidas::core::McSocketUDP::_firstRead
private

◆ _iochanRequester

IOChannelRequester* nidas::core::McSocketUDP::_iochanRequester
protected

Referenced by connected(), and requestConnection().

◆ _mcsocket

MyMcSocket nidas::core::McSocketUDP::_mcsocket
protected

◆ _name

std::string nidas::core::McSocketUDP::_name
private

Referenced by getName(), and setName().

◆ _newInput

bool nidas::core::McSocketUDP::_newInput
private

Referenced by isNewInput().

◆ _nonBlocking

bool nidas::core::McSocketUDP::_nonBlocking
private

Referenced by isNonBlocking(), and setNonBlocking().

◆ namespaceURI

XMLCh * DOMable::namespaceURI = 0
staticprivateinherited

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