application Class Reference

This base class models an application. More...

#include <application.h>

Inheritance diagram for application:
Inheritance graph
[legend]
Collaboration diagram for application:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 application (const string &appid)
void init (int argc, char **argv)
virtual int main (void)

Public Attributes

value argv
value env
value rsrc
value opt
string creator

Detailed Description

This base class models an application.

Provides housekeeping tasks for an application, including:

On startup, the file rsrc:grace.runoptions.xml is loaded into the opt value and rsrc:resources.xml is loaded into the rsrc value object.


Constructor & Destructor Documentation

application::application ( const string appid  ) 

Default constructor.

Loads resources, initializes.

Parameters:
appid the application-id [tld.domain.foo.app]

References creator, string::cutat(), env, file::openread(), file::openwrite(), and string::strstr().

Here is the call graph for this function:


Member Function Documentation

void application::init ( int  argc,
char **  argv 
)

Second stage initialization.

Parses commandline arguments according to the rules found in the "rsrc:grace.runoptions.xml" file. Arguments and flags defined in this rule file are filed with their proper (long format) key in the argv[] value object inside the application object. Unaccounted or extra arguments are stored as unkeyed items inside argv["*"][].

Parameters:
argc argument count
argv argument array

The layout of the a runoptions file is as follows:

 <?xml version="1.0" encoding="utf-8"?>
 <grace.runoptions>
   <grace.option id="-h">
     <grace.long>--help</grace.long>
   </grace.option>
   <grace.option id="-d">
     <grace.long>--debug</grace.long>
   </grace.option>
   <grace.option id="--help">
     <grace.argc>0</grace.argc>
     <grace.help>Show help information</grace.help>
   </grace.option>
   <grace.option id="--debug">
     <grace.argc>1</grace.argc>
     <grace.default>0</grace.default>
   </grace.option>
 </grace.runoptions>

Options with a 'short' commandline flag as their key, as a rule, only contain a reference to their long counterpart.

int application::main ( void   )  [virtual]

The main loop.

Represents the application's main loop, a concrete subclass should implement the actual application's main loop here.

Returns:
Application return value after it finished.

Reimplemented in cgi, and daemon.

References file::printf().

Here is the call graph for this function:


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

Generated on Sun Feb 28 10:35:12 2010 for GRACE by  doxygen 1.6.1