XdmfItemFactory.cpp 1.6 KB
Newer Older
1 2 3 4 5
#include "XdmfAttribute.hpp"
#include "XdmfDomain.hpp"
#include "XdmfGeometry.hpp"
#include "XdmfGrid.hpp"
#include "XdmfGridCollection.hpp"
6
#include "XdmfInformation.hpp"
7 8
#include "XdmfItemFactory.hpp"
#include "XdmfSet.hpp"
9
#include "XdmfTime.hpp"
10 11 12 13 14 15 16 17 18 19 20 21
#include "XdmfTopology.hpp"

XdmfItemFactory::XdmfItemFactory()
{
}

XdmfItemFactory::~XdmfItemFactory()
{
}

boost::shared_ptr<XdmfItem> XdmfItemFactory::createItem(const std::string & itemTag, const std::map<std::string, std::string> & itemProperties) const
{
22 23 24
	boost::shared_ptr<XdmfItem> newItem = XdmfCoreItemFactory::createItem(itemTag, itemProperties);

	if(newItem != NULL)
25
	{
26
		return newItem;
27
	}
28 29

	if(itemTag.compare(XdmfAttribute::ItemTag) == 0)
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
	{
		newItem = XdmfAttribute::New();
	}
	else if(itemTag.compare(XdmfDomain::ItemTag) == 0)
	{
		newItem = XdmfDomain::New();
	}
	else if(itemTag.compare(XdmfGeometry::ItemTag) == 0)
	{
		newItem = XdmfGeometry::New();
	}
	else if(itemTag.compare(XdmfGrid::ItemTag) == 0)
	{
		std::map<std::string, std::string>::const_iterator gridType = itemProperties.find("GridType");
		if(gridType != itemProperties.end() && gridType->second.compare("Collection") == 0)
		{
			newItem = XdmfGridCollection::New();
		}
		else
		{
			newItem = XdmfGrid::New();
		}
	}
53 54 55 56
	else if(itemTag.compare(XdmfInformation::ItemTag) == 0)
	{
		newItem = XdmfInformation::New();
	}
57 58 59 60
	else if(itemTag.compare(XdmfSet::ItemTag) == 0)
	{
		newItem = XdmfSet::New();
	}
61 62 63 64
	else if(itemTag.compare(XdmfTime::ItemTag) == 0)
	{
		newItem = XdmfTime::New();
	}
65 66 67 68 69 70
	else if(itemTag.compare(XdmfTopology::ItemTag) == 0)
	{
		newItem = XdmfTopology::New();
	}
	return newItem;
}