Files
Upsilon/apps/apps_container.cpp
Émilie Feral af6a1c7046 [apps] add a method to get the global context in appsContainer
Change-Id: I4b7a4c1c64ae21c7e4f0193b3314d96cef805cbb
2016-11-10 17:26:07 +01:00

51 lines
1.0 KiB
C++

#include "apps_container.h"
extern "C" {
#include <assert.h>
}
AppsContainer::AppsContainer() :
Container(),
m_homeApp(this),
m_graphApp(this, &m_context),
m_probabilityApp(this),
m_calculationApp(this, &m_context),
m_context(Context())
{
}
int AppsContainer::numberOfApps() {
return k_numberOfApps;
}
App * AppsContainer::appAtIndex(int index) {
static App * apps[] = {
&m_homeApp,
&m_graphApp,
&m_probabilityApp,
&m_calculationApp,
};
assert(sizeof(apps)/sizeof(apps[0]) == k_numberOfApps);
assert(index >= 0 && index < k_numberOfApps);
return apps[index];
}
Context * AppsContainer::context() {
return &m_context;
}
ToolBoxController * AppsContainer::toolBoxController() {
return &m_toolBoxController;
}
VariableBoxController * AppsContainer::variableBoxController() {
return &m_variableBoxController;
}
bool AppsContainer::handleEvent(Ion::Events::Event event) {
if (event == Ion::Events::Event::F1) {
switchTo(appAtIndex(0));
return true;
}
return false;
}