blob: f63a727a208f4d9c5bcfd2c4a808d619bf76c443 (
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
|
#include "pch.hpp"
#include "sourceObject.h"
#include "exceptions.h"
#include "safeMapFind.h"
#include "scripts.h"
unsigned int SourceObject::loadOrder = 1;
SimpleMessageException(ComponentNotFound);
SourceObject::SourceObject(ScriptNodePtr p) :
name(p ? p->value("name", "anon").as<std::string>() : "anon"),
order(loadOrder++),
script(p->script.get())
{
LoaderBase::loadedObjects.insert(this);
script->namedComponents[name] = this;
}
SourceObject::SourceObject(const std::string & n) :
name(n),
order(loadOrder++),
script(NULL)
{
LoaderBase::loadedObjects.insert(this);
}
SourceObject::~SourceObject()
{
LoaderBase::loadedObjects.erase(this);
}
void
SourceObject::loadComplete(const CommonObjects *)
{
}
void
SourceObject::send(int eventID) const
{
for (Events::const_iterator i = events.lower_bound(eventID); i != events.upper_bound(eventID); i++) {
i->second();
}
}
void
SourceObject::registerFor(int eventID, const Event & event) const
{
events.insert(Events::value_type(eventID, event));
}
SourceObject *
SourceObject::findComponent(const std::string & name) const
{
return safeMapLookup<ComponentNotFound>(script->namedComponents, name);
}
|