Class MAE

Index Home MAE > MAE Architecture > MAE Data Types > Class Index > Class MAE

Summary
Public Properties
Public Methods
MAE(programName, appchannels)
static inline void setDaemon()
static inline void setUtility()
static inline void setApp()
static inline bool isDaemon()
static inline bool isUtility()
static inline bool isApp()
void _main(argc, argv)
static MAE* getPrimeInstance()
static void init(argc, argv)
static void registerDetails()
static void main()
static void handleMessage(msgr, src, dest, request, param)
static void handleBroadcast(msgr, src, dest, request, param)
static void handleInputResponse(dest, device, cbtag, cbdata, response)
static void handleMouseInput(device, cbtag, cbdata, dir, x, y)
static void handleApiMessage(msgr, src, dest, request, param)
static void handleRpcMessage(service, params, appname, user, data)
void appRegistration()
static void quit(rc, msg)
static void toggleDebug(_unused)
inline static MsgBroadcast& getBroadcast()
Private Properties
Private Methods
static void sigquit(a)

#include <MAE.h >

Summary

This class is the starting point of the MAE platform.  Create a single instance for MAE to operate correctly in your main source file. More than likely, you'll instead declare a sub-class - MAEApp, MAEDaemon, or MAEUtility - which is tailored to your tasks's purpose.

Public Properties

static MgmtClient mgmt

Each MAE app has the option to be managed by the supervisor app.

If so, it uses this MgmtClient data structure.

static bool forkit

Flag: When MAE starts your application, should it fork?

If not, then add this line to your program:

bool MAE::forkit= false;

to override the default of true.


Public Methods

MAE(programName, appchannels)

const string& programName

the name of the task as registered inside MAE

const string& appchannels

a comma separated list of message channels used. Default is one channel using the program's name.

Default value: ""


Constructor for MAE task.

static inline void setDaemon()

Declare this task as a daemon - a persistent program providing support to other MAE tasks.

static inline void setUtility()

Declare this task as a utility - a one-shot program that performs a task and exits.

static inline void setApp()

Declare this task as an app - a persistent program servicing user requests via UI.

static inline bool isDaemon()

Query if the current task behaves like a daemon.

static inline bool isUtility()

Query if the current task behaves like a utility.

static inline bool isApp()

Query if the current task behaves like an app.

void _main(argc, argv)

int argc

number of parameters passed to program from OS

char** argv

the parameters passed to program from OS


MAE defines a ::main(). It creates a single instance of this MAE class and then calls _main(). It necessarily needs to be public so ::main() can call it.

static MAE* getPrimeInstance()

Return the global instance of the MAE class.

Return value: a pointer to the global MAE instance.

static void init(argc, argv)

int argc

the number of command line arguments (including program name)

char** argv

an array of arguments (char *) to the program


Application Provided Method.

MAE calls this when the task environment setup to let task initialize itself.

static void registerDetails()

Application Provided Method.

MAE calls this after init() to perform RPC registrations.

The genmae prgram generates this inside the msg*.cpp file.

static void main()

Application Provided Method.

MAE calls this once this task's environment is fully initialized.

This is where your task performs its main functionality.

static void handleMessage(msgr, src, dest, request, param)

Messenger& msgr

handle to Messenger service

const string& src

the source channel that sent the message

const string& dest

the destination channel for the message

const string& request

the action/keyword/request for this message

XMLData& param

the data payload for this request


Application Provided Method.

Called to handle a message from an app/daemon.

static void handleBroadcast(msgr, src, dest, request, param)

Messenger& msgr

handle to Messenger service

const string& src

the source channel that sent the message

const string& dest

the destination channel for the message, e.g. broadcast

const string& request

the action/keyword/request for this message

XMLData& param

the data payload for this request


Application Provided Method.

MAE calls this to handle a broadcast message from an app/daemon.

static void handleInputResponse(dest, device, cbtag, cbdata, response)

const string& dest

the destination channel to receive response

UserDevice& device

handle to User's device/screen

const string& cbtag

the action to take with the response

const XMLData& cbdata

the data associated with the action

string response

the User's response


Application Provided Method.

MAE calls this to handle a user response message.

static void handleMouseInput(device, cbtag, cbdata, dir, x, y)

UserDevice& device

handle to User's device/screen

const string& cbtag

the action to take with the response

const XMLData& cbdata

the data associated with the action

const string& dir

mouse click direction - up, down, move

float x

mouse x coordinate of click

float y

mouse y coordinate of click


Application Provided Method.

MAE calls this to handle a user mouse response.

static void handleApiMessage(msgr, src, dest, request, param)

Messenger& msgr

handle to Messenger service

const string& src

the source channel that sent the message

const string& dest

the destination channel for the message, e.g. gui

const string& request

the action/keyword/request for this message

XMLData& param

the data payload for this request


Application Provided Method.

MAE calls this to handle an API request

static void handleRpcMessage(service, params, appname, user, data)

string service

the action/keyword/request for this message

XMLData& params

the parameters in this message

string appname

the client's app id

string user

(future use)

void* data

(future use)


Application Provided Method.

MAE calls this to handle a RPC request

void appRegistration()

Application Provided Method.

MAE calls this Register the app's various UI and message callbacks.

static void quit(rc, msg)

int rc

the program's exit code (0 means normal exit, 1+ means err exit)

const string& msg

an explanation why the app is shutting down


Application Provided Method.

Either the user or the ecosystem has initiated a task exit.

static void toggleDebug(_unused)

int _unused

(ignored)

Default value: 0


Toggle the debug mode for the program.

Ensures FILE*dbgf is pointing to a valid log file, e.g. /usr/mae/log/ <taskname >dbg.log

inline static MsgBroadcast& getBroadcast()

Private Properties

static enum taskType

The task type, e.g. daemon, utility, app

string taskname

The name of the running task

string channels

The name of the running task

channels; channels

The channels used by this task

static string dbgfilename

When debug enabled, this is the debug filename used

static MsgBroadcast broadcast

For communication to broadcast channel

static MAE* instance

The running instance of MAE


Private Methods

static void sigquit(a)

int a

(ignored)


Program exit signal handlers