![]() |
Mantis App v0.1.13
|
Mantis entry point. More...
#include <app.h>
Public Member Functions | |
MantisApp (int argc=0, char **argv=nullptr) | |
MantisApp constructor, creates a singleton instance if one is not created yet. | |
~MantisApp () | |
void | init () |
Run initialization actions for Mantis, ensuring all objects are initialized properly before use. | |
int | run () const |
Start the http server and start listening for requests. | |
void | close () const |
Close the application. | |
int | port () const |
Retrieve HTTP Listening port. | |
void | setPort (const int &port) |
Set a new port value for HTTP server. | |
int | poolSize () const |
Retrieve the database pool size value. | |
void | setPoolSize (const int &pool_size) |
Set the database pool size value. | |
std::string | host () const |
Retrieve HTTP Server host address. For instance, a host of 127.0.0.1 , 0.0.0.0 , etc. | |
void | setHost (const std::string &host) |
Update HTTP Server host address. | |
std::string | publicDir () const |
Retrieve the public static file directory. | |
void | setPublicDir (const std::string &dir) |
Update HTTP server static file directory. | |
std::string | dataDir () const |
Retrieves the data directory where SQLite db and files are stored. | |
void | setDataDir (const std::string &dir) |
Update the data directory for MantisApp. | |
DbType | dbType () const |
Retrieves the active database type. | |
void | setDbType (const DbType &dbType) |
void | ensureInitialized (const char *caller) const |
Syntactic method to enforce. | |
DatabaseUnit & | db () const |
Get the database unit object. | |
LoggingUnit & | log () const |
Get the logging unit object. | |
HttpUnit & | http () const |
Get the http unit object. | |
argparse::ArgumentParser & | cmd () const |
Get the commandline parser object. | |
Router & | router () const |
Get the router object instance. | |
Validator & | validators () const |
Get the validators unit object instance in MantisApp. | |
ExprEvaluator & | evaluator () const |
Get the cparse expression evaluator unit object instance. | |
SettingsUnit & | settings () const |
Get the settings unit object. | |
void | openBrowserOnStart () const |
Launch browser with the admin dashboard page. If all goes well, the default OS browser should open (if not opened) with the admin dashboard URL. | |
Static Public Member Functions | |
static MantisApp & | instance () |
Retrieve existing application instance. | |
static int | quit (const int &exitCode=0, const std::string &reason="Something went wrong!") |
Quit the running application immediately. | |
static std::string | jwtSecretKey () |
Retrieve the JWT secret key. | |
static std::string | appVersion () |
static int | appMinorVersion () |
Fetch the major version. | |
static int | appMajorVersion () |
Fetch the minor version. | |
static int | appPatchVersion () |
Fetch the patch version. | |
Mantis entry point.
This class handles the entrypoint to the Mantis
world, where we can set/get application flags and variables, as well as access other application units. These units are:
|
explicit |
MantisApp constructor, creates a singleton instance if one is not created yet.
argc | Argument count. |
argv | Argument values. |
mantis::MantisApp::~MantisApp | ( | ) |
|
static |
Fetch the minor version.
|
static |
Fetch the major version.
|
static |
Fetch the patch version.
|
static |
Fetch the application version
void mantis::MantisApp::close | ( | ) | const |
Close the application.
Internally, this stops running http server.
argparse::ArgumentParser & mantis::MantisApp::cmd | ( | ) | const |
Get the commandline parser object.
std::string mantis::MantisApp::dataDir | ( | ) | const |
Retrieves the data directory where SQLite db and files are stored.
DatabaseUnit & mantis::MantisApp::db | ( | ) | const |
Get the database unit object.
DbType mantis::MantisApp::dbType | ( | ) | const |
Retrieves the active database type.
void mantis::MantisApp::ensureInitialized | ( | const char * | caller | ) | const |
ExprEvaluator & mantis::MantisApp::evaluator | ( | ) | const |
Get the cparse
expression evaluator unit object instance.
std::string mantis::MantisApp::host | ( | ) | const |
Retrieve HTTP Server host address. For instance, a host of 127.0.0.1
, 0.0.0.0
, etc.
HttpUnit & mantis::MantisApp::http | ( | ) | const |
Get the http unit object.
void mantis::MantisApp::init | ( | ) |
Run initialization actions for Mantis, ensuring all objects are initialized properly before use.
|
static |
Retrieve existing application instance.
|
static |
LoggingUnit & mantis::MantisApp::log | ( | ) | const |
Get the logging unit object.
void mantis::MantisApp::openBrowserOnStart | ( | ) | const |
Launch browser with the admin dashboard page. If all goes well, the default OS browser should open (if not opened) with the admin dashboard URL.
Added in v0.1.6
int mantis::MantisApp::poolSize | ( | ) | const |
Retrieve the database pool size value.
int mantis::MantisApp::port | ( | ) | const |
Retrieve HTTP Listening port.
std::string mantis::MantisApp::publicDir | ( | ) | const |
Retrieve the public static file directory.
|
static |
Quit the running application immediately.
exitCode | Exit code value |
reason | User-friendly reason for the exit. |
exitCode
value. Router & mantis::MantisApp::router | ( | ) | const |
Get the router object instance.
int mantis::MantisApp::run | ( | ) | const |
Start the http server and start listening for requests.
0
if execution was okay, else a non-zero value. void mantis::MantisApp::setDataDir | ( | const std::string & | dir | ) |
Update the data directory for MantisApp.
dir | New data directory. |
void mantis::MantisApp::setDbType | ( | const DbType & | dbType | ) |
Update the active database type for Mantis.
dbType | New database type enum value. |
void mantis::MantisApp::setHost | ( | const std::string & | host | ) |
Update HTTP Server host address.
host | New HTTP Server host address. |
void mantis::MantisApp::setPoolSize | ( | const int & | pool_size | ) |
Set the database pool size value.
pool_size | New pool size value. |
void mantis::MantisApp::setPort | ( | const int & | port | ) |
Set a new port value for HTTP server.
port | New HTTP port value. |
void mantis::MantisApp::setPublicDir | ( | const std::string & | dir | ) |
Update HTTP server static file directory.
dir | New directory path. |
SettingsUnit & mantis::MantisApp::settings | ( | ) | const |
Get the settings unit object.
Validator & mantis::MantisApp::validators | ( | ) | const |
Get the validators unit object instance in MantisApp.