#include <basicapp.h>
Inheritance diagram for BasicApp:
Public Member Functions | |
DECLSPEC | BasicApp (int argc, char *argv[], const char *datapath=NULL, const char *debug=NULL) |
DECLSPEC | BasicApp (int argc, char *argv[], TiXmlElement *el) |
DECLSPEC int | init (TiXmlElement *el=NULL) |
virtual DECLSPEC void | destroy () |
virtual long | mainLoop () |
DECLSPEC const char * | getExePath () |
DECLSPEC const char * | getDataPath () |
DECLSPEC std::string | makeDataPath (const char *path) |
const char * | getUserdataPath () |
DECLSPEC std::string | makeUserPath (const char *path) |
int | getArgC () |
const char * | getArgV (int n) |
DECLSPEC void | exitWithMessage (const char *str) |
Static Public Member Functions | |
static DECLSPEC bool | setWorkingDir (const char *dn) |
static DECLSPEC bool | chDirToUser () |
static DECLSPEC const char * | getOSName () |
static DECLSPEC const char * | getCPUArch () |
static DECLSPEC const char * | getRunningOSName () |
static DECLSPEC const char * | getRunningOSVersion () |
static DECLSPEC const char * | getRunningOSArch () |
static DECLSPEC BasicApp * | getThe () |
Static Public Attributes | |
static BasicApp * | the |
Protected Member Functions | |
DECLSPEC void | setDataPath (const char *path) |
DECLSPEC void | setUserdataPath (const char *path) |
DECLSPEC void | onInit () |
Protected Attributes | |
int | nInitFailStatus |
Do not use two or more variables of this class at a time. But to use the netrinjo-engine, it has to be contructed once.
BasicApp is used to handle the main process and getting important paths. Only use it in a derived class and inherit mainLoop(). For better understanding of this class have a look at an example application.
BasicApp::BasicApp | ( | int | argc, | |
char * | argv[], | |||
const char * | datapath = NULL , |
|||
const char * | debug = NULL | |||
) |
Constructor
argc | number of arguments given to the app | |
argv | content of the arguments given to the app | |
datapath | the path to the data-containing directory, if NULL, the executable's directory is taken | |
debug | the filename of the log-file, if NULL, logging is not possible |
BasicApp::BasicApp | ( | int | argc, | |
char * | argv[], | |||
TiXmlElement * | el | |||
) |
Constructor, using XML data
argc | number of arguments given to the app | |
argv | content of the arguments given to the app | |
el | the XML data, the value of the Attribute "DataPath" is read and is then returned by the method getDataPath() |
int BasicApp::init | ( | TiXmlElement * | el = NULL |
) |
May be implemented in derived classes.
el | the XML data, used for initialisation (not useful, if that was already specified on creation) |
void BasicApp::destroy | ( | ) | [virtual] |
by calling destroy() the application finishes the log-file and exits with "0"
Reimplemented from BasicObject.
Reimplemented in XmlApp.
virtual long BasicApp::mainLoop | ( | ) | [inline, virtual] |
only for derived classes
Reimplemented in XmlApp.
const char * BasicApp::getExePath | ( | ) |
const char * BasicApp::getDataPath | ( | ) |
std::string BasicApp::makeDataPath | ( | const char * | path | ) |
Makes an absolute path out of a path, relative to the data containing folder. At first the method makeEnvPath() is called to replace environment expressions. Then it is checked, whether it is absolute or not. If the path is absolute, the result equals the one of makeEnvPath(), otherwise the data path is prepended.
const char* BasicApp::getUserdataPath | ( | ) | [inline] |
std::string BasicApp::makeUserPath | ( | const char * | path | ) |
Makes an absolute path out of a path, relative to the user's data containing folder. At first the method makeEnvPath() is called to replace environment expressions. Then it is checked, whether it is absolute or not. If the path is absolute, the result equals the one of makeEnvPath(), otherwise the user's data path is prepended.
int BasicApp::getArgC | ( | ) | [inline] |
const char* BasicApp::getArgV | ( | int | n | ) | [inline] |
void BasicApp::exitWithMessage | ( | const char * | str | ) |
prints an error-message with "str" to the standard-output and also writes it to the logfile then it exits by calling the "BasicApp::destroy()"-function
str | the message to print and write to the logfile |
bool BasicApp::setWorkingDir | ( | const char * | dn | ) | [static] |
sets the current working directory to "dn". if "dn" does not exist, it trys to create it
dn | the working directory to be set; may be a relative path |
bool BasicApp::chDirToUser | ( | ) | [static] |
changes the current working directory to the user's home-directory Linux usually: /home/username Windows usually: C:/Documents and Settings/username
const char * BasicApp::getOSName | ( | ) | [static] |
const char * BasicApp::getCPUArch | ( | ) | [static] |
const char * BasicApp::getRunningOSName | ( | ) | [static] |
const char * BasicApp::getRunningOSVersion | ( | ) | [static] |
const char * BasicApp::getRunningOSArch | ( | ) | [static] |
BasicApp * BasicApp::getThe | ( | ) | [static] |
void BasicApp::setDataPath | ( | const char * | path | ) | [protected] |
Sets the path to the data containing directory. The environment variable DATAPATH is also set/updated to the new value.
path | the path to set |
void BasicApp::setUserdataPath | ( | const char * | path | ) | [protected] |
Sets the path to the user specific, data containing directory. The environment variable USERPATH is also set/updated to the new value.
path | the path to set, if it starts with "~/", it is taken relative to the user's home directory |
void BasicApp::onInit | ( | ) | [protected, virtual] |
Initializes the object's variables by reading data from the XML element. If there were no XML data used for creation, nothing is done. This function calls onInit() of its children recursively (after it has inited itself). It is highly recommended to call BasicObject::onInit(), usually at the end of the onInit() method, when overwriting it in a derived class.
Reimplemented from BasicLog.
Reimplemented in XmlApp.
BasicApp * BasicApp::the [static] |
not accessible in Windows, equals the result of getThe()
int BasicApp::nInitFailStatus [protected] |
set to a number different from zero, if initialisation failed; use this in a derived class to set the return value of init()