/*****************************************************************************/ /* XDMF */ /* eXtensible Data Model and Format */ /* */ /* Id : XdmfAttribute.cpp */ /* */ /* Author: */ /* Kenneth Leiter */ /* kenneth.leiter@arl.army.mil */ /* US Army Research Laboratory */ /* Aberdeen Proving Ground, MD */ /* */ /* Copyright @ 2011 US Army Research Laboratory */ /* All Rights Reserved */ /* See Copyright.txt for details */ /* */ /* 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 #include "XdmfAttribute.hpp" #include "XdmfAttributeCenter.hpp" #include "XdmfAttributeType.hpp" #include "XdmfError.hpp" shared_ptr XdmfAttribute::New() { shared_ptr p(new XdmfAttribute()); return p; } XdmfAttribute::XdmfAttribute() : mCenter(XdmfAttributeCenter::Grid()), mName(""), mType(XdmfAttributeType::NoAttributeType()) { } XdmfAttribute::~XdmfAttribute() { } const std::string XdmfAttribute::ItemTag = "Attribute"; shared_ptr XdmfAttribute::getCenter() const { return mCenter; } std::map XdmfAttribute::getItemProperties() const { std::map attributeProperties; attributeProperties.insert(std::make_pair("Name", mName)); mType->getProperties(attributeProperties); mCenter->getProperties(attributeProperties); return attributeProperties; } std::string XdmfAttribute::getItemTag() const { return ItemTag; } std::string XdmfAttribute::getName() const { return mName; } shared_ptr XdmfAttribute::getType() const { return mType; } void XdmfAttribute::populateItem(const std::map & itemProperties, const std::vector > & childItems, const XdmfCoreReader * const reader) { XdmfItem::populateItem(itemProperties, childItems, reader); std::map::const_iterator name = itemProperties.find("Name"); if(name != itemProperties.end()) { mName = name->second; } else { XdmfError::message(XdmfError::FATAL, "'Name' not found in itemProperties in " "XdmfAttribute::populateItem"); } mCenter = XdmfAttributeCenter::New(itemProperties); mType = XdmfAttributeType::New(itemProperties); for(std::vector >::const_iterator iter = childItems.begin(); iter != childItems.end(); ++iter) { if(shared_ptr array = shared_dynamic_cast(*iter)) { this->swap(array); break; } } } void XdmfAttribute::setCenter(const shared_ptr center) { mCenter = center; } void XdmfAttribute::setName(const std::string & name) { mName= name; } void XdmfAttribute::setType(const shared_ptr type) { mType = type; }