#include <llapp.h>
Inheritance diagram for LLApp:
Runtime options | |
enum | OptionPriority { PRIORITY_RUNTIME_OVERRIDE, PRIORITY_COMMAND_LINE, PRIORITY_SPECIFIC_CONFIGURATION, PRIORITY_GENERAL_CONFIGURATION, PRIORITY_DEFAULT, PRIORITY_COUNT } |
Enumeration to specify option priorities in highest to lowest order. More... | |
LLSD | getOption (const std::string &name) const |
Get the application option at the highest priority. | |
bool | parseCommandOptions (int argc, char **argv) |
Parse command line options and insert them into application command line options. | |
bool | setOptionData (OptionPriority level, LLSD data) |
Set the options at the specified priority. | |
LLSD | getOptionData (OptionPriority level) |
Get the option data at the specified priority. | |
Public Types | |
typedef enum LLApp::e_app_status | EAppStatus |
typedef std::map< std::string, std::string > | string_map |
APP_STATUS_RUNNING | |
APP_STATUS_QUITTING | |
APP_STATUS_STOPPED | |
APP_STATUS_ERROR | |
PRIORITY_RUNTIME_OVERRIDE | |
PRIORITY_COMMAND_LINE | |
PRIORITY_SPECIFIC_CONFIGURATION | |
PRIORITY_GENERAL_CONFIGURATION | |
PRIORITY_DEFAULT | |
PRIORITY_COUNT | |
enum | e_app_status { APP_STATUS_RUNNING, APP_STATUS_QUITTING, APP_STATUS_STOPPED, APP_STATUS_ERROR } |
Public Member Functions | |
LLApp () | |
virtual | ~LLApp () |
virtual bool | init ()=0 |
virtual bool | cleanup ()=0 |
virtual bool | mainLoop ()=0 |
void | setErrorHandler (LLAppErrorHandler handler) |
void | setChildCallback (pid_t pid, LLAppChildCallback callback) |
LL_WINDOWS. | |
void | setDefaultChildCallback (LLAppChildCallback callback) |
pid_t | fork () |
LLRunner & | getRunner () |
Get a reference to the application runner. | |
Static Public Member Functions | |
static LLApp * | instance () |
Return the static app instance if one was created. | |
static void | setQuitting () |
static void | setStopped () |
static void | setError () |
static bool | isStopped () |
static bool | isRunning () |
static bool | isQuitting () |
static bool | isError () |
static bool | isExiting () |
static U32 | getSigChildCount () |
static void | incSigChildCount () |
static int | getPid () |
Public Attributes | |
string_map | mOptionMap |
Static Public Attributes | |
static BOOL | sLogInSignal = FALSE |
Protected Types | |
typedef std::map< pid_t, LLChildInfo > | child_map |
Protected Member Functions | |
void | stepFrame () |
This method is called once a frame to do once a frame tasks. | |
Static Protected Member Functions | |
static void | setStatus (EAppStatus status) |
Static Protected Attributes | |
static EAppStatus | sStatus = LLApp::APP_STATUS_STOPPED |
static BOOL | sErrorThreadRunning = FALSE |
static LLAtomicU32 * | sSigChildCount = NULL |
static child_map | sChildMap |
static LLAppChildCallback | sDefaultChildCallback = NULL |
Private Types | |
typedef int(*) | signal_handler_func (int signum) |
Private Member Functions | |
void | setupErrorHandling () |
Static Private Member Functions | |
static void | runErrorHandler () |
Private Attributes | |
LLErrorThread * | mThreadErrorp |
LLRunner | mRunner |
Runtime option implementation | |
LLSD | mOptions |
Static Private Attributes | |
static LLAppErrorHandler | sErrorHandler = NULL |
static LLApp * | sApplication = NULL |
Friends | |
class | LLErrorThread |
void | default_unix_signal_handler (int signum, siginfo_t *info, void *) |
Definition at line 63 of file llapp.h.
typedef std::map<pid_t, LLChildInfo> LLApp::child_map [protected] |
typedef enum LLApp::e_app_status LLApp::EAppStatus |
typedef int(*) LLApp::signal_handler_func(int signum) [private] |
typedef std::map<std::string, std::string> LLApp::string_map |
enum LLApp::e_app_status |
LLApp::LLApp | ( | ) |
Definition at line 75 of file llapp.cpp.
References APP_STATUS_RUNNING, LLSD::append(), LLSD::emptyArray(), i, LLCommon::initClass(), mOptions, PRIORITY_COUNT, sApplication, tut::sd(), setStatus(), setupErrorHandling(), and sSigChildCount.
LLApp::~LLApp | ( | ) | [virtual] |
Definition at line 109 of file llapp.cpp.
References LLCommon::cleanupClass(), ms_sleep(), mThreadErrorp, NULL, setStopped(), and sSigChildCount.
virtual bool LLApp::cleanup | ( | ) | [pure virtual] |
Implemented in tut::application::LLTestApp.
pid_t LLApp::fork | ( | ) |
Definition at line 415 of file llapp.cpp.
References llendl, llinfos, llwarns, ms_sleep(), and setupErrorHandling().
LLSD LLApp::getOption | ( | const std::string & | name | ) | const |
Get the application option at the highest priority.
If the return value is undefined, the option does not exist.
name | The name of the option. |
Definition at line 134 of file llapp.cpp.
References LLSD::beginArray(), end, LLSD::endArray(), LLSD::isDefined(), and mOptions.
Referenced by LLServiceBuilder::buildServiceURI(), get_shared_secret(), LLError::initForServer(), and LLHTTPLiveConfigSingleService::validate().
LLSD LLApp::getOptionData | ( | OptionPriority | level | ) |
Get the option data at the specified priority.
This method is probably not so useful except when merging information.
level | The priority level of the data. |
Definition at line 191 of file llapp.cpp.
References mOptions, and PRIORITY_COUNT.
Referenced by LLHTTPConfigRuntimeSingleService::del(), LLHTTPLiveConfigService::get(), LLHTTPConfigRuntimeSingleService::get(), LLHTTPConfigRuntimeService::get(), LLHTTPConfigService::get(), LLHTTPConfigRuntimeService::post(), LLHTTPConfigRuntimeSingleService::put(), and LLHTTPConfigRuntimeSingleService::validate().
LLRunner& LLApp::getRunner | ( | ) | [inline] |
Get a reference to the application runner.
Please use the runner with caution. Since the Runner usage pattern is not yet clear, this method just gives access to it to add and remove runnables.
Definition at line 221 of file llapp.h.
References mRunner.
U32 LLApp::getSigChildCount | ( | ) | [static] |
Definition at line 330 of file llapp.cpp.
References sSigChildCount.
Referenced by LLErrorThread::run().
void LLApp::incSigChildCount | ( | ) | [static] |
Definition at line 340 of file llapp.cpp.
References sSigChildCount.
Referenced by default_unix_signal_handler().
virtual bool LLApp::init | ( | ) | [pure virtual] |
Implemented in tut::application::LLTestApp.
LLApp * LLApp::instance | ( | ) | [static] |
Return the static app instance if one was created.
Definition at line 128 of file llapp.cpp.
References sApplication.
Referenced by LLServiceBuilder::buildServiceURI(), LLHTTPConfigRuntimeSingleService::del(), LLHTTPLiveConfigSingleService::get(), LLHTTPLiveConfigService::get(), LLHTTPConfigPriorityService< PRIORITY >::get(), LLHTTPConfigRuntimeSingleService::get(), LLHTTPConfigRuntimeService::get(), LLHTTPConfigService::get(), get_shared_secret(), LLError::initForServer(), LLHTTPConfigRuntimeService::post(), LLHTTPConfigRuntimeSingleService::put(), LLHTTPLiveConfigSingleService::validate(), and LLHTTPConfigRuntimeSingleService::validate().
bool LLApp::isError | ( | ) | [static] |
Definition at line 311 of file llapp.cpp.
References APP_STATUS_ERROR, and sStatus.
Referenced by default_unix_signal_handler(), isExiting(), and LLErrorThread::run().
bool LLApp::isExiting | ( | ) | [static] |
Definition at line 323 of file llapp.cpp.
References isError(), and isQuitting().
Referenced by setQuitting().
bool LLApp::isQuitting | ( | ) | [static] |
Definition at line 318 of file llapp.cpp.
References APP_STATUS_QUITTING, and sStatus.
Referenced by default_unix_signal_handler(), and isExiting().
bool LLApp::isRunning | ( | ) | [static] |
bool LLApp::isStopped | ( | ) | [static] |
Definition at line 297 of file llapp.cpp.
References APP_STATUS_STOPPED, and sStatus.
Referenced by default_unix_signal_handler(), and LLErrorThread::run().
virtual bool LLApp::mainLoop | ( | ) | [pure virtual] |
Implemented in tut::application::LLTestApp.
bool LLApp::parseCommandOptions | ( | int | argc, | |
char ** | argv | |||
) |
Parse command line options and insert them into application command line options.
The name inserted into the option will have leading option identifiers (a minus or double minus) stripped. All options with values will be stored as a string, while all options without values will be stored as true.
Definition at line 147 of file llapp.cpp.
References LLSD::assign(), llendl, llinfos, PRIORITY_COMMAND_LINE, and setOptionData().
void LLApp::runErrorHandler | ( | ) | [static, private] |
Definition at line 251 of file llapp.cpp.
References sErrorHandler, and setStopped().
Referenced by LLErrorThread::run().
void LLApp::setChildCallback | ( | pid_t | pid, | |
LLAppChildCallback | callback | |||
) |
LL_WINDOWS.
Definition at line 403 of file llapp.cpp.
References LLChildInfo::mCallback, and sChildMap.
void LLApp::setDefaultChildCallback | ( | LLAppChildCallback | callback | ) |
void LLApp::setError | ( | ) | [static] |
Definition at line 271 of file llapp.cpp.
References APP_STATUS_ERROR, and setStatus().
Referenced by default_unix_signal_handler().
void LLApp::setErrorHandler | ( | LLAppErrorHandler | handler | ) |
bool LLApp::setOptionData | ( | OptionPriority | level, | |
LLSD | data | |||
) |
Set the options at the specified priority.
This function completely replaces the options at the priority level with the data specified. This function will make sure level and data might be valid before doing the replace.
level | The priority level of the data. | |
data | The data to set. |
Definition at line 179 of file llapp.cpp.
References mOptions, PRIORITY_COUNT, LLSD::type(), and LLSD::TypeMap.
Referenced by LLHTTPConfigRuntimeSingleService::del(), LLLiveAppConfig::loadFile(), parseCommandOptions(), LLHTTPConfigRuntimeService::post(), and LLHTTPConfigRuntimeSingleService::put().
void LLApp::setQuitting | ( | ) | [static] |
Definition at line 278 of file llapp.cpp.
References APP_STATUS_QUITTING, isExiting(), llendl, llinfos, and setStatus().
Referenced by default_unix_signal_handler().
void LLApp::setStatus | ( | EAppStatus | status | ) | [static, protected] |
Definition at line 264 of file llapp.cpp.
References sStatus.
Referenced by LLApp(), setError(), setQuitting(), and setStopped().
void LLApp::setStopped | ( | ) | [static] |
Definition at line 290 of file llapp.cpp.
References APP_STATUS_STOPPED, and setStatus().
Referenced by runErrorHandler(), and ~LLApp().
void LLApp::setupErrorHandling | ( | ) | [private] |
Definition at line 208 of file llapp.cpp.
References llendl, LLErrorThread, llinfos, mThreadErrorp, setup_signals(), LLErrorThread::setUserData(), and LLThread::start().
void LLApp::stepFrame | ( | ) | [protected] |
This method is called once a frame to do once a frame tasks.
Definition at line 200 of file llapp.cpp.
References mRunner, LLRunner::run(), LLEventTimer::updateClass(), and LLFrameTimer::updateFrameTime().
friend class LLErrorThread [friend] |
LLSD LLApp::mOptions [private] |
Definition at line 266 of file llapp.h.
Referenced by getOption(), getOptionData(), LLApp(), and setOptionData().
LLRunner LLApp::mRunner [private] |
LLErrorThread* LLApp::mThreadErrorp [private] |
LLApp * LLApp::sApplication = NULL [static, private] |
LLApp::child_map LLApp::sChildMap [static, protected] |
Definition at line 236 of file llapp.h.
Referenced by default_unix_signal_handler(), LLErrorThread::run(), and setChildCallback().
LLAppChildCallback LLApp::sDefaultChildCallback = NULL [static, protected] |
Definition at line 237 of file llapp.h.
Referenced by LLErrorThread::run(), and setDefaultChildCallback().
LLAppErrorHandler LLApp::sErrorHandler = NULL [static, private] |
BOOL LLApp::sErrorThreadRunning = FALSE [static, protected] |
Definition at line 231 of file llapp.h.
Referenced by default_unix_signal_handler(), and LLErrorThread::run().
BOOL LLApp::sLogInSignal = FALSE [static] |
Definition at line 280 of file llapp.h.
Referenced by default_unix_signal_handler(), and LLErrorThread::run().
LLAtomicU32 * LLApp::sSigChildCount = NULL [static, protected] |
Definition at line 234 of file llapp.h.
Referenced by getSigChildCount(), incSigChildCount(), LLApp(), and ~LLApp().
LLApp::EAppStatus LLApp::sStatus = LLApp::APP_STATUS_STOPPED [static, protected] |
Definition at line 230 of file llapp.h.
Referenced by isError(), isQuitting(), isRunning(), isStopped(), and setStatus().