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",
"OK" << endl ) ;
219 BESDEBUG(
"standalone",
"ServerApp: initializing default commands ... " 222 BESDEBUG(
"standalone",
"OK" << endl ) ;
230 cerr <<
"Failed to initialize stand alone app" << endl ;
235 BESDEBUG(
"standalone",
"StandAloneApp: initialized settings:" 249 _client->
setOutput( _outputStrm,
true ) ;
255 BESDEBUG(
"standalone",
"OK" << endl ) ;
264 BESDEBUG(
"standalone",
"FAILED" << endl ) ;
265 cerr <<
"error starting the client" << endl ;
276 else if( _inputStrm )
287 cerr <<
"error processing commands" << endl ;
293 BESDEBUG(
"standalone",
"StandAloneApp: shutting down client ... " 300 BESDEBUG(
"standalone",
"OK" << endl ) ;
302 BESDEBUG(
"standalone",
"StandAloneApp: closing input stream ... " 304 if( _createdInputStrm )
306 _inputStrm->close() ;
310 BESDEBUG(
"standalone",
"OK" << endl ) ;
314 BESDEBUG(
"standalone",
"FAILED" << endl ) ;
315 cerr <<
"error closing the client" << endl ;
331 BESDEBUG(
"standalone",
"ServerApp: terminating default module ... " 334 BESDEBUG(
"standalone",
"OK" << endl ) ;
336 BESDEBUG(
"standalone",
"ServerApp: terminating default commands ... " 339 BESDEBUG(
"standalone",
"OK" << endl ) ;
358 << (
void *)
this <<
")" << endl ;
364 _client->
dump( strm ) ;
372 strm <<
BESIndent::LMarg <<
"output stream: " << (
void *)_outputStrm << endl ;
373 strm <<
BESIndent::LMarg <<
"input stream: " << (
void *)_inputStrm << endl ;
374 strm <<
BESIndent::LMarg <<
"created input stream? " << _createdInputStrm << endl ;
383 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.
virtual void dump(ostream &strm) const
dumps information about this object
static int initialize(int argc, char **argv)
virtual int main(int argC, char **argV)
main method of the BES application
virtual void dump(ostream &strm) const
dumps information about this object
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.
virtual string get_message()
get the error message for this exception
virtual void dump(ostream &strm) const
dumps information about this object
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)
Base application object for all BES applications.
virtual int initialize(int argC, char **argV)
Load and initialize any BES modules.
string appName(void) const
Returns the name of the application.
virtual int terminate(int sig=0)
clean up after the application
static int initialize(int argc, char **argv)
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream