LLApp Class Reference

#include <llapp.h>

Inheritance diagram for LLApp:

Inheritance graph
[legend]
Collaboration diagram for LLApp:

Collaboration graph
[legend]
List of all members.

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 ()
LLRunnergetRunner ()
 Get a reference to the application runner.

Static Public Member Functions

static LLAppinstance ()
 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, LLChildInfochild_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 LLAtomicU32sSigChildCount = 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

LLErrorThreadmThreadErrorp
LLRunner mRunner
Runtime option implementation
LLSD mOptions

Static Private Attributes

static LLAppErrorHandler sErrorHandler = NULL
static LLAppsApplication = NULL

Friends

class LLErrorThread
void default_unix_signal_handler (int signum, siginfo_t *info, void *)

Detailed Description

Definition at line 63 of file llapp.h.


Member Typedef Documentation

typedef std::map<pid_t, LLChildInfo> LLApp::child_map [protected]

Definition at line 235 of file llapp.h.

typedef enum LLApp::e_app_status LLApp::EAppStatus

typedef int(*) LLApp::signal_handler_func(int signum) [private]

Definition at line 253 of file llapp.h.

typedef std::map<std::string, std::string> LLApp::string_map

Definition at line 224 of file llapp.h.


Member Enumeration Documentation

enum LLApp::e_app_status

Enumerator:
APP_STATUS_RUNNING 
APP_STATUS_QUITTING 
APP_STATUS_STOPPED 
APP_STATUS_ERROR 

Definition at line 67 of file llapp.h.

enum LLApp::OptionPriority

Enumeration to specify option priorities in highest to lowest order.

Enumerator:
PRIORITY_RUNTIME_OVERRIDE 
PRIORITY_COMMAND_LINE 
PRIORITY_SPECIFIC_CONFIGURATION 
PRIORITY_GENERAL_CONFIGURATION 
PRIORITY_DEFAULT 
PRIORITY_COUNT 

Definition at line 90 of file llapp.h.


Constructor & Destructor Documentation

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.


Member Function Documentation

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.

Parameters:
name The name of the option.
Returns:
Returns the option data.

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.

Parameters:
level The priority level of the data.
Returns:
Returns The data (if any) at the level priority.

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().

int LLApp::getPid (  )  [static]

Definition at line 352 of file llapp.cpp.

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.

Returns:
Returns the application runner. Do not save the pointer past the caller's stack frame.

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]

Definition at line 304 of file llapp.cpp.

References APP_STATUS_RUNNING, and sStatus.

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.

Parameters:
argc The argc passed into main().
argv The argv passed into main().
Returns:
Returns true if the parse succeeded.

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  ) 

Definition at line 410 of file llapp.cpp.

References sDefaultChildCallback.

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  ) 

Definition at line 245 of file llapp.cpp.

References sErrorHandler.

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.

Parameters:
level The priority level of the data.
data The data to set.
Returns:
Returns true if the option was 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().

Referenced by fork(), and LLApp().

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().


Friends And Related Function Documentation

void default_unix_signal_handler ( int  signum,
siginfo_t *  info,
void  
) [friend]

friend class LLErrorThread [friend]

Definition at line 65 of file llapp.h.

Referenced by setupErrorHandling().


Member Data Documentation

string_map LLApp::mOptionMap

Definition at line 225 of file llapp.h.

LLSD LLApp::mOptions [private]

Definition at line 266 of file llapp.h.

Referenced by getOption(), getOptionData(), LLApp(), and setOptionData().

LLRunner LLApp::mRunner [private]

Definition at line 260 of file llapp.h.

Referenced by getRunner(), and stepFrame().

LLErrorThread* LLApp::mThreadErrorp [private]

Definition at line 257 of file llapp.h.

Referenced by setupErrorHandling(), and ~LLApp().

LLApp * LLApp::sApplication = NULL [static, private]

Definition at line 272 of file llapp.h.

Referenced by instance(), and LLApp().

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]

Definition at line 254 of file llapp.h.

Referenced by runErrorHandler(), and setErrorHandler().

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().


The documentation for this class was generated from the following files:
Generated on Thu Jul 1 06:11:10 2010 for Second Life Viewer by  doxygen 1.4.7