61 _createdInputStrm( false ),
76 StandAloneApp::showVersion()
78 cout <<
appName() <<
": version 2.0" << endl ;
82 StandAloneApp::showUsage( )
85 cout <<
appName() <<
": the following flags are available:" << endl ;
86 cout <<
" -c <configFile> - specifies a BES configuration file to use" << endl ;
87 cout <<
" -x <command> - specifies a command for the server to execute" << endl ;
88 cout <<
" -i <inputFile> - specifies a file name for a sequence of input commands" << endl ;
89 cout <<
" -f <outputFile> - specifies a file name to output the results of the input" << endl ;
90 cout <<
" -d - sets the optional debug flag for the client session" << endl ;
91 cout <<
" -r <num> - repeat the command(s) num times" << endl ;
92 cout <<
" -? - display this list of flags" << endl ;
102 string outputStr =
"" ;
103 string inputStr =
"" ;
104 string repeatStr =
"" ;
106 bool badUsage = false ;
110 while( ( c = getopt( argc, argv,
"?vc:d:x:f:i:r:" ) ) != EOF )
147 if( outputStr !=
"" )
149 if( _cmd ==
"" && inputStr ==
"" )
151 cerr <<
"When specifying an output file you must either "
152 <<
"specify a command or an input file"
156 else if( _cmd !=
"" && inputStr !=
"" )
158 cerr <<
"You must specify either a command or an input file on "
159 <<
"the command line, not both"
165 if( badUsage ==
true )
171 if( outputStr !=
"" )
173 _outputStrm =
new ofstream( outputStr.c_str() ) ;
174 if( !(*_outputStrm) )
176 cerr <<
"could not open the output file " << outputStr << endl ;
183 _inputStrm =
new ifstream( inputStr.c_str() ) ;
186 cerr <<
"could not open the input file " << inputStr << endl ;
189 _createdInputStrm = true ;
192 if( !repeatStr.empty() )
194 _repeat = atoi( repeatStr.c_str() ) ;
195 if( !_repeat && repeatStr !=
"0" )
197 cerr <<
"repeat number invalid: " << repeatStr << endl ;
206 if( badUsage ==
true )
214 BESDEBUG(
"standalone",
"ServerApp: initializing default module ... "
217 BESDEBUG(
"standalone",
"ServerApp: done initializing default module"
220 BESDEBUG(
"standalone",
"ServerApp: initializing default commands ... "
223 BESDEBUG(
"standalone",
"ServerApp: done initializing default commands"
226 BESDEBUG(
"standalone",
"ServerApp: initializing loaded modules ... "
229 BESDEBUG(
"standalone",
"ServerApp: done initializing loaded modules"
236 cerr <<
"Failed to initialize stand alone app" << endl ;
241 BESDEBUG(
"standalone",
"StandAloneApp: initialized settings:"
255 _client->
setOutput( _outputStrm,
true ) ;
261 BESDEBUG(
"standalone",
"OK" << endl ) ;
270 BESDEBUG(
"standalone",
"FAILED" << endl ) ;
271 cerr <<
"error starting the client" << endl ;
282 else if( _inputStrm )
293 cerr <<
"error processing commands" << endl ;
299 BESDEBUG(
"standalone",
"StandAloneApp: shutting down client ... "
306 BESDEBUG(
"standalone",
"OK" << endl ) ;
308 BESDEBUG(
"standalone",
"StandAloneApp: closing input stream ... "
310 if( _createdInputStrm )
312 _inputStrm->close() ;
316 BESDEBUG(
"standalone",
"OK" << endl ) ;
320 BESDEBUG(
"standalone",
"FAILED" << endl ) ;
321 cerr <<
"error closing the client" << endl ;
337 BESDEBUG(
"standalone",
"ServerApp: terminating loaded modules ... "
340 BESDEBUG(
"standalone",
"ServerApp: done terminating loaded modules"
343 BESDEBUG(
"standalone",
"ServerApp: terminating default commands ... "
346 BESDEBUG(
"standalone",
"ServerApp: done terminating default commands"
349 BESDEBUG(
"standalone",
"ServerApp: terminating default module ... "
352 BESDEBUG(
"standalone",
"ServerApp: done terminating default module"
370 << (
void *)
this <<
")" << endl ;
376 _client->
dump( strm ) ;
384 strm <<
BESIndent::LMarg <<
"output stream: " << (
void *)_outputStrm << endl ;
385 strm <<
BESIndent::LMarg <<
"input stream: " << (
void *)_inputStrm << endl ;
386 strm <<
BESIndent::LMarg <<
"created input stream? " << _createdInputStrm << endl ;
395 return app.
main( argc, argv ) ;
void executeCommands(const string &cmd_list, int repeat)
Send the command(s) specified to the BES server after wrapping in request document.
virtual int run()
the applications functionality is implemented in the run method
void setOutput(ostream *strm, bool created)
Set the output stream for responses from the BES server.
static void SetUp(const string &values)
Sets up debugging for the bes.
static int initialize(int argc, char **argv)
virtual void dump(ostream &strm) const
dumps information about this object
virtual int main(int argC, char **argV)
main method of the BES application
static int terminate(void)
virtual int terminate(int sig=0)
clean up after the application
StandAloneClient 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.
static int terminate(void)
Removes the default set of BES XML commands from the list of possible commands.
string appName(void) const
Returns the name of the application.
virtual string get_message()
get the error message for this exception
virtual int initialize(int argC, char **argV)
Load and initialize any BES modules.
static int initialize(int argc, char **argv)
Loads the default set of BES XML commands.
Abstract exception class for the BES with basic string message.
void interact()
An interactive BES client that takes BES requests on the command line.
static void Help(ostream &strm)
Writes help information for so that developers know what can be set for debugging.
static int terminate(void)
static ostream & LMarg(ostream &strm)
virtual void dump(ostream &strm) const
dumps information about this object
Base application object for all BES applications.
virtual int initialize(int argC, char **argV)
Load and initialize any BES modules.
virtual int terminate(int sig=0)
clean up after the application
static int initialize(int argc, char **argv)
virtual void dump(ostream &strm) const
dumps information about this object
int main(int argc, char **argv)
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream