Otawa  0.10
otawa::Application Class Reference

A class making easier the use of applications built on OTAWA. More...

#include <otawa/app/Application.h>

Inheritance diagram for otawa::Application:
elm::option::Manager

Public Types

typedef const char *const * argv_t
 

Public Member Functions

 Application (cstring _program, Version _version=Version::ZERO, cstring _description="", cstring _author="", cstring _copyright="")
 Build the application. More...
 
virtual ~Application (void)
 
int run (int argc, char **argv)
 Run the application: More...
 
void addOption (Option *option)
 
void removeOption (Option *option)
 
void parse (int argc, argv_t argv)
 
void displayHelp (void)
 
cstring getProgram (void) const
 
const VersiongetVersion (void) const
 
cstring getAuthor (void) const
 
cstring getCopyright (void) const
 
cstring getDescription (void) const
 
cstring getFreeArgumentDescription (void) const
 

Protected Member Functions

virtual void prepare (PropList &props)
 This method may be overriden by the child class in order to customize the building of configuration property list. More...
 
virtual void work (PropList &props) throw (elm::Exception)
 This method must be overriden to implement the action of the application. More...
 
virtual void work (const string &entry, PropList &props) throw (elm::Exception)
 This method must be overriden to give a special behaviour for each free argument of the command line (supposed to be the tasks entry points). More...
 
WorkSpaceworkspace (void) const
 Provide the current workspace. More...
 
void require (const AbstractFeature &feature)
 Perform a require request on the current process with the current configuration property list (as configured in prepare()). More...
 
virtual void process (string arg)
 If overriden, this method allows to provide a customized behaviour to the usual processing of free arguments. More...
 
bool isVerbose (void) const
 
const genstruct::Vector< stringarguments (void) const
 
Address parseAddress (const string &s) throw (otawa::Exception)
 Parse a symbolic address and return it. More...
 
virtual void configure (int tag, VarArg &args)
 

Protected Attributes

Make info
 

Private Attributes

option::BoolOption help
 
option::BoolOption verbose
 
option::ListOption< stringsets
 
option::ListOption< stringparams
 
option::ListOption< stringff
 
LogOption log_level
 
elm::system::Path path
 
genstruct::Vector< string_args
 
PropList props
 
PropListprops2
 
int result
 
WorkSpacews
 

Detailed Description

A class making easier the use of applications built on OTAWA.

It automatically support for

  • –add-prop ID=VALUE – set a configuration property (passed to manager and other processors),
  • -f|–flowfacts PATH – select a flow fact file to load
  • -h|–help – option help display,
  • –load-param ID=VALUE – add a load parameter (passed to the manager load command)
  • -v|–verbose – verbose mode activation,
  • first argument as binary program,
  • following arguments as task entries.

Usually, it specialized according your application purpose:

class MyApp: public Application {
public:
MyApplication(void):
Application("my_application", ...),
option1(*this, ...),
option2(*this, ...)
{
...
}
protected:
void work(PropList &props) throw(elm::Exception) {
// do_something useful on the opened workspace
}
private:
MyOption1 option1;
MyOption2 option2;
...
};
OTAWA_RUN(MyApp)

Constructor & Destructor Documentation

otawa::Application::Application ( cstring  _program,
Version  _version = Version::ZERO,
cstring  _description = "",
cstring  _author = "",
cstring  _copyright = "" 
)

Build the application.

Parameters
_programProgram name.
_versionCurrent version (optional).
_descriptionDescription of the application (optional).
_authorAuthor identification.
_copyrightApplied copyright.
otawa::Application::~Application ( void  )
virtual

Member Function Documentation

const genstruct::Vector<string> otawa::Application::arguments ( void  ) const
inlineprotected
bool otawa::Application::isVerbose ( void  ) const
inlineprotected

References verbose.

Address otawa::Application::parseAddress ( const string s)
throw (otawa::Exception
)
protected

Parse a symbolic address and return it.

Parameters
sAddress string to parse.
Returns
Matching address.
Exceptions
otawa::ExceptionIf the address cannot be resolved or parsed.

References _, otawa::SymAddress::parse(), and otawa::SymAddress::toAddress().

void otawa::Application::prepare ( PropList props)
protectedvirtual

This method may be overriden by the child class in order to customize the building of configuration property list.

Parameters
propsProperty list to customize.

Referenced by run().

void otawa::Application::process ( string  arg)
protectedvirtual

If overriden, this method allows to provide a customized behaviour to the usual processing of free arguments.

Parameters
argCurrent argument.

Reimplemented from elm::option::Manager.

References _args, and path.

void otawa::Application::require ( const AbstractFeature feature)
protected

Perform a require request on the current process with the current configuration property list (as configured in prepare()).

Parameters
featureFeature to require.

References props2, otawa::WorkSpace::require(), and ws.

int otawa::Application::run ( int  argc,
char **  argv 
)
void otawa::Application::work ( PropList props)
throw (elm::Exception
)
protectedvirtual

This method must be overriden to implement the action of the application.

As a default, it call the work(string, props) method for each free argument on a command line (supposed to be a task entry).

When this method is called, the program has been already loaded.

Exceptions
elm::ExceptionFor any found error.

References otawa::TASK_ADDRESS.

Referenced by run().

void otawa::Application::work ( const string entry,
PropList props 
)
throw (elm::Exception
)
protectedvirtual

This method must be overriden to give a special behaviour for each free argument of the command line (supposed to be the tasks entry points).

As a default, do nothing.

When this method is called, the program has already been loaded and the workspace is marked as having as entry point the one passed in argument: threfore the workspace is ready for computation.

Parameters
entryTask entry point name or any free argument.
Exceptions
elm::ExceptionFor any found error.
WorkSpace * otawa::Application::workspace ( void  ) const
inlineprotected

Provide the current workspace.

Returns
Current workspace.

Member Data Documentation

genstruct::Vector<string> otawa::Application::_args
private

Referenced by process(), and run().

option::ListOption<string> otawa::Application::ff
private

Referenced by run().

option::BoolOption otawa::Application::help
private

Referenced by run().

LogOption otawa::Application::log_level
private

Referenced by run().

option::ListOption<string> otawa::Application::params
private

Referenced by run().

elm::system::Path otawa::Application::path
private

Referenced by process(), and run().

PropList otawa::Application::props
private

Referenced by run().

PropList* otawa::Application::props2
private

Referenced by require().

int otawa::Application::result
private

Referenced by run().

option::ListOption<string> otawa::Application::sets
private

Referenced by run().

option::BoolOption otawa::Application::verbose
private

Referenced by run().

WorkSpace* otawa::Application::ws
private

Referenced by require(), and run().


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