bes  Updated for version 3.20.6
CmdClient Class Reference

#include <CmdClient.h>

Collaboration diagram for CmdClient:
Collaboration graph

Public Member Functions

void brokenPipe ()
 inform the server that there has been a borken pipe More...
 
virtual void dump (std::ostream &strm) const
 dumps information about this object More...
 
bool executeClientCommand (const std::string &cmd)
 Executes a client side command. More...
 
bool executeCommands (const std::string &cmd, int repeat)
 Send the command(s) specified to the BES server after wrapping in request document. More...
 
bool executeCommands (std::ifstream &inputFile, int repeat)
 Sends the xml request document from the specified file to the server. More...
 
bool interact ()
 An interactive BES client that takes BES requests on the command line. More...
 
bool isConnected ()
 return whether the client is connected to the BES More...
 
void setOutput (std::ostream *strm, bool created)
 Set the output stream for responses from the BES server. More...
 
void shutdownClient ()
 Closes the connection to the OpeNDAP server and closes the output stream. More...
 
void startClient (const std::string &host, int portVal, int timeout)
 Connect the BES client to the BES server. More...
 
void startClient (const std::string &unixSocket, int timeout)
 Connect the BES client to the BES server using the unix socket. More...
 

Detailed Description

CmdClient is an object that handles the connection to, sending requests to, and receiving response from a specified OpenDAP server running either on this machine or another machine.

Requests to the OpenDAP server can be taken in different ways by the CmdClient object.

  • One request, ending with a semicolon.
  • Multiple requests, each ending with a semicolon.
  • Requests listed in a file, each request can span multiple lines in the file and there can be more than one request per line. Each request ends with a semicolon.
  • Interactive mode where the user inputs requests on the command line, each ending with a semicolon, with multiple requests allowed per line.

Response from the requests can sent to any File or OutputStream as specified by using the setOutput methods. If no output is specified using the setOutput methods thent he output is ignored.

Thread safety of this object has not yet been determined.

Author
Patrick West <A * HREF="mailto:pwest@hao.ucar.edu">pwest.nosp@m.@hao.nosp@m..ucar.nosp@m..edu

Definition at line 71 of file CmdClient.h.

Member Function Documentation

◆ brokenPipe()

void CmdClient::brokenPipe ( )

inform the server that there has been a borken pipe

Definition at line 553 of file CmdClient.cc.

◆ dump()

void CmdClient::dump ( std::ostream &  strm) const
virtual

dumps information about this object

Displays the pointer value of this instance

Parameters
strmC++ i/o stream to dump the information to

Implements BESObj.

Definition at line 564 of file CmdClient.cc.

◆ executeClientCommand()

bool CmdClient::executeClientCommand ( const std::string &  cmd)

Executes a client side command.

Client side commands include client suppress; client output to screen; client output to <filename>; client load <filename>;

Parameters
cmdThe BES client side command to execute
See also
BESError

Definition at line 198 of file CmdClient.cc.

◆ executeCommands() [1/2]

bool CmdClient::executeCommands ( const std::string &  cmd,
int  repeat 
)

Send the command(s) specified to the BES server after wrapping in request document.

This takes a string command or set of string commands from the command line, builds an xml document with the commands, and sends it to the server.

The response is written to the output stream if one is specified, otherwise the output is ignored.

Parameters
cmd_listThe BES commands to send to the BES server
repeatNumber of times to repeat the command
Exceptions
BESErrorThrown if there is a problem sending any of the request to the server or a problem receiving any of the responses from the server.
See also
BESError

Definition at line 350 of file CmdClient.cc.

◆ executeCommands() [2/2]

bool CmdClient::executeCommands ( std::ifstream &  inputFile,
int  repeat 
)

Sends the xml request document from the specified file to the server.

The file can contain only one xml request document and must be well formatted. If not, the server will respond with an exception

The response is written to the output stream if one is specified, otherwise the output is ignored.

Parameters
istrmThe file holding the xml request document
repeatNumber of times to repeat the series of commands from the file.
Exceptions
BESErrorThrown if there is a problem opening the file to read, reading the request document from the file, sending the request document to the server or a problem receiving any of the responses from the server.
See also
File
BESError

Definition at line 391 of file CmdClient.cc.

◆ interact()

bool CmdClient::interact ( )

An interactive BES client that takes BES requests on the command line.

The commands specified interactively are the old style command syntax, not xml documents.

There can be more than one command per line, but commands cannot span multiple lines. The user will be prompted to enter a new BES request.

OpenDAPClient:

The response is written to the output stream if one is specified, otherwise the output is ignored.

Exceptions
BESErrorThrown if there is a problem sending any of the requests to the server or a problem receiving any of the responses from the server.
See also
BESError

Definition at line 430 of file CmdClient.cc.

◆ isConnected()

bool CmdClient::isConnected ( )

return whether the client is connected to the BES

Returns
whether the client is connected (true) or not (false)

Definition at line 545 of file CmdClient.cc.

◆ setOutput()

void CmdClient::setOutput ( std::ostream *  strm,
bool  created 
)

Set the output stream for responses from the BES server.

Specify where the response output from your BES request will be sent. Set to null if you wish to ignore the response from the BES server.

Parameters
strman OutputStream specifying where to send responses from the BES server. If null then the output will not be output but will be thrown away.
createdtrue of the passed stream was created and can be deleted either by being replaced ro in the destructor
Exceptions
BESErrorcatches any problems with opening or writing to the output stream and creates a BESError
See also
OutputStream
BESError

Definition at line 174 of file CmdClient.cc.

◆ shutdownClient()

void CmdClient::shutdownClient ( )

Closes the connection to the OpeNDAP server and closes the output stream.

Exceptions
BESErrorThrown if unable to close the connection or close the output stream. machine given the specified port.
See also
OutputStream
BESError

Definition at line 153 of file CmdClient.cc.

◆ startClient() [1/2]

void CmdClient::startClient ( const std::string &  host,
int  portVal,
int  timeout 
)

Connect the BES client to the BES server.

Connects to the BES server on the specified machine listening on the specified port.

Parameters
hostThe name of the host machine where the server is running.
portValThe port on which the server on the host hostStr is listening for requests.
timeoutNumber of times to try an un-blocked read
Exceptions
BESErrorThrown if unable to connect to the specified host machine given the specified port.
See also
BESError

Definition at line 124 of file CmdClient.cc.

◆ startClient() [2/2]

void CmdClient::startClient ( const std::string &  unixSocket,
int  timeout 
)

Connect the BES client to the BES server using the unix socket.

Connects to the BES server using the specified unix socket

Parameters
unixStrFull path to the unix socket
timeoutNumber of times to try an un-blocked read
Exceptions
BESErrorThrown if unable to connect to the BES server
See also
BESError

Definition at line 139 of file CmdClient.cc.


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