blob: 2c4845dcbb56de90835f36582c9606b7edb4808f (
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
|
#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", NULL).as<std::string>() : "anon"),
order(loadOrder++),
script(p->script)
{
script.lock()->namedComponents[name] = this;
}
SourceObject::SourceObject(const std::string & n) :
name(n),
order(loadOrder++)
{
}
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 AdHoc::safeMapLookup<ComponentNotFound>(script.lock()->namedComponents, name);
}
|