FreeNOS
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes
Application Class Referenceabstract

Generic application. More...

#include <Application.h>

Inheritance diagram for Application:
BootImageCreate POSIXApplication BenchMark Cat CreateFile Decompress DhcpClient Echo FileStatus Hostname Init ListFiles Login MakeNode Mount MpiPing MpiProxy NetCat NetCtl NetPing NetSend ProcessList Remove Shell Shutdown SievePrime Sleep SysControl SysInfo UnixName

Public Types

enum  Result {
  Success, NotFound, IOError, InvalidArgument,
  ShowUsage, TimedOut, OutOfMemory
}
 Result codes. More...
 

Public Member Functions

 Application (int argc, char **argv)
 Class constructor. More...
 
virtual ~Application ()
 Class destructor. More...
 
virtual int run ()
 Run the application. More...
 

Protected Member Functions

virtual Result initialize ()
 Initialize the application. More...
 
virtual Result exec ()=0
 Execute the application event loop. More...
 
virtual Result output (const char *string) const =0
 Print text to output. More...
 
virtual Result output (String &string) const
 Print string to output. More...
 
ArgumentParserparser ()
 Get program arguments parser. More...
 
const ArgumentParserparser () const
 Get constant program arguments parser. More...
 
const ArgumentContainerarguments () const
 Get program arguments. More...
 
void setVersion (const String &version)
 Set program version. More...
 

Protected Attributes

int m_argc
 Input argument count. More...
 
char ** m_argv
 Input argument values. More...
 

Private Member Functions

void usage () const
 Print usage and terminate. More...
 

Private Attributes

ArgumentParser m_parser
 Program argument parser object. More...
 
ArgumentContainer m_arguments
 Parsed Arguments. More...
 
String m_version
 Program version. More...
 

Static Private Attributes

static const uint ExitSuccess = 0
 Exit code for successful termination. More...
 
static const uint ExitFailure = 1
 Exit code for failure termination. More...
 

Detailed Description

Generic application.

Definition at line 38 of file Application.h.

Member Enumeration Documentation

◆ Result

Result codes.

Enumerator
Success 
NotFound 
IOError 
InvalidArgument 
ShowUsage 
TimedOut 
OutOfMemory 

Definition at line 53 of file Application.h.

Constructor & Destructor Documentation

◆ Application()

Application::Application ( int  argc,
char **  argv 
)

Class constructor.

Parameters
argcArgument count
argvArgument values

Definition at line 20 of file Application.cpp.

References m_argc, m_argv, m_parser, and ArgumentParser::registerFlag().

◆ ~Application()

Application::~Application ( )
virtual

Class destructor.

Definition at line 29 of file Application.cpp.

Member Function Documentation

◆ arguments()

const ArgumentContainer & Application::arguments ( ) const
protected

◆ exec()

virtual Result Application::exec ( )
protectedpure virtual

◆ initialize()

Application::Result Application::initialize ( )
protectedvirtual

Initialize the application.

Returns
Result code

Reimplemented in DhcpClient, MpiProxy, NetSend, MpiPing, MpiPrime, Cat, NetCat, and NetCtl.

Definition at line 33 of file Application.cpp.

References Success.

Referenced by run().

◆ output() [1/2]

virtual Result Application::output ( const char *  string) const
protectedpure virtual

Print text to output.

Parameters
stringText to print to program output.
Returns
Result code.

Implemented in BootImageCreate, and POSIXApplication.

Referenced by output(), run(), and usage().

◆ output() [2/2]

Application::Result Application::output ( String string) const
protectedvirtual

Print string to output.

Parameters
stringReference to string to output.
Returns
Result code.

Definition at line 97 of file Application.cpp.

References output().

◆ parser() [1/2]

const ArgumentParser & Application::parser ( )
protected

◆ parser() [2/2]

const ArgumentParser& Application::parser ( ) const
protected

Get constant program arguments parser.

Returns
Program arguments parser.

◆ run()

int Application::run ( )
virtual

◆ setVersion()

void Application::setVersion ( const String version)
protected

Set program version.

Parameters
versionProgram version string

Definition at line 117 of file Application.cpp.

References m_version.

Referenced by POSIXApplication::POSIXApplication().

◆ usage()

void Application::usage ( ) const
private

Print usage and terminate.

Definition at line 91 of file Application.cpp.

References ArgumentParser::getUsage(), m_parser, and output().

Referenced by run().

Field Documentation

◆ ExitFailure

const uint Application::ExitFailure = 1
staticprivate

Exit code for failure termination.

Definition at line 46 of file Application.h.

Referenced by run().

◆ ExitSuccess

const uint Application::ExitSuccess = 0
staticprivate

Exit code for successful termination.

Definition at line 43 of file Application.h.

Referenced by run().

◆ m_argc

int Application::m_argc
protected

Input argument count.

Definition at line 157 of file Application.h.

Referenced by Application(), and run().

◆ m_arguments

ArgumentContainer Application::m_arguments
private

Parsed Arguments.

Definition at line 168 of file Application.h.

Referenced by arguments(), and run().

◆ m_argv

char** Application::m_argv
protected

Input argument values.

Definition at line 160 of file Application.h.

Referenced by Application(), and run().

◆ m_parser

ArgumentParser Application::m_parser
private

Program argument parser object.

Definition at line 165 of file Application.h.

Referenced by Application(), parser(), run(), and usage().

◆ m_version

String Application::m_version
private

Program version.

Definition at line 171 of file Application.h.

Referenced by run(), and setVersion().


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