XdmfAttributeCenter.cpp 2.04 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/*
 * XdmfAttributeCenter.cpp
 *
 *  Created on: Jan 29, 2010
 *      Author: kleiter
 */

#include "XdmfAttributeCenter.hpp"

// Supported XdmfAttributeCenters
11
boost::shared_ptr<const XdmfAttributeCenter> XdmfAttributeCenter::Grid()
12
{
13 14
	static boost::shared_ptr<const XdmfAttributeCenter> p(new XdmfAttributeCenter("Grid"));
	return p;
15 16
}

17
boost::shared_ptr<const XdmfAttributeCenter> XdmfAttributeCenter::Cell()
18
{
19 20
	static boost::shared_ptr<const XdmfAttributeCenter> p(new XdmfAttributeCenter("Cell"));
	return p;
21 22
}

23
boost::shared_ptr<const XdmfAttributeCenter> XdmfAttributeCenter::Face()
24
{
25 26
	static boost::shared_ptr<const XdmfAttributeCenter> p(new XdmfAttributeCenter("Face"));
	return p;
27 28
}

29
boost::shared_ptr<const XdmfAttributeCenter> XdmfAttributeCenter::Edge()
30
{
31 32
	static boost::shared_ptr<const XdmfAttributeCenter> p(new XdmfAttributeCenter("Edge"));
	return p;
33 34
}

35
boost::shared_ptr<const XdmfAttributeCenter> XdmfAttributeCenter::Node()
36
{
37 38
	static boost::shared_ptr<const XdmfAttributeCenter> p(new XdmfAttributeCenter("Node"));
	return p;
39 40
}

41
XdmfAttributeCenter::XdmfAttributeCenter(const std::string & name) :
42
	mName(name)
43 44
{
}
45

46
XdmfAttributeCenter::~XdmfAttributeCenter()
47 48 49
{
}

50
boost::shared_ptr<const XdmfAttributeCenter> XdmfAttributeCenter::New(const std::map<std::string, std::string> & itemProperties)
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
{
	std::map<std::string, std::string>::const_iterator center = itemProperties.find("Center");
	if(center != itemProperties.end())
	{
		const std::string centerVal = center->second;
		if(centerVal.compare("Grid") == 0)
		{
			return Grid();
		}
		else if(centerVal.compare("Cell") == 0)
		{
			return Cell();
		}
		else if(centerVal.compare("Face") == 0)
		{
			return Face();
		}
		else if(centerVal.compare("Edge") == 0)
		{
			return Edge();
		}
		else if(centerVal.compare("Node") == 0)
		{
			return Node();
		}
		else
		{
			assert(false);
		}
	}
	assert(false);
82
    return boost::shared_ptr<const XdmfAttributeCenter>();
83 84
}

85 86
void XdmfAttributeCenter::getProperties(std::map<std::string, std::string> & collectedProperties) const
{
87
	collectedProperties["Center"] = mName;
88
}