Support launching Servo2d with a URI.

This commit is contained in:
Josh Matthews 2019-03-15 13:49:49 -04:00
parent 0a5aab6cc2
commit daabda7fe1
3 changed files with 29 additions and 5 deletions

View file

@ -3,11 +3,32 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
#include <Servo2D.h>
#include <ml_lifecycle.h>
#include <ml_logging.h>
int main(int argc, char **argv)
{
ML_LOG(Debug, "Servo2D Starting.");
Servo2D myApp;
return myApp.run();
// Handle optional initialization string passed via 'mldb launch'
MLLifecycleInitArgList* list = NULL;
MLLifecycleGetInitArgList(&list);
const char* uri = NULL;
if (nullptr != list) {
int64_t list_length = 0;
MLLifecycleGetInitArgListLength(list, &list_length);
if (list_length > 0) {
const MLLifecycleInitArg* iarg = NULL;
MLLifecycleGetInitArgByIndex(list, 0, &iarg);
if (nullptr != iarg) {
MLLifecycleGetInitArgUri(iarg, &uri);
}
}
}
Servo2D myApp(uri);
int rv = myApp.run();
MLLifecycleFreeInitArgList(&list);
return rv;
}