XdmfItemFactory.cpp 1.63 KB
Newer Older
1 2 3 4 5 6
#include "XdmfArray.hpp"
#include "XdmfAttribute.hpp"
#include "XdmfDomain.hpp"
#include "XdmfGeometry.hpp"
#include "XdmfGrid.hpp"
#include "XdmfGridCollection.hpp"
7
#include "XdmfInformation.hpp"
8 9
#include "XdmfItemFactory.hpp"
#include "XdmfSet.hpp"
10
#include "XdmfTime.hpp"
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
#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();
		}
	}
52 53 54 55
	else if(itemTag.compare(XdmfInformation::ItemTag) == 0)
	{
		newItem = XdmfInformation::New();
	}
56 57 58 59
	else if(itemTag.compare(XdmfSet::ItemTag) == 0)
	{
		newItem = XdmfSet::New();
	}
60 61 62 63
	else if(itemTag.compare(XdmfTime::ItemTag) == 0)
	{
		newItem = XdmfTime::New();
	}
64 65 66 67 68 69 70 71 72 73
	else if(itemTag.compare(XdmfTopology::ItemTag) == 0)
	{
		newItem = XdmfTopology::New();
	}
	else
	{
		assert(false);
	}
	return newItem;
}