FreeNOS
|
Generic application. More...
#include <Application.h>
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... | |
ArgumentParser & | parser () |
Get program arguments parser. More... | |
const ArgumentParser & | parser () const |
Get constant program arguments parser. More... | |
const ArgumentContainer & | arguments () 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... | |
Generic application.
Definition at line 38 of file Application.h.
enum Application::Result |
Result codes.
Enumerator | |
---|---|
Success | |
NotFound | |
IOError | |
InvalidArgument | |
ShowUsage | |
TimedOut | |
OutOfMemory |
Definition at line 53 of file Application.h.
Application::Application | ( | int | argc, |
char ** | argv | ||
) |
Class constructor.
Definition at line 20 of file Application.cpp.
References m_argc, m_argv, m_parser, and ArgumentParser::registerFlag().
|
virtual |
Class destructor.
Definition at line 29 of file Application.cpp.
|
protected |
Get program arguments.
Definition at line 112 of file Application.cpp.
References m_arguments.
Referenced by NetPing::exec(), Decompress::exec(), Init::exec(), Login::exec(), ListFiles::exec(), FileStatus::exec(), SievePrime::exec(), Remove::exec(), Echo::exec(), MakeNode::exec(), Shutdown::exec(), Sleep::exec(), Mount::exec(), CreateFile::exec(), UnixName::exec(), SysControl::exec(), Shell::exec(), NetCat::exec(), Cat::exec(), MpiPrime::exec(), NetSend::exec(), BootImageCreate::exec(), DhcpClient::exec(), NetCat::initialize(), Cat::initialize(), NetSend::initialize(), MpiProxy::initialize(), DhcpClient::initialize(), ListFiles::printFiles(), ListFiles::printSingleFile(), and SievePrime::reportResult().
|
protectedpure virtual |
Execute the application event loop.
Implemented in DhcpClient, MpiProxy, BootImageCreate, NetSend, MpiPing, MpiPrime, Cat, NetCat, NetCtl, Shell, SysInfo, SysControl, BenchMark, Decompress, Echo, Hostname, Init, Login, ListFiles, MakeNode, Mount, SievePrime, Remove, Shutdown, Sleep, FileStatus, CreateFile, UnixName, NetPing, and ProcessList.
Referenced by run().
|
protectedvirtual |
|
protectedpure virtual |
Print text to output.
string | Text to print to program output. |
Implemented in BootImageCreate, and POSIXApplication.
|
protectedvirtual |
Print string to output.
string | Reference to string to output. |
Definition at line 97 of file Application.cpp.
References output().
|
protected |
Get program arguments parser.
Definition at line 102 of file Application.cpp.
References m_parser.
Referenced by BenchMark::BenchMark(), BootImageCreate::BootImageCreate(), Cat::Cat(), Cat::cat(), CreateFile::CreateFile(), Decompress::Decompress(), DhcpClient::DhcpClient(), Echo::Echo(), BootImageCreate::exec(), FileStatus::FileStatus(), Hostname::Hostname(), Init::Init(), ListFiles::ListFiles(), Login::Login(), MakeNode::MakeNode(), Mount::Mount(), MpiPing::MpiPing(), MpiPrime::MpiPrime(), MpiProxy::MpiProxy(), NetCat::NetCat(), NetCtl::NetCtl(), NetPing::NetPing(), NetSend::NetSend(), ProcessList::ProcessList(), BootImageCreate::readBootSymbols(), Remove::Remove(), Shell::Shell(), Shutdown::Shutdown(), SievePrime::SievePrime(), Sleep::Sleep(), SysControl::SysControl(), SysInfo::SysInfo(), and UnixName::UnixName().
|
protected |
Get constant program arguments parser.
|
virtual |
Run the application.
Definition at line 38 of file Application.cpp.
References Log::Debug, exec(), ExitFailure, ExitSuccess, ArgumentContainer::get(), initialize(), WeakSingleton< Log >::instance(), m_argc, m_arguments, m_argv, m_parser, m_version, output(), ArgumentParser::parse(), Log::setMinimumLogLevel(), ArgumentParser::setName(), ShowUsage, ArgumentParser::Success, Success, and usage().
Referenced by main().
|
protected |
Set program version.
version | Program version string |
Definition at line 117 of file Application.cpp.
References m_version.
Referenced by POSIXApplication::POSIXApplication().
|
private |
Print usage and terminate.
Definition at line 91 of file Application.cpp.
References ArgumentParser::getUsage(), m_parser, and output().
Referenced by run().
|
staticprivate |
Exit code for failure termination.
Definition at line 46 of file Application.h.
Referenced by run().
|
staticprivate |
Exit code for successful termination.
Definition at line 43 of file Application.h.
Referenced by run().
|
protected |
Input argument count.
Definition at line 157 of file Application.h.
Referenced by Application(), and run().
|
private |
Parsed Arguments.
Definition at line 168 of file Application.h.
Referenced by arguments(), and run().
|
protected |
Input argument values.
Definition at line 160 of file Application.h.
Referenced by Application(), and run().
|
private |
Program argument parser object.
Definition at line 165 of file Application.h.
Referenced by Application(), parser(), run(), and usage().
|
private |
Program version.
Definition at line 171 of file Application.h.
Referenced by run(), and setVersion().