summaryrefslogtreecommitdiff
path: root/project2/commonObjects.cpp
blob: e811fe7f88ba7feadedc97db148ebd98b84424d7 (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
#include "commonObjects.h"
#include "appEngine.h"
#include "xmlObjectLoader.h"
#include "xmlScriptParser.h"

CommonObjects::~CommonObjects()
{
}

RowSetPtr
CommonObjects::getSource(const std::string & name) const
{
	RowSets::const_iterator i = rowSets.find(name);
	if (i != rowSets.end()) {
		return i->second;
	}
	throw CommonObjects::DataSourceNotFound(name);
}

CommonObjects::DataSources::const_iterator
CommonObjects::loadDataSource(const std::string & name) const
{
	XmlScriptParser xml(Environment::getCurrent()->resolveScript(
				Environment::getCurrent()->datasourceRoot, name), true);

	LoaderBase loader(true);
	loader.supportedStorers.insert(Storer::into(&datasources));
	loader.collectAll(xml.get_document()->get_root_node(), false);

	DataSources::const_iterator i = datasources.find(name);
	if (i == datasources.end()) {
		throw DataSourceNotFound(name);
	}
	return i;
}