summaryrefslogtreecommitdiff
path: root/project2/console/consoleAppEngine.cpp
blob: e49825ff965b01998f9b19c71e1c32286e9eb8b7 (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
#include <pch.hpp>
#include "consoleAppEngine.h"
#include "consoleEnvironment.h"
#include "safeMapFind.h"
#include "iterate.h"
#include "xmlObjectLoader.h"
#include <boost/foreach.hpp>
#include <boost/bind.hpp>
#include <iostream>

SimpleMessageException(UnknownPlatformAlias);

ConsoleApplicationEngine::ConsoleApplicationEngine(const ConsoleEnvironment * env, const boost::filesystem::path & f) :
	XmlScriptParser(f, false),
	SourceObject(get_document()->get_root_node()),
	CheckHost(f),
	ApplicationEngine("console/environment"),
	TaskHost(f),
	ViewHost(f),
	_env(env),
	runtime(new Session(UUID::generate_random()))
{
}

ConsoleApplicationEngine::~ConsoleApplicationEngine()
{
}

void
onCheckFailureHelper(boost::intrusive_ptr<const ParamChecker> pc)
{
	throw std::runtime_error(pc->message());
}

void
ConsoleApplicationEngine::process() const
{
	runChecks();
	execute();
	executeViews(boost::bind(&PresenterLoader::createFrom, LoaderBase::getLoader<PresenterLoader, NotSupported>("console"), _1));
	addAppData(headPresenter().get());
}

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

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

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

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

Glib::ustring
ConsoleApplicationEngine::resolveCurrentConfig() const
{
	return safeMapFind<UnknownPlatformAlias>(conplat, _env->getPlatform())->second;
}

void
ConsoleApplicationEngine::loadEngineSection(const xmlpp::Element * e) const
{
	conplat.insert(ConsolePlatforms::value_type(e->get_attribute_value("setting"), e->get_attribute_value("platform")));
}