Mantis App v0.1.13
Loading...
Searching...
No Matches
mantis::MantisApp Class Reference

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.
 
DatabaseUnitdb () const
 Get the database unit object.
 
LoggingUnitlog () const
 Get the logging unit object.
 
HttpUnithttp () const
 Get the http unit object.
 
argparse::ArgumentParser & cmd () const
 Get the commandline parser object.
 
Routerrouter () const
 Get the router object instance.
 
Validatorvalidators () const
 Get the validators unit object instance in MantisApp.
 
ExprEvaluatorevaluator () const
 Get the cparse expression evaluator unit object instance.
 
SettingsUnitsettings () 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 MantisAppinstance ()
 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.
 

Detailed Description

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:

Constructor & Destructor Documentation

◆ MantisApp()

mantis::MantisApp::MantisApp ( int  argc = 0,
char **  argv = nullptr 
)
explicit

MantisApp constructor, creates a singleton instance if one is not created yet.

Parameters
argcArgument count.
argvArgument values.

◆ ~MantisApp()

mantis::MantisApp::~MantisApp ( )

Member Function Documentation

◆ appMajorVersion()

int mantis::MantisApp::appMajorVersion ( )
static

Fetch the minor version.

◆ appMinorVersion()

int mantis::MantisApp::appMinorVersion ( )
static

Fetch the major version.

◆ appPatchVersion()

int mantis::MantisApp::appPatchVersion ( )
static

Fetch the patch version.

◆ appVersion()

std::string mantis::MantisApp::appVersion ( )
static

Fetch the application version

Returns
Application version

◆ close()

void mantis::MantisApp::close ( ) const

Close the application.

Internally, this stops running http server.

◆ cmd()

argparse::ArgumentParser & mantis::MantisApp::cmd ( ) const

Get the commandline parser object.

◆ dataDir()

std::string mantis::MantisApp::dataDir ( ) const

Retrieves the data directory where SQLite db and files are stored.

Returns
MantisApp data directory.

◆ db()

DatabaseUnit & mantis::MantisApp::db ( ) const

Get the database unit object.

◆ dbType()

DbType mantis::MantisApp::dbType ( ) const

Retrieves the active database type.

Returns
Selected DatabaseType enum value.

◆ ensureInitialized()

void mantis::MantisApp::ensureInitialized ( const char *  caller) const

Syntactic method to enforce.

See also
init() is run before any other executions.

Since init() ensures all objects are initialized, this ensures we don't use null pointers.

Parameters
callerCaller function name.

◆ evaluator()

ExprEvaluator & mantis::MantisApp::evaluator ( ) const

Get the cparse expression evaluator unit object instance.

◆ host()

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.

Returns
HTTP Server Host address.

◆ http()

HttpUnit & mantis::MantisApp::http ( ) const

Get the http unit object.

◆ init()

void mantis::MantisApp::init ( )

Run initialization actions for Mantis, ensuring all objects are initialized properly before use.

◆ instance()

MantisApp & mantis::MantisApp::instance ( )
static

Retrieve existing application instance.

Returns
A reference to the existing application instance.

◆ jwtSecretKey()

std::string mantis::MantisApp::jwtSecretKey ( )
static

Retrieve the JWT secret key.

Returns
JWT Secret value.

◆ log()

LoggingUnit & mantis::MantisApp::log ( ) const

Get the logging unit object.

◆ openBrowserOnStart()

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

◆ poolSize()

int mantis::MantisApp::poolSize ( ) const

Retrieve the database pool size value.

Returns
SOCI's database pool size.

◆ port()

int mantis::MantisApp::port ( ) const

Retrieve HTTP Listening port.

Returns
Http Listening Port.

◆ publicDir()

std::string mantis::MantisApp::publicDir ( ) const

Retrieve the public static file directory.

Returns
MantisApp public directory.

◆ quit()

int mantis::MantisApp::quit ( const int &  exitCode = 0,
const std::string &  reason = "Something went wrong!" 
)
static

Quit the running application immediately.

Parameters
exitCodeExit code value
reasonUser-friendly reason for the exit.
Returns
exitCode value.

◆ router()

Router & mantis::MantisApp::router ( ) const

Get the router object instance.

◆ run()

int mantis::MantisApp::run ( ) const

Start the http server and start listening for requests.

Returns
0 if execution was okay, else a non-zero value.

◆ setDataDir()

void mantis::MantisApp::setDataDir ( const std::string &  dir)

Update the data directory for MantisApp.

Parameters
dirNew data directory.

◆ setDbType()

void mantis::MantisApp::setDbType ( const DbType dbType)

Update the active database type for Mantis.

Parameters
dbTypeNew database type enum value.

◆ setHost()

void mantis::MantisApp::setHost ( const std::string &  host)

Update HTTP Server host address.

Parameters
hostNew HTTP Server host address.

◆ setPoolSize()

void mantis::MantisApp::setPoolSize ( const int &  pool_size)

Set the database pool size value.

Parameters
pool_sizeNew pool size value.

◆ setPort()

void mantis::MantisApp::setPort ( const int &  port)

Set a new port value for HTTP server.

Parameters
portNew HTTP port value.

◆ setPublicDir()

void mantis::MantisApp::setPublicDir ( const std::string &  dir)

Update HTTP server static file directory.

Parameters
dirNew directory path.

◆ settings()

SettingsUnit & mantis::MantisApp::settings ( ) const

Get the settings unit object.

◆ validators()

Validator & mantis::MantisApp::validators ( ) const

Get the validators unit object instance in MantisApp.


The documentation for this class was generated from the following files: