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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
#include "consoleAppEngine.h"
#include "consoleEnvironment.h"
#include "iterate.h"
#include "xmlObjectLoader.h"
#include <boost/foreach.hpp>
#include <boost/bind.hpp>
#include <iostream>
SimpleMessageException(UnknownPlatformAlias);
/// Session implementation that stores its contents locally in memory, it has no long term persistence
class ConsoleSession : public Session {
public:
ConsoleSession() : expiry(0)
{
}
virtual ~ConsoleSession()
{
}
virtual const VariableType & GetValue(const Glib::ustring & name) const
{
Values::const_iterator i = vars.find(name);
if (i == vars.end()) {
throw Session::VariableNotFound(name);
}
return i->second;
}
virtual Values GetValuesCopy() const
{
return vars;
}
virtual void SetValue(const Glib::ustring & name, const VariableType & value)
{
vars[name] = value;
}
virtual void ClearValue(const Glib::ustring & name)
{
vars.erase(name);
}
virtual time_t ExpiryTime() const
{
return expiry;
}
protected:
virtual void ExpiryTime(time_t t)
{
expiry = t;
}
private:
time_t expiry;
Values vars;
};
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 ConsoleSession())
{
}
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
{
ConsolePlatforms::const_iterator i = conplat.find(_env->getPlatform());
if (i != conplat.end()) {
return i->second;
}
throw UnknownPlatformAlias(_env->getPlatform());
}
void
ConsoleApplicationEngine::loadEngineSection(const xmlpp::Element * e) const
{
conplat.insert(ConsolePlatforms::value_type(e->get_attribute_value("setting"), e->get_attribute_value("platform")));
}
|