Generic Application. More...
#include <rapplication.h>
Public Member Functions | |
RApplication (const RString &name, int argc, char **argv, const RString &localconfig=RString::Null, const RString &globalconfig=RString::Null) | |
RApplication (const RString &name, const RString &localconfig=RString::Null, const RString &globalconfig=RString::Null) | |
void | ParseArguments (int argc, char **argv) |
RString | GetName (void) const |
RString | GetApplicationFile (void) const |
bool | IsInit (void) const |
RString | GetLocalConfigDir (void) const |
RConfig * | GetConfig (void) |
RCursor< RString > | GetArgs (void) const |
bool | GetParamValue (const RString &name, RString &value) const |
RCursor< RParamValue > | GetParams (void) const |
void | Execute (void) |
virtual | ~RApplication (void) |
Protected Member Functions | |
virtual void | CreateConfig (void) |
virtual void | Init (void) |
Protected Attributes | |
RString | Name |
RString | File |
RContainer< RString, true, false > | Args |
RContainer< RParamValue, true, false > | Params |
RString | LocalConfigDir |
RConfig | Config |
Private Member Functions | |
virtual void | Run (void) |
Private Attributes | |
bool | HasInitApp |
Detailed Description
Generic Application.
The RApplication class provides a representation for a generic application. It defines a configuration file (stored in "~/.r/config/app") that can eventually have a template (stored in "/usr/r/config/app"). It manages also arguments on the form: "--argwithoutvalue" or "--argwithvalue value".
In practice, the important methods are CreateConfig(void) to create some configuration parameters, Init(void) to initialize the application (for example to allocate some structures) and Run(void) that contains the code to execute. Here is an example:
Constructor & Destructor Documentation
RApplication | ( | const RString & | name, |
int | argc, | ||
char ** | argv, | ||
const RString & | localconfig = RString::Null , |
||
const RString & | globalconfig = RString::Null |
||
) |
Construct an application. If both parameters 'localconfig' and 'globalconfig' are null (or not specified), the default directories are chosen.
- Parameters
-
name Name of the application. argc Number of arguments of the program (received from main). argv Arguments of the program (received from main). localconfig Local configuration. globalconfig Local configuration.
RApplication | ( | const RString & | name, |
const RString & | localconfig = RString::Null , |
||
const RString & | globalconfig = RString::Null |
||
) |
Construct an application. If both parameters 'localconfig' and 'globalconfig' are null (or not specified), the default directories are chosen.
This constructor doesn't analyzed the parameter passed to the program throught the main function. The method RApplication::ParseArguments should be manually called if parameters must be parsed.
- Parameters
-
name Name of the application. localconfig Local configuration. globalconfig Local configuration.
|
virtual |
Destructor of the application. By default, the configuration is saved.
Member Function Documentation
void ParseArguments | ( | int | argc, |
char ** | argv | ||
) |
Parse the arguments.
- Parameters
-
argc Number of arguments of the program (received from main). argv Arguments of the program (received from main).
RString GetName | ( | void | ) | const |
Get the name of the application.
RString GetApplicationFile | ( | void | ) | const |
Get the name of the file representing the executable.
bool IsInit | ( | void | ) | const |
Look if the application was initialized (call 'Init()' method).
RString GetLocalConfigDir | ( | void | ) | const |
- Returns
- the directory where the local configuration is stored.
RConfig* GetConfig | ( | void | ) |
Get a pointer over the configuration.
Get the value of a parameter passed as argument to program. Suppose the following program launch:
These parameters can be treated with the code:
- Parameters
-
name Name of the parameter. value The value of the parameter. It can be RString::Null if no value is associated.
- Returns
- true if the parameter was found.
RCursor<RParamValue> GetParams | ( | void | ) | const |
- Returns
- a cursor on the parameters.
|
protectedvirtual |
Create the configuration structure. New parameters can be added by defining a new method.
Reimplemented in QRGUIApplication.
|
protectedvirtual |
Initialize the application. By default, it create the configuration structure and load the configuration file.
|
privatevirtual |
Run the application.
void Execute | ( | void | ) |
Execute the application. In practice, it initializes the application if necessary, and then calls the Run() method.
Field Documentation
|
protected |
Name of the application.
|
protected |
Name of executable file.
|
protected |
Arguments of the application.
|
protected |
Parameters of the application.
|
protected |
Local directory of the configuration.
|
protected |
Configuration
|
private |
Application initialized?