summaryrefslogtreecommitdiff
path: root/project2/console/consoleAppEngine.cpp
blob: 114061d92b6f40d40be35341d6e4f14b0827dd56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#include "pch.hpp"
#include <glibmm/exception.h>
#include <cxxabi.h>
#include "consoleAppEngine.h"
#include "consoleEnvironment.h"
#include "consolePresenter.h"
#include "logger.h"
#include "safeMapFind.h"
#include "iterate.h"
#include "scriptLoader.h"
#include <boost/foreach.hpp>
#include <boost/bind.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <iostream>

SimpleMessageException(UnknownPlatformAlias);

ConsoleApplicationEngine::ConsoleApplicationEngine(const ConsoleEnvironment * env, ScriptReaderPtr script) :
	SourceObject(script->root()),
	CommonObjects(script->root()),
	CheckHost(script->root()),
	TaskHost(script->root()),
	ViewHost(script->root()),
	_env(env),
	runtime(new Session(boost::uuids::random_generator()())),
	presenter(new ConsolePresenter())
{
}

ConsoleApplicationEngine::~ConsoleApplicationEngine()
{
}

void
ConsoleApplicationEngine::process() const
{
	try {
		runChecks();
		execute();
		executeViews();
		addAppData(presenter.get());
	}
	catch (const std::exception & e) {
		char * buf = __cxxabiv1::__cxa_demangle(typeid(e).name(), NULL, NULL, NULL);
		Logger()->messagef(LOG_ERR, "%s: Script errored: %s: %s", __FUNCTION__, buf, e.what());
		free(buf);
	}
	catch (const Glib::Exception & e) {
		char * buf = __cxxabiv1::__cxa_demangle(typeid(e).name(), NULL, NULL, NULL);
		Logger()->messagebf(LOG_ERR, "%s: Script errored: %s: %s", __FUNCTION__, buf, e.what());
		free(buf);
	}
}

MultiRowSetPresenterPtr
ConsoleApplicationEngine::getPresenter() const
{
	return presenter;
}

const Environment *
ConsoleApplicationEngine::env() const
{
	return _env;
}

SessionPtr
ConsoleApplicationEngine::session() const
{
	return runtime;
}

void
ConsoleApplicationEngine::addEnvData(const MultiRowSetPresenter *) const
{
}

void
ConsoleApplicationEngine::addAppData(const MultiRowSetPresenter *) const
{
}