XdmfSetType.cpp 1.73 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 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
/*
 * XdmfSetType.cpp
 *
 *  Created on: Jan 29, 2010
 *      Author: kleiter
 */

#include "XdmfSetType.hpp"

// Supported XdmfSetTypes
XdmfSetType XdmfSetType::NoSetType()
{
	return XdmfSetType("None");
}

XdmfSetType XdmfSetType::Node()
{
	return XdmfSetType("Node");
}

XdmfSetType XdmfSetType::Cell()
{
	return XdmfSetType("Cell");
}

XdmfSetType XdmfSetType::Face()
{
	return XdmfSetType("Face");
}

XdmfSetType XdmfSetType::Edge()
{
	return XdmfSetType("Edge");
}

XdmfSetType::XdmfSetType(const XdmfSetType & setType):
	mName(setType.mName)
{
}

XdmfSetType::XdmfSetType(const std::string & name) :
	mName(name)
{
}

XdmfSetType XdmfSetType::New(const std::map<std::string, std::string> & itemProperties)
{
	std::map<std::string, std::string>::const_iterator type = itemProperties.find("SetType");
	if(type != itemProperties.end())
	{
		const std::string typeVal = type->second;
		if(typeVal.compare("None") == 0)
		{
			return NoSetType();
		}
		else if(typeVal.compare("Node") == 0)
		{
			return Node();
		}
		else if(typeVal.compare("Cell") == 0)
		{
			return Cell();
		}
		else if(typeVal.compare("Face") == 0)
		{
			return Face();
		}
		else if(typeVal.compare("Edge") == 0)
		{
			return Edge();
		}
		else
		{
			assert(false);
		}
	}
	assert(false);
}

XdmfSetType & XdmfSetType::operator=(const XdmfSetType & setType)
{
	if(this != &setType)
	{
		mName = setType.mName;
	}
	return *this;
}

bool XdmfSetType::operator==(const XdmfSetType & setType) const
{
	return mName.compare(setType.mName) == 0;
}

bool XdmfSetType::operator!=(const XdmfSetType & setType) const
{
	return !this->operator==(setType);
}

void XdmfSetType::getProperties(std::map<std::string, std::string> & collectedProperties) const
{
	collectedProperties["SetType"] = this->mName;
}