blob: 72d34a99cdb45d7000d2d657e0fda0444dda6749 (
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
|
#include "appInstance.h"
#include <boost/tuple/tuple_comparison.hpp>
AppInstance * AppInstance::_current = nullptr;
AppInstance::AppInstance()
{
if (_current) {
throw std::runtime_error("One AppInstance at a time please");
}
_current = this;
}
AppInstance::~AppInstance()
{
if (_current != this) {
throw std::runtime_error("All kinds of bad, destroying a non-current AppInstance");
}
_current = NULL;
}
AppInstance &
AppInstance::current()
{
if (!_current) {
throw std::runtime_error("No current AppInstance");
}
return *_current;
}
ScriptReaderPtr
AppInstance::cachedScript(const ScriptReader::ScriptKey & sk) const
{
auto cached = scriptCache.find(sk);
if (cached != scriptCache.end()) {
return cached->second;
}
return nullptr;
}
void
AppInstance::cacheScript(const ScriptReader::ScriptKey & sk, ScriptReaderPtr s)
{
scriptCache[sk] = s;
}
void
AppInstance::clearScriptCache()
{
scriptCache.clear();
}
|