XdmfItemFactory.cpp 1.4 KB
Newer Older
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 57 58 59 60 61 62 63
#include "XdmfArray.hpp"
#include "XdmfAttribute.hpp"
#include "XdmfDomain.hpp"
#include "XdmfGeometry.hpp"
#include "XdmfGrid.hpp"
#include "XdmfGridCollection.hpp"
#include "XdmfItemFactory.hpp"
#include "XdmfSet.hpp"
#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
{
	boost::shared_ptr<XdmfItem> newItem;
	if(itemTag.compare(XdmfArray::ItemTag) == 0)
	{
		newItem = XdmfArray::New();
	}
	else if(itemTag.compare(XdmfAttribute::ItemTag) == 0)
	{
		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();
		}
	}
	else if(itemTag.compare(XdmfSet::ItemTag) == 0)
	{
		newItem = XdmfSet::New();
	}
	else if(itemTag.compare(XdmfTopology::ItemTag) == 0)
	{
		newItem = XdmfTopology::New();
	}
	else
	{
		assert(false);
	}
	return newItem;
}