nidas  v1.2-1520
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
nidas::dynld::psql::PSQLChannel Class Referenceabstract

#include <PSQLChannel.h>

Inheritance diagram for nidas::dynld::psql::PSQLChannel:
Inheritance graph
[legend]

Public Member Functions

 PSQLChannel ()
 
 PSQLChannel (const PSQLChannel &)
 Copy constructor. More...
 
virtual ~PSQLChannel ()
 
PSQLChannelclone () const
 Clone method. More...
 
void setName (const std::string &val)
 
const std::string & getName () const
 
void requestConnection (ConnectionRequester *) throw (nidas::util::IOException)
 
IOChannelconnect () throw (nidas::util::IOException)
 Establish a connection. More...
 
size_t read (void *buf, size_t len) throw (nidas::util::IOException)
 Read method (not used). More...
 
size_t write (const void *buf, size_t len) throw (nidas::util::IOException)
 Write method. More...
 
void flush () throw (nidas::util::IOException)
 Default flush implementation does nothing. More...
 
void close () throw (nidas::util::IOException)
 
int getFd () const
 
void setHost (const std::string &val)
 
const std::string & getHost () const
 
void setDBName (const std::string &val)
 
const std::string & getDBName () const
 
void setUser (const std::string &val)
 
const std::string & getUser () const
 
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 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...
 
virtual void requestConnection (IOChannelRequester *)=0 throw (nidas::util::IOException)
 After the IOChannel is configured, a user of IOChannel calls requestConnection to get things started. More...
 
virtual int getReconnectDelaySecs () const
 
virtual void setNonBlocking (bool val)=0 throw (nidas::util::IOException)
 
virtual bool isNonBlocking () const =0 throw (nidas::util::IOException)
 
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 size_t write (const struct iovec *iov, int iovcnt)=0 throw (nidas::util::IOException)
 Physical write method which must be implemented in derived classes. 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

void connectDatabase ()
 

Protected Attributes

std::string name
 
std::string host
 
std::string dbname
 
std::string user
 
PGconn * _conn
 Database connection pointer. More...
 
char * lastCommand
 
size_t lastNchars
 

Constructor & Destructor Documentation

PSQLChannel::PSQLChannel ( )

Referenced by clone().

PSQLChannel::PSQLChannel ( const PSQLChannel x)

Copy constructor.

PSQLChannel::~PSQLChannel ( )
virtual

References _conn, and lastCommand.

Member Function Documentation

PSQLChannel * PSQLChannel::clone ( ) const
virtual

Clone method.

Implements nidas::core::IOChannel.

References PSQLChannel().

Referenced by connect().

void PSQLChannel::close ( )
throw (nidas::util::IOException
)
virtual
IOChannel * PSQLChannel::connect ( )
throw (nidas::util::IOException
)
virtual

Establish a connection.

On return, the connection has been established. It may return a new instance of an IOChannel.

Implements nidas::core::IOChannel.

References clone(), connectDatabase(), and DLOG.

Referenced by nidas::dynld::psql::PSQLSampleOutput::connect().

void PSQLChannel::connectDatabase ( )
protected

References _conn, getDBName(), getHost(), getName(), and getUser().

Referenced by connect().

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
void PSQLChannel::flush ( )
throw (nidas::util::IOException
)
virtual

Default flush implementation does nothing.

Reimplemented from nidas::core::IOChannel.

References _conn, getName(), and lastCommand.

Referenced by close(), and nidas::dynld::psql::PSQLSampleOutput::flush().

void PSQLChannel::fromDOMElement ( const xercesc::DOMElement *  )
throw (nidas::util::InvalidParameterException
)
virtual

Initialize myself from a xercesc::DOMElement.

Implements nidas::core::DOMable.

References nidas::core::XDOMAttr::getName(), nidas::util::Logger::log(), and LOG_INFO.

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

const std::string& nidas::dynld::psql::PSQLChannel::getDBName ( ) const
inline

Referenced by connectDatabase().

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::dynld::psql::PSQLChannel::getFd ( ) const
inlinevirtual
const std::string& nidas::dynld::psql::PSQLChannel::getHost ( ) const
inline

Referenced by connectDatabase().

const std::string& nidas::dynld::psql::PSQLChannel::getName ( ) const
inlinevirtual

Implements nidas::core::IOChannel.

Referenced by connectDatabase(), and flush().

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
const std::string& nidas::dynld::psql::PSQLChannel::getUser ( ) const
inline

Referenced by connectDatabase().

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

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

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

virtual bool nidas::core::IOChannel::isNonBlocking ( ) const
throw (nidas::util::IOException
)
pure virtualinherited
size_t nidas::dynld::psql::PSQLChannel::read ( void *  buf,
size_t  len 
)
throw (nidas::util::IOException
)
inlinevirtual

Read method (not used).

Implements nidas::core::IOChannel.

void nidas::dynld::psql::PSQLChannel::requestConnection ( ConnectionRequester *  )
throw (nidas::util::IOException
)
virtual void nidas::core::IOChannel::requestConnection ( IOChannelRequester )
throw (nidas::util::IOException
)
pure virtualinherited

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.

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

Referenced by nidas::dynld::XMLConfigService::schedule().

virtual void nidas::core::IOChannel::setConnectionInfo ( const ConnectionInfo val)
inlinevirtualinherited
void PSQLChannel::setDBName ( const std::string &  val)

References dbname, host, setName(), and user.

virtual void nidas::core::IOChannel::setDSMConfig ( const DSMConfig val)
inlinevirtualinherited
void PSQLChannel::setHost ( const std::string &  val)

References dbname, host, setName(), and user.

void nidas::dynld::psql::PSQLChannel::setName ( const std::string &  val)
inlinevirtual

Implements nidas::core::IOChannel.

Referenced by setDBName(), setHost(), and setUser().

virtual void nidas::core::IOChannel::setNonBlocking ( bool  val)
throw (nidas::util::IOException
)
pure virtualinherited
virtual void nidas::core::IOChannel::setRequestType ( enum McSocketRequest  )
inlinevirtualinherited
void PSQLChannel::setUser ( const std::string &  val)

References dbname, host, setName(), and user.

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 PSQLChannel::write ( const void *  buf,
size_t  len 
)
throw (nidas::util::IOException
)
virtual

Write method.

Sends SQL command to DB.

Implements nidas::core::IOChannel.

References len.

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

Physical write method which must be implemented in derived classes.

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

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

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

PGconn* nidas::dynld::psql::PSQLChannel::_conn
protected

Database connection pointer.

Referenced by close(), connectDatabase(), flush(), and ~PSQLChannel().

std::string nidas::dynld::psql::PSQLChannel::dbname
protected

Referenced by setDBName(), setHost(), and setUser().

std::string nidas::dynld::psql::PSQLChannel::host
protected

Referenced by setDBName(), setHost(), and setUser().

char* nidas::dynld::psql::PSQLChannel::lastCommand
protected

Referenced by flush(), and ~PSQLChannel().

size_t nidas::dynld::psql::PSQLChannel::lastNchars
protected
std::string nidas::dynld::psql::PSQLChannel::name
protected
std::string nidas::dynld::psql::PSQLChannel::user
protected

Referenced by setDBName(), setHost(), and setUser().


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