Commit 637eab96 authored by Michal Habera's avatar Michal Habera

Added ItemType property for Attribute

parent 2b38aea7
/*****************************************************************************/
/* XDMF */
/* eXtensible Data Model and Format */
/* */
/* Id : XdmfAttributeItemType.hpp */
/* */
/* */
/* Author: */
/* Michal Habera */
/* habera<at>karlin.mff.cuni.cz */
/* */
/* This software is distributed WITHOUT ANY WARRANTY; without */
/* even the implied warranty of MERCHANTABILITY or FITNESS */
/* FOR A PARTICULAR PURPOSE. See the above copyright notice */
/* for more information. */
/* */
/*****************************************************************************/
#include <utility>
#include "XdmfAttributeItemType.hpp"
#include "XdmfError.hpp"
//-----------------------------------------------------------------------------
std::map<std::string, shared_ptr<const XdmfAttributeItemType>(*)()>
XdmfAttributeItemType::mAttributeDefinitions;
//-----------------------------------------------------------------------------
// Supported XdmfAttributeItemType
shared_ptr<const XdmfAttributeItemType>
XdmfAttributeItemType::NoAttributeItemType()
{
static shared_ptr<const XdmfAttributeItemType>
p(new XdmfAttributeItemType("None"));
return p;
}
//-----------------------------------------------------------------------------
shared_ptr<const XdmfAttributeItemType>
XdmfAttributeItemType::FiniteElementFunction()
{
static shared_ptr<const XdmfAttributeItemType>
p(new XdmfAttributeItemType("FiniteElementFunction"));
return p;
}
//-----------------------------------------------------------------------------
void XdmfAttributeItemType::InitTypes()
{
mAttributeDefinitions["NONE"] = NoAttributeType;
mAttributeDefinitions["FINITE_ELEMENT_FUNCTION"] = FiniteElementFunction;
}
//-----------------------------------------------------------------------------
XdmfAttributeItemType::XdmfAttributeItemType(const std::string & name) :
mName(name)
{
}
//-----------------------------------------------------------------------------
XdmfAttributeItemType::~XdmfAttributeItemType()
{
}
//-----------------------------------------------------------------------------
shared_ptr<const XdmfAttributeItemType> XdmfAttributeItemType::New(
const std::map<std::string, std::string &itemProperties)
{
InitTypes();
std::map<std::string, std::string>::const_iterator item_type =
itemProperties.find("ItemType");
const std::string & typeVal = ConvertToUpper(type->second);
std::map<std::string,
shared_ptr<const XdmfAttributeItemType>(*)()>::const_iterator
returnType = mAttributeDefinitions.find(typeVal);
if (returnType == mAttributeDefinitions.end()) {
XdmfError::message(XdmfError::FATAL,
"ItemType not of 'None','FiniteElementFunction' in "
"XdmfAttributeItemType::New");
}
else {
return (*(returnType->second))();
}
// unreachable
return shared_ptr<const XdmfAttributeItemType>();
}
//-----------------------------------------------------------------------------
void XdmfAttributeItemType::getProperties(
std::map<std::string, std::string>& collectedProperties) const
{
collectedProperties.insert(std::make_pair("ItemType", mName));
}
//-----------------------------------------------------------------------------
// C Wrappers
//-----------------------------------------------------------------------------
int XdmfAttributeItemTypeFiniteElementFunction()
{
return XDMF_ATTRIBUTE_ITEM_TYPE_FINITE_ELEMENT_FUNCTION;
}
\ No newline at end of file
/*****************************************************************************/
/* XDMF */
/* eXtensible Data Model and Format */
/* */
/* Id : XdmfAttributeItemType.hpp */
/* */
/* */
/* Author: */
/* Michal Habera */
/* habera<at>karlin.mff.cuni.cz */
/* */
/* This software is distributed WITHOUT ANY WARRANTY; without */
/* even the implied warranty of MERCHANTABILITY or FITNESS */
/* FOR A PARTICULAR PURPOSE. See the above copyright notice */
/* for more information. */
/* */
/*****************************************************************************/
#ifndef XDMFATTRIBUTEITEMTYPE_HPP_
#define XDMFATTRIBUTEITEMTYPE_HPP_
// C Compatible Includes
#include "Xdmf.hpp"
#ifdef __cplusplus
#include "XdmfItemProperty.hpp"
/**
* @brief Property describing the type of values an XdmfAttribute
* contains.
*
* XdmfAttributeItemType is a specific property of XdmfAttribute
* used to specify what type of values XdmfAttribute contains.
* Unlike XdmfAttributeType, this property does not specify rank
* of values (scalar, vector, tensor, etc) but more general
* framework is allowed. For example, FiniteElementFunction
* defines how to interpret content of Attribute as a finite
* element function.
*
* Xdmf supports the following attribute item types:
* FiniteElementFunction
*/
class XDMF_EXPORT XdmfAttributeItemType : public XdmfItemProperty {
{
public:
virtual ~XdmfAttributeItemType();
friend class XdmfAttribute;
// Supported Xdmf Attribute Types
static shared_ptr<const XdmfAttributeItemType> FiniteElementFunction();
void
getProperties(std::map<std::string, std::string> & collectedProperties) const;
protected:
/**
* Protected constructor for XdmfAttributeItemType. The constructor is
* protected because all attribute types supported by Xdmf should be
* accessed through more specific static methods that construct
* XdmfAttributeItemTypes - i.e.
* XdmfAttributeItemType::FiniteElementFunction().
*
* @param name The name of the XdmfAttributeItemType to construct.
*/
XdmfAttributeItemType(const std::string & name);
static std::map<std::string, shared_ptr<const XdmfAttributeItemType>(*)()>
mAttributeDefinitions;
static void InitTypes();
private:
XdmfAttributeItemType(const XdmfAttributeItemType &); // Not implemented.
void operator=(const XdmfAttributeItemType &); // Not implemented.
static shared_ptr<const XdmfAttributeItemType>
New(const std::map<std::string, std::string> & itemProperties);
std::string mName;
};
#endif
#ifdef __cplusplus
extern "C" {
#endif
// C wrappers go here
#define XDMF_ATTRIBUTE_ITEM_TYPE_FINITE_ELEMENT_FUNCTION 300
#define XDMF_ATTRIBUTE_ITEM_TYPE_NOTYPE 301
XDMF_EXPORT int XdmfAttributeItemTypeFiniteElementFunction();
XDMF_EXPORT int XdmfAttributeItemTypeNoAttributeItemType();
#ifdef __cplusplus
}
#endif
#endif // XDMFATTRIBUTEITEMTYPE_HPP_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment