summaryrefslogtreecommitdiff
path: root/project2/common/transform.cpp
blob: 0dafcd5f64eaa6c2bdf092db1df230b34d9ecc08 (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
#include <pch.hpp>
#include "transform.h"
#include "logger.h"
#include <boost/foreach.hpp>

TransformChainLink::~TransformChainLink()
{
}

typedef std::map<std::string, boost::shared_ptr<TransformLoader> > TransformLoaderMap;
void
TransformSource::addTarget(TransformChainLinkPtr tcl, ScriptNodePtr e)
{
	BOOST_FOREACH(const TransformLoaderMap::value_type & tl, *LoaderBase::objLoaders<TransformLoader>()) {
		TransformPtr t = tl.second->create();
		if (t->canTransform(this, tcl.get())) {
			if (e) {
				t->configure(e);
			}
			targets[tcl] = t;
			return;
		}
	}
	throw NotSupported("Couldn't find a suitable transformation");
}

typedef std::map<TransformChainLinkPtr, TransformPtr> Targets;
void
TransformSource::doTransforms() const
{
	BOOST_FOREACH(const Targets::value_type & t, targets) {
		t.second->transform(this, t.first.get());
		if (const TransformSource * tr = dynamic_cast<const TransformSource *>(t.first.get())) {
			tr->doTransforms();
		}
	}
}