Commit 94f61d16 authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Modify ItemProperties to use shared pointers like the rest of Xdmf. ...

ENH: Modify ItemProperties to use shared pointers like the rest of Xdmf.  Modify swig wrapping to correctly
handle both non const and const shared pointers.
parent 0457f2ee
......@@ -38,6 +38,12 @@ namespace boost {
};
}
// Macro for defining shared pointer templates:
%define SWIG_SHARED_PTR_TEMPLATE(CLASS...)
%template(CLASS ## _Ptr) boost::shared_ptr< CLASS >;
%template(CLASS ## _ConstPtr) boost::shared_ptr< const CLASS >;
%enddef
// Macro for defining shared pointer inheritances:
%define SWIG_SHARED_PTR_DERIVED(CLASS, BASECLASS...)
%types(boost::shared_ptr< CLASS > = boost::shared_ptr< BASECLASS > ) %{
......@@ -52,23 +58,30 @@ namespace boost {
%include loki/Visitor.h
// Shared Pointer Templates
%template(XdmfAttributePtr) boost::shared_ptr<XdmfAttribute>;
%template(XdmfArrayPtr) boost::shared_ptr<XdmfArray>;
%template(XdmfBaseVisitorPtr) boost::shared_ptr<Loki::BaseVisitor>;
%template(XdmfDataItemPtr) boost::shared_ptr<XdmfDataItem>;
%template(XdmfDomainPtr) boost::shared_ptr<XdmfDomain>;
%template(XdmfGeometryPtr) boost::shared_ptr<XdmfGeometry>;
%template(XdmfGridPtr) boost::shared_ptr<XdmfGrid>;
%template(XdmfGridCollectionPtr) boost::shared_ptr<XdmfGridCollection>;
%template(XdmfHDF5ControllerPtr) boost::shared_ptr<XdmfHDF5Controller>;
%template(XdmfHDF5WriterPtr) boost::shared_ptr<XdmfHDF5Writer>;
%template(XdmfItemPtr) boost::shared_ptr<XdmfItem>;
%template(XdmfObjPtr) boost::shared_ptr<XdmfObject>;
%template(XdmfReaderPtr) boost::shared_ptr<XdmfReader>;
%template(XdmfSetPtr) boost::shared_ptr<XdmfSet>;
%template(XdmfTopologyPtr) boost::shared_ptr<XdmfTopology>;
%template(XdmfVisitorPtr) boost::shared_ptr<XdmfVisitor>;
%template(XdmfWriterPtr) boost::shared_ptr<XdmfWriter>;
SWIG_SHARED_PTR_TEMPLATE(XdmfArray);
SWIG_SHARED_PTR_TEMPLATE(XdmfAttribute);
SWIG_SHARED_PTR_TEMPLATE(XdmfAttributeCenter);
SWIG_SHARED_PTR_TEMPLATE(XdmfAttributeType);
SWIG_SHARED_PTR_TEMPLATE(XdmfBaseVisitor);
SWIG_SHARED_PTR_TEMPLATE(XdmfDataItem);
SWIG_SHARED_PTR_TEMPLATE(XdmfDomain);
SWIG_SHARED_PTR_TEMPLATE(XdmfGeometry);
SWIG_SHARED_PTR_TEMPLATE(XdmfGeometryType);
SWIG_SHARED_PTR_TEMPLATE(XdmfGrid);
SWIG_SHARED_PTR_TEMPLATE(XdmfGridCollection);
SWIG_SHARED_PTR_TEMPLATE(XdmfGridCollectionType);
SWIG_SHARED_PTR_TEMPLATE(XdmfHDF5Controller);
SWIG_SHARED_PTR_TEMPLATE(XdmfHDF5Writer);
SWIG_SHARED_PTR_TEMPLATE(XdmfItem);
SWIG_SHARED_PTR_TEMPLATE(XdmfItemProperty);
SWIG_SHARED_PTR_TEMPLATE(XdmfObject);
SWIG_SHARED_PTR_TEMPLATE(XdmfReader);
SWIG_SHARED_PTR_TEMPLATE(XdmfSet);
SWIG_SHARED_PTR_TEMPLATE(XdmfSetType);
SWIG_SHARED_PTR_TEMPLATE(XdmfTopology);
SWIG_SHARED_PTR_TEMPLATE(XdmfTopologyType);
SWIG_SHARED_PTR_TEMPLATE(XdmfVisitor);
SWIG_SHARED_PTR_TEMPLATE(XdmfWriter);
// Abstract Base Classes
%template() Loki::BaseVisitable<void>;
......@@ -85,6 +98,10 @@ SWIG_SHARED_PTR_DERIVED(XdmfArray, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfAttribute, XdmfDataItem);
SWIG_SHARED_PTR_DERIVED(XdmfAttribute, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfAttribute, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfAttributeCenter, XdmfItemProperty)
SWIG_SHARED_PTR_DERIVED(XdmfAttributeCenter, XdmfObject)
SWIG_SHARED_PTR_DERIVED(XdmfAttributeType, XdmfItemProperty)
SWIG_SHARED_PTR_DERIVED(XdmfAttributeType, XdmfObject)
SWIG_SHARED_PTR_DERIVED(XdmfDataItem, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfDataItem, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfDomain, XdmfItem);
......@@ -92,27 +109,36 @@ SWIG_SHARED_PTR_DERIVED(XdmfDomain, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfGeometry, XdmfDataItem);
SWIG_SHARED_PTR_DERIVED(XdmfGeometry, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfGeometry, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfGeometryType, XdmfItemProperty)
SWIG_SHARED_PTR_DERIVED(XdmfGeometryType, XdmfObject)
SWIG_SHARED_PTR_DERIVED(XdmfGrid, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfGrid, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfGridCollection, XdmfGrid);
SWIG_SHARED_PTR_DERIVED(XdmfGridCollection, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfGridCollection, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfGridCollectionType, XdmfItemProperty)
SWIG_SHARED_PTR_DERIVED(XdmfGridCollectionType, XdmfObject)
SWIG_SHARED_PTR_DERIVED(XdmfHDF5Controller, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfHDF5Writer, XdmfVisitor);
SWIG_SHARED_PTR_DERIVED(XdmfHDF5Writer, Loki::BaseVisitor);
SWIG_SHARED_PTR_DERIVED(XdmfHDF5Writer, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfItem, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfItemProperty, XdmfObject)
SWIG_SHARED_PTR_DERIVED(XdmfReader, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfSet, XdmfDataItem);
SWIG_SHARED_PTR_DERIVED(XdmfSet, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfSet, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfSetType, XdmfItemProperty)
SWIG_SHARED_PTR_DERIVED(XdmfSetType, XdmfObject)
SWIG_SHARED_PTR_DERIVED(XdmfTopology, XdmfDataItem);
SWIG_SHARED_PTR_DERIVED(XdmfTopology, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfTopology, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfVisitor, Loki::BaseVisitor);
SWIG_SHARED_PTR_DERIVED(XdmfTopologyType, XdmfItemProperty)
SWIG_SHARED_PTR_DERIVED(XdmfTopologyType, XdmfObject)
SWIG_SHARED_PTR_DERIVED(XdmfVisitor, XdmfBaseVisitor);
SWIG_SHARED_PTR_DERIVED(XdmfVisitor, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfWriter, XdmfVisitor);
SWIG_SHARED_PTR_DERIVED(XdmfWriter, Loki::BaseVisitor);
SWIG_SHARED_PTR_DERIVED(XdmfWriter, XdmfBaseVisitor);
SWIG_SHARED_PTR_DERIVED(XdmfWriter, XdmfObject);
%include XdmfObject.hpp
......
......@@ -204,7 +204,7 @@ public:
void read();
/**
* Release all data from currently held in memory.
* Release all data currently held in memory.
*/
void release();
......
......@@ -6,6 +6,8 @@
*/
#include "XdmfAttribute.hpp"
#include "XdmfAttributeCenter.hpp"
#include "XdmfAttributeType.hpp"
XdmfAttribute::XdmfAttribute() :
mName(""),
......@@ -22,12 +24,12 @@ XdmfAttribute::~XdmfAttribute()
std::string XdmfAttribute::ItemTag = "Attribute";
XdmfAttributeCenter XdmfAttribute::getAttributeCenter() const
boost::shared_ptr<const XdmfAttributeCenter> XdmfAttribute::getAttributeCenter() const
{
return mAttributeCenter;
}
XdmfAttributeType XdmfAttribute::getAttributeType() const
boost::shared_ptr<const XdmfAttributeType> XdmfAttribute::getAttributeType() const
{
return mAttributeType;
}
......@@ -36,8 +38,8 @@ std::map<std::string, std::string> XdmfAttribute::getItemProperties() const
{
std::map<std::string, std::string> attributeProperties;
attributeProperties["Name"] = mName;
mAttributeType.getProperties(attributeProperties);
mAttributeCenter.getProperties(attributeProperties);
mAttributeType->getProperties(attributeProperties);
mAttributeCenter->getProperties(attributeProperties);
return attributeProperties;
}
......@@ -68,12 +70,12 @@ void XdmfAttribute::populateItem(const std::map<std::string, std::string> & item
XdmfDataItem::populateItem(itemProperties, childItems);
}
void XdmfAttribute::setAttributeCenter(const XdmfAttributeCenter & attributeCenter)
void XdmfAttribute::setAttributeCenter(const boost::shared_ptr<const XdmfAttributeCenter> attributeCenter)
{
mAttributeCenter = attributeCenter;
}
void XdmfAttribute::setAttributeType(const XdmfAttributeType & attributeType)
void XdmfAttribute::setAttributeType(const boost::shared_ptr<const XdmfAttributeType> attributeType)
{
mAttributeType = attributeType;
}
......
#ifndef XDMFATTRIBUTE_HPP_
#define XDMFATTRIBUTE_HPP_
// Forward Declarations
class XdmfAttributeCenter;
class XdmfAttributeType;
// Includes
#include "XdmfAttributeCenter.hpp"
#include "XdmfAttributeType.hpp"
#include "XdmfDataItem.hpp"
/**
......@@ -25,14 +27,14 @@ public:
*
* @return XdmfAttributeCenter of the attribute.
*/
XdmfAttributeCenter getAttributeCenter() const;
boost::shared_ptr<const XdmfAttributeCenter> getAttributeCenter() const;
/**
* Get the XdmfAttributeType associated with this attribute.
*
* @return XdmfAttributeType of the attribute.
*/
XdmfAttributeType getAttributeType() const;
boost::shared_ptr<const XdmfAttributeType> getAttributeType() const;
std::map<std::string, std::string> getItemProperties() const;
......@@ -50,14 +52,14 @@ public:
*
* @param attributeCenter the XdmfAttributeCenter to set.
*/
void setAttributeCenter(const XdmfAttributeCenter & attributeCenter);
void setAttributeCenter(const boost::shared_ptr<const XdmfAttributeCenter> attributeCenter);
/**
* Set the XdmfAttributeType associated with this attribute.
*
* @param attributeType XdmfAttributeType to set.
*/
void setAttributeType(const XdmfAttributeType & attributeType);
void setAttributeType(const boost::shared_ptr<const XdmfAttributeType> attributeType);
/**
* Set the name of the attribute.
......@@ -78,8 +80,8 @@ private:
void operator=(const XdmfAttribute & attribute); // Not implemented.
std::string mName;
XdmfAttributeType mAttributeType;
XdmfAttributeCenter mAttributeCenter;
boost::shared_ptr<const XdmfAttributeType> mAttributeType;
boost::shared_ptr<const XdmfAttributeCenter> mAttributeCenter;
};
#endif /* XDMFATTRIBUTE_HPP_ */
......@@ -8,29 +8,34 @@
#include "XdmfAttributeCenter.hpp"
// Supported XdmfAttributeCenters
XdmfAttributeCenter XdmfAttributeCenter::Grid()
boost::shared_ptr<const XdmfAttributeCenter> XdmfAttributeCenter::Grid()
{
return XdmfAttributeCenter("Grid");
static boost::shared_ptr<const XdmfAttributeCenter> p(new XdmfAttributeCenter("Grid"));
return p;
}
XdmfAttributeCenter XdmfAttributeCenter::Cell()
boost::shared_ptr<const XdmfAttributeCenter> XdmfAttributeCenter::Cell()
{
return XdmfAttributeCenter("Cell");
static boost::shared_ptr<const XdmfAttributeCenter> p(new XdmfAttributeCenter("Cell"));
return p;
}
XdmfAttributeCenter XdmfAttributeCenter::Face()
boost::shared_ptr<const XdmfAttributeCenter> XdmfAttributeCenter::Face()
{
return XdmfAttributeCenter("Face");
static boost::shared_ptr<const XdmfAttributeCenter> p(new XdmfAttributeCenter("Face"));
return p;
}
XdmfAttributeCenter XdmfAttributeCenter::Edge()
boost::shared_ptr<const XdmfAttributeCenter> XdmfAttributeCenter::Edge()
{
return XdmfAttributeCenter("Edge");
static boost::shared_ptr<const XdmfAttributeCenter> p(new XdmfAttributeCenter("Edge"));
return p;
}
XdmfAttributeCenter XdmfAttributeCenter::Node()
boost::shared_ptr<const XdmfAttributeCenter> XdmfAttributeCenter::Node()
{
return XdmfAttributeCenter("Node");
static boost::shared_ptr<const XdmfAttributeCenter> p(new XdmfAttributeCenter("Node"));
return p;
}
XdmfAttributeCenter::XdmfAttributeCenter(const std::string & name) :
......@@ -38,12 +43,11 @@ XdmfAttributeCenter::XdmfAttributeCenter(const std::string & name) :
{
}
XdmfAttributeCenter::XdmfAttributeCenter(const XdmfAttributeCenter & attributeCenter):
mName(attributeCenter.mName)
XdmfAttributeCenter::~XdmfAttributeCenter()
{
}
XdmfAttributeCenter XdmfAttributeCenter::New(const std::map<std::string, std::string> & itemProperties)
boost::shared_ptr<const XdmfAttributeCenter> XdmfAttributeCenter::New(const std::map<std::string, std::string> & itemProperties)
{
std::map<std::string, std::string>::const_iterator center = itemProperties.find("Center");
if(center != itemProperties.end())
......@@ -77,15 +81,6 @@ XdmfAttributeCenter XdmfAttributeCenter::New(const std::map<std::string, std::st
assert(false);
}
XdmfAttributeCenter & XdmfAttributeCenter::operator=(const XdmfAttributeCenter & attributeCenter)
{
if(this != &attributeCenter)
{
mName = attributeCenter.mName;
}
return *this;
}
bool XdmfAttributeCenter::operator==(const XdmfAttributeCenter & attributeCenter) const
{
return mName.compare(attributeCenter.mName) == 0;
......
......@@ -23,13 +23,14 @@ class XdmfAttributeCenter : public XdmfItemProperty {
public:
friend class XdmfAttribute;
template <typename T> friend void boost::checked_delete(T * x);
// Supported Xdmf Attribute Centers
static XdmfAttributeCenter Grid();
static XdmfAttributeCenter Cell();
static XdmfAttributeCenter Face();
static XdmfAttributeCenter Edge();
static XdmfAttributeCenter Node();
static boost::shared_ptr<const XdmfAttributeCenter> Grid();
static boost::shared_ptr<const XdmfAttributeCenter> Cell();
static boost::shared_ptr<const XdmfAttributeCenter> Face();
static boost::shared_ptr<const XdmfAttributeCenter> Edge();
static boost::shared_ptr<const XdmfAttributeCenter> Node();
void getProperties(std::map<std::string, std::string> & collectedProperties) const;
......@@ -49,9 +50,6 @@ public:
*/
bool operator!=(const XdmfAttributeCenter & attributeCenter) const;
XdmfAttributeCenter(const XdmfAttributeCenter & attributeCenter);
XdmfAttributeCenter & operator=(const XdmfAttributeCenter & attributeCenter);
protected:
/**
......@@ -62,10 +60,14 @@ protected:
* @param name the name of the XdmfAttributeCenter to construct.
*/
XdmfAttributeCenter(const std::string & name);
~XdmfAttributeCenter();
private:
static XdmfAttributeCenter New(const std::map<std::string, std::string> & itemProperties);
XdmfAttributeCenter(const XdmfAttributeCenter & attributeCenter); // Not implemented.
void operator=(const XdmfAttributeCenter & attributeCenter); // Not implemented.
static boost::shared_ptr<const XdmfAttributeCenter> New(const std::map<std::string, std::string> & itemProperties);
std::string mName;
};
......
......@@ -8,52 +8,60 @@
#include "XdmfAttributeType.hpp"
// Supported XdmfAttributeTypes
XdmfAttributeType XdmfAttributeType::NoAttributeType()
boost::shared_ptr<const XdmfAttributeType> XdmfAttributeType::NoAttributeType()
{
return XdmfAttributeType("None");
static boost::shared_ptr<const XdmfAttributeType> p(new XdmfAttributeType("None"));
return p;
}
XdmfAttributeType XdmfAttributeType::Scalar()
boost::shared_ptr<const XdmfAttributeType> XdmfAttributeType::Scalar()
{
return XdmfAttributeType("Scalar");
static boost::shared_ptr<const XdmfAttributeType> p(new XdmfAttributeType("Scalar"));
return p;
}
XdmfAttributeType XdmfAttributeType::Vector()
boost::shared_ptr<const XdmfAttributeType> XdmfAttributeType::Vector()
{
return XdmfAttributeType("Vector");
static boost::shared_ptr<const XdmfAttributeType> p(new XdmfAttributeType("Vector"));
return p;
}
XdmfAttributeType XdmfAttributeType::Tensor()
boost::shared_ptr<const XdmfAttributeType> XdmfAttributeType::Tensor()
{
return XdmfAttributeType("Tensor");
static boost::shared_ptr<const XdmfAttributeType> p(new XdmfAttributeType("Tensor"));
return p;
}
XdmfAttributeType XdmfAttributeType::Matrix()
boost::shared_ptr<const XdmfAttributeType> XdmfAttributeType::Matrix()
{
return XdmfAttributeType("Matrix");
static boost::shared_ptr<const XdmfAttributeType> p(new XdmfAttributeType("Matrix"));
return p;
}
XdmfAttributeType XdmfAttributeType::Tensor6()
boost::shared_ptr<const XdmfAttributeType> XdmfAttributeType::Tensor6()
{
return XdmfAttributeType("Tensor6");
static boost::shared_ptr<const XdmfAttributeType> p(new XdmfAttributeType("Tensor6"));
return p;
}
XdmfAttributeType XdmfAttributeType::GlobalId()
boost::shared_ptr<const XdmfAttributeType> XdmfAttributeType::GlobalId()
{
return XdmfAttributeType("GlobalId");
static boost::shared_ptr<const XdmfAttributeType> p(new XdmfAttributeType("GlobalId"));
return p;
}
XdmfAttributeType::XdmfAttributeType(const std::string & name) :
mName(name)
{
std::cout << "CRRRRREATED" << std::endl;
}
XdmfAttributeType::XdmfAttributeType(const XdmfAttributeType & attributeType):
mName(attributeType.mName)
XdmfAttributeType::~XdmfAttributeType()
{
std::cout << "DEEEELETED" << std::endl;
}
XdmfAttributeType XdmfAttributeType::New(const std::map<std::string, std::string> & itemProperties)
boost::shared_ptr<const XdmfAttributeType> XdmfAttributeType::New(const std::map<std::string, std::string> & itemProperties)
{
std::map<std::string, std::string>::const_iterator type = itemProperties.find("AttributeType");
if(type != itemProperties.end())
......@@ -95,15 +103,6 @@ XdmfAttributeType XdmfAttributeType::New(const std::map<std::string, std::string
assert(false);
}
XdmfAttributeType & XdmfAttributeType::operator=(const XdmfAttributeType & attributeType)
{
if(this != &attributeType)
{
mName = attributeType.mName;
}
return *this;
}
bool XdmfAttributeType::operator==(const XdmfAttributeType & attributeType) const
{
return mName.compare(attributeType.mName) == 0;
......
......@@ -25,15 +25,16 @@ class XdmfAttributeType : public XdmfItemProperty {
public:
friend class XdmfAttribute;
template <typename T> friend void boost::checked_delete(T * x);
// Supported Xdmf Attribute Types
static XdmfAttributeType NoAttributeType();
static XdmfAttributeType Scalar();
static XdmfAttributeType Vector();
static XdmfAttributeType Tensor();
static XdmfAttributeType Matrix();
static XdmfAttributeType Tensor6();
static XdmfAttributeType GlobalId();
static boost::shared_ptr<const XdmfAttributeType> NoAttributeType();
static boost::shared_ptr<const XdmfAttributeType> Scalar();
static boost::shared_ptr<const XdmfAttributeType> Vector();
static boost::shared_ptr<const XdmfAttributeType> Tensor();
static boost::shared_ptr<const XdmfAttributeType> Matrix();
static boost::shared_ptr<const XdmfAttributeType> Tensor6();
static boost::shared_ptr<const XdmfAttributeType> GlobalId();
void getProperties(std::map<std::string, std::string> & collectedProperties) const;
......@@ -53,9 +54,6 @@ public:
*/
bool operator!=(const XdmfAttributeType & attributeType) const;
XdmfAttributeType(const XdmfAttributeType & attributeType);
XdmfAttributeType & operator=(const XdmfAttributeType & attributeType);
protected:
/**
......@@ -66,10 +64,14 @@ protected:
* @param name the name of the XdmfAttributeType to construct.
*/
XdmfAttributeType(const std::string & name);
~XdmfAttributeType();
private:
static XdmfAttributeType New(const std::map<std::string, std::string> & itemProperties);
XdmfAttributeType(const XdmfAttributeType & attributeType); // Not implemented.
void operator=(const XdmfAttributeType & attributeType); // Not implemented.
static boost::shared_ptr<const XdmfAttributeType> New(const std::map<std::string, std::string> & itemProperties);
std::string mName;
};
......
......@@ -45,7 +45,7 @@ void XdmfDataItem::setArray(boost::shared_ptr<XdmfArray> array)
mArray = array;
}
void XdmfDataItem::traverse(boost::shared_ptr<Loki::BaseVisitor> visitor)
void XdmfDataItem::traverse(boost::shared_ptr<XdmfBaseVisitor> visitor)
{
mArray->accept(visitor);
}
......@@ -40,7 +40,7 @@ public:
*/
void setArray(boost::shared_ptr<XdmfArray> array);
virtual void traverse(boost::shared_ptr<Loki::BaseVisitor> visitor);
virtual void traverse(boost::shared_ptr<XdmfBaseVisitor> visitor);
protected:
......
......@@ -78,7 +78,7 @@ void XdmfDomain::removeGrid(const unsigned int index)
mGrids.erase(mGrids.begin() + index);
}
void XdmfDomain::traverse(boost::shared_ptr<Loki::BaseVisitor> visitor)
void XdmfDomain::traverse(boost::shared_ptr<XdmfBaseVisitor> visitor)
{
for(std::vector<boost::shared_ptr<XdmfGrid> >::const_iterator iter = mGrids.begin(); iter != mGrids.end(); ++iter)
{
......
......@@ -62,7 +62,7 @@ public:
*/
void removeGrid(const unsigned int index);
virtual void traverse(boost::shared_ptr<Loki::BaseVisitor> visitor);
virtual void traverse(boost::shared_ptr<XdmfBaseVisitor> visitor);
protected:
......
......@@ -7,6 +7,7 @@
#include "XdmfArray.hpp"
#include "XdmfGeometry.hpp"
#include "XdmfGeometryType.hpp"
XdmfGeometry::XdmfGeometry() :
mGeometryType(XdmfGeometryType::NoGeometryType()),
......@@ -22,7 +23,7 @@ XdmfGeometry::~XdmfGeometry()
std::string XdmfGeometry::ItemTag = "Geometry";
XdmfGeometryType XdmfGeometry::getGeometryType() const
boost::shared_ptr<const XdmfGeometryType> XdmfGeometry::getGeometryType() const
{
return mGeometryType;
}
......@@ -30,7 +31,7 @@ XdmfGeometryType XdmfGeometry::getGeometryType() const
std::map<std::string, std::string> XdmfGeometry::getItemProperties() const
{
std::map<std::string, std::string> geometryProperties;
mGeometryType.getProperties(geometryProperties);
mGeometryType->getProperties(geometryProperties);
return geometryProperties;
}
......@@ -41,11 +42,11 @@ std::string XdmfGeometry::getItemTag() const
unsigned int XdmfGeometry::getNumberPoints() const
{
if(mGeometryType.getDimensions() == 0)
if(mGeometryType->getDimensions() == 0)
{
return 0;
}
return this->getArray()->getSize() / mGeometryType.getDimensions();
return this->getArray()->getSize() / mGeometryType->getDimensions();
}
void XdmfGeometry::populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems)
......@@ -54,7 +55,7 @@ void XdmfGeometry::populateItem(const std::map<std::string, std::string> & itemP
XdmfDataItem::populateItem(itemProperties, childItems);
}
void XdmfGeometry::setGeometryType(const XdmfGeometryType & geometryType)
void XdmfGeometry::setGeometryType(const boost::shared_ptr<const XdmfGeometryType> geometryType)
{
mGeometryType = geometryType;
}
#ifndef XDMFGEOMETRY_HPP_
#define XDMFGEOMETRY_HPP_
// Forward Declarations
class XdmfGeometryType;
// Includes
#include "XdmfDataItem.hpp"
#include "XdmfGeometryType.hpp"
/**
* @brief Handles the coordinate positions of points in an XdmfGrid.
......@@ -25,7 +27,7 @@ public:
*
* @return XdmfGeometryType of this geometry.
*/
XdmfGeometryType getGeometryType() const;
boost::shared_ptr<const XdmfGeometryType> getGeometryType() const;
std::map<std::string, std::string> getItemProperties() const;
......@@ -41,7 +43,7 @@ public:
*
* @param geometryType the XdmfGeometryType to set.
*/
void setGeometryType(const XdmfGeometryType & geometryType);
void setGeometryType(const boost::shared_ptr<const XdmfGeometryType> geometryType);
protected:
......@@ -54,7 +56,7 @@ private:
XdmfGeometry(const XdmfGeometry & geometry); // Not implemented.
void operator=(const XdmfGeometry & geometry); // Not implemented.
XdmfGeometryType mGeometryType;
boost::shared_ptr<const XdmfGeometryType> mGeometryType;
int mNumberPoints;
};
......
......@@ -8,55 +8,58 @@
#include "XdmfGeometryType.hpp"
// Supported XdmfGeometryTypes
XdmfGeometryType XdmfGeometryType::NoGeometryType()
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::NoGeometryType()
{
return XdmfGeometryType("NONE", 0);
static boost::shared_ptr<const XdmfGeometryType> p(new XdmfGeometryType("None", 0));
return p;
}
XdmfGeometryType XdmfGeometryType::XYZ()
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::XYZ()
{
return XdmfGeometryType("XYZ", 3);
static boost::shared_ptr<const XdmfGeometryType> p(new XdmfGeometryType("XYZ", 3));
return p;
}
XdmfGeometryType XdmfGeometryType::XY()
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::XY()
{
return XdmfGeometryType("XY", 2);
static boost::shared_ptr<const XdmfGeometryType> p(new XdmfGeometryType("XY", 2));
return p;
}
XdmfGeometryType XdmfGeometryType::X_Y_Z()
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::X_Y_Z()
{
return XdmfGeometryType("X_Y_Z", 3);
static boost::shared_ptr<const XdmfGeometryType> p(new XdmfGeometryType("X_Y_Z", 3));
return p;
}
XdmfGeometryType XdmfGeometryType::X_Y()
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::X_Y()
{
return XdmfGeometryType("X_Y", 2);
static boost::shared_ptr<const XdmfGeometryType> p(new XdmfGeometryType("X_Y", 2));
return p;
}
XdmfGeometryType XdmfGeometryType::VXVYVZ()
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::VXVYVZ()
{
return XdmfGeometryType("VXVYVZ", 3);
static boost::shared_ptr<const XdmfGeometryType> p(new XdmfGeometryType("VXVYVZ", 3));
return p;
}
XdmfGeometryType XdmfGeometryType::Origin_DXDYDZ()
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::Origin_DXDYDZ()
{
return XdmfGeometryType("ORIGIN_DXDYDZ", 3);
static boost::shared_ptr<const XdmfGeometryType> p(new XdmfGeometryType("ORIGIN_DXDYDZ", 3));
return p;
}
XdmfGeometryType XdmfGeometryType::VXVY()
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::VXVY()
{
return XdmfGeometryType("VXVY", 2);
static boost::shared_ptr<const XdmfGeometryType> p(new XdmfGeometryType("VXVY", 2));
return p;
}
XdmfGeometryType XdmfGeometryType::Origin_DXDY()
{
return XdmfGeometryType("ORIGIN_DXDY", 2);
}
XdmfGeometryType::XdmfGeometryType(const XdmfGeometryType& geometryType):
mDimensions(geometryType.mDimensions),
mName(geometryType.mName)
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::Origin_DXDY()
{
static boost::shared_ptr<const XdmfGeometryType> p(new XdmfGeometryType("ORIGIN_DXDY", 2));
return p;
}
XdmfGeometryType::XdmfGeometryType(const std::string& name, const int& dimensions) :
......@@ -65,13 +68,13 @@ XdmfGeometryType::XdmfGeometryType(const std::string& name, const int& dimension
{
}
XdmfGeometryType XdmfGeometryType::New(const std::map<std::string, std::string> & itemProperties)
boost::shared_ptr<const XdmfGeometryType> XdmfGeometryType::New(const std::map<std::string, std::string> & itemProperties)
{
std::map<std::string, std::string>::const_iterator type = itemProperties.find("GeometryType");
if(type != itemProperties.end())
{
const std::string typeVal = type->second;
if(typeVal.compare("NONE") == 0)
if(typeVal.compare("None") == 0)
{
return NoGeometryType();
}