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 { ...@@ -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: // Macro for defining shared pointer inheritances:
%define SWIG_SHARED_PTR_DERIVED(CLASS, BASECLASS...) %define SWIG_SHARED_PTR_DERIVED(CLASS, BASECLASS...)
%types(boost::shared_ptr< CLASS > = boost::shared_ptr< BASECLASS > ) %{ %types(boost::shared_ptr< CLASS > = boost::shared_ptr< BASECLASS > ) %{
...@@ -52,23 +58,30 @@ namespace boost { ...@@ -52,23 +58,30 @@ namespace boost {
%include loki/Visitor.h %include loki/Visitor.h
// Shared Pointer Templates // Shared Pointer Templates
%template(XdmfAttributePtr) boost::shared_ptr<XdmfAttribute>; SWIG_SHARED_PTR_TEMPLATE(XdmfArray);
%template(XdmfArrayPtr) boost::shared_ptr<XdmfArray>; SWIG_SHARED_PTR_TEMPLATE(XdmfAttribute);
%template(XdmfBaseVisitorPtr) boost::shared_ptr<Loki::BaseVisitor>; SWIG_SHARED_PTR_TEMPLATE(XdmfAttributeCenter);
%template(XdmfDataItemPtr) boost::shared_ptr<XdmfDataItem>; SWIG_SHARED_PTR_TEMPLATE(XdmfAttributeType);
%template(XdmfDomainPtr) boost::shared_ptr<XdmfDomain>; SWIG_SHARED_PTR_TEMPLATE(XdmfBaseVisitor);
%template(XdmfGeometryPtr) boost::shared_ptr<XdmfGeometry>; SWIG_SHARED_PTR_TEMPLATE(XdmfDataItem);
%template(XdmfGridPtr) boost::shared_ptr<XdmfGrid>; SWIG_SHARED_PTR_TEMPLATE(XdmfDomain);
%template(XdmfGridCollectionPtr) boost::shared_ptr<XdmfGridCollection>; SWIG_SHARED_PTR_TEMPLATE(XdmfGeometry);
%template(XdmfHDF5ControllerPtr) boost::shared_ptr<XdmfHDF5Controller>; SWIG_SHARED_PTR_TEMPLATE(XdmfGeometryType);
%template(XdmfHDF5WriterPtr) boost::shared_ptr<XdmfHDF5Writer>; SWIG_SHARED_PTR_TEMPLATE(XdmfGrid);
%template(XdmfItemPtr) boost::shared_ptr<XdmfItem>; SWIG_SHARED_PTR_TEMPLATE(XdmfGridCollection);
%template(XdmfObjPtr) boost::shared_ptr<XdmfObject>; SWIG_SHARED_PTR_TEMPLATE(XdmfGridCollectionType);
%template(XdmfReaderPtr) boost::shared_ptr<XdmfReader>; SWIG_SHARED_PTR_TEMPLATE(XdmfHDF5Controller);
%template(XdmfSetPtr) boost::shared_ptr<XdmfSet>; SWIG_SHARED_PTR_TEMPLATE(XdmfHDF5Writer);
%template(XdmfTopologyPtr) boost::shared_ptr<XdmfTopology>; SWIG_SHARED_PTR_TEMPLATE(XdmfItem);
%template(XdmfVisitorPtr) boost::shared_ptr<XdmfVisitor>; SWIG_SHARED_PTR_TEMPLATE(XdmfItemProperty);
%template(XdmfWriterPtr) boost::shared_ptr<XdmfWriter>; 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 // Abstract Base Classes
%template() Loki::BaseVisitable<void>; %template() Loki::BaseVisitable<void>;
...@@ -85,6 +98,10 @@ SWIG_SHARED_PTR_DERIVED(XdmfArray, XdmfObject); ...@@ -85,6 +98,10 @@ SWIG_SHARED_PTR_DERIVED(XdmfArray, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfAttribute, XdmfDataItem); SWIG_SHARED_PTR_DERIVED(XdmfAttribute, XdmfDataItem);
SWIG_SHARED_PTR_DERIVED(XdmfAttribute, XdmfItem); SWIG_SHARED_PTR_DERIVED(XdmfAttribute, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfAttribute, XdmfObject); 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, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfDataItem, XdmfObject); SWIG_SHARED_PTR_DERIVED(XdmfDataItem, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfDomain, XdmfItem); SWIG_SHARED_PTR_DERIVED(XdmfDomain, XdmfItem);
...@@ -92,27 +109,36 @@ SWIG_SHARED_PTR_DERIVED(XdmfDomain, XdmfObject); ...@@ -92,27 +109,36 @@ SWIG_SHARED_PTR_DERIVED(XdmfDomain, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfGeometry, XdmfDataItem); SWIG_SHARED_PTR_DERIVED(XdmfGeometry, XdmfDataItem);
SWIG_SHARED_PTR_DERIVED(XdmfGeometry, XdmfItem); SWIG_SHARED_PTR_DERIVED(XdmfGeometry, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfGeometry, XdmfObject); 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, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfGrid, XdmfObject); SWIG_SHARED_PTR_DERIVED(XdmfGrid, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfGridCollection, XdmfGrid); SWIG_SHARED_PTR_DERIVED(XdmfGridCollection, XdmfGrid);
SWIG_SHARED_PTR_DERIVED(XdmfGridCollection, XdmfItem); SWIG_SHARED_PTR_DERIVED(XdmfGridCollection, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfGridCollection, XdmfObject); 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(XdmfHDF5Controller, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfHDF5Writer, XdmfVisitor); SWIG_SHARED_PTR_DERIVED(XdmfHDF5Writer, XdmfVisitor);
SWIG_SHARED_PTR_DERIVED(XdmfHDF5Writer, Loki::BaseVisitor); SWIG_SHARED_PTR_DERIVED(XdmfHDF5Writer, Loki::BaseVisitor);
SWIG_SHARED_PTR_DERIVED(XdmfHDF5Writer, XdmfObject); SWIG_SHARED_PTR_DERIVED(XdmfHDF5Writer, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfItem, XdmfObject); SWIG_SHARED_PTR_DERIVED(XdmfItem, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfItemProperty, XdmfObject)
SWIG_SHARED_PTR_DERIVED(XdmfReader, XdmfObject); SWIG_SHARED_PTR_DERIVED(XdmfReader, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfSet, XdmfDataItem); SWIG_SHARED_PTR_DERIVED(XdmfSet, XdmfDataItem);
SWIG_SHARED_PTR_DERIVED(XdmfSet, XdmfItem); SWIG_SHARED_PTR_DERIVED(XdmfSet, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfSet, XdmfObject); 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, XdmfDataItem);
SWIG_SHARED_PTR_DERIVED(XdmfTopology, XdmfItem); SWIG_SHARED_PTR_DERIVED(XdmfTopology, XdmfItem);
SWIG_SHARED_PTR_DERIVED(XdmfTopology, XdmfObject); 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(XdmfVisitor, XdmfObject);
SWIG_SHARED_PTR_DERIVED(XdmfWriter, XdmfVisitor); 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); SWIG_SHARED_PTR_DERIVED(XdmfWriter, XdmfObject);
%include XdmfObject.hpp %include XdmfObject.hpp
......
...@@ -204,7 +204,7 @@ public: ...@@ -204,7 +204,7 @@ public:
void read(); void read();
/** /**
* Release all data from currently held in memory. * Release all data currently held in memory.
*/ */
void release(); void release();
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
*/ */
#include "XdmfAttribute.hpp" #include "XdmfAttribute.hpp"
#include "XdmfAttributeCenter.hpp"
#include "XdmfAttributeType.hpp"
XdmfAttribute::XdmfAttribute() : XdmfAttribute::XdmfAttribute() :
mName(""), mName(""),
...@@ -22,12 +24,12 @@ XdmfAttribute::~XdmfAttribute() ...@@ -22,12 +24,12 @@ XdmfAttribute::~XdmfAttribute()
std::string XdmfAttribute::ItemTag = "Attribute"; std::string XdmfAttribute::ItemTag = "Attribute";
XdmfAttributeCenter XdmfAttribute::getAttributeCenter() const boost::shared_ptr<const XdmfAttributeCenter> XdmfAttribute::getAttributeCenter() const
{ {
return mAttributeCenter; return mAttributeCenter;
} }
XdmfAttributeType XdmfAttribute::getAttributeType() const boost::shared_ptr<const XdmfAttributeType> XdmfAttribute::getAttributeType() const
{ {
return mAttributeType; return mAttributeType;
} }
...@@ -36,8 +38,8 @@ std::map<std::string, std::string> XdmfAttribute::getItemProperties() const ...@@ -36,8 +38,8 @@ std::map<std::string, std::string> XdmfAttribute::getItemProperties() const
{ {
std::map<std::string, std::string> attributeProperties; std::map<std::string, std::string> attributeProperties;
attributeProperties["Name"] = mName; attributeProperties["Name"] = mName;
mAttributeType.getProperties(attributeProperties); mAttributeType->getProperties(attributeProperties);
mAttributeCenter.getProperties(attributeProperties); mAttributeCenter->getProperties(attributeProperties);
return attributeProperties; return attributeProperties;
} }
...@@ -68,12 +70,12 @@ void XdmfAttribute::populateItem(const std::map<std::string, std::string> & item ...@@ -68,12 +70,12 @@ void XdmfAttribute::populateItem(const std::map<std::string, std::string> & item
XdmfDataItem::populateItem(itemProperties, childItems); XdmfDataItem::populateItem(itemProperties, childItems);
} }
void XdmfAttribute::setAttributeCenter(const XdmfAttributeCenter & attributeCenter) void XdmfAttribute::setAttributeCenter(const boost::shared_ptr<const XdmfAttributeCenter> attributeCenter)
{ {
mAttributeCenter = attributeCenter; mAttributeCenter = attributeCenter;
} }
void XdmfAttribute::setAttributeType(const XdmfAttributeType & attributeType) void XdmfAttribute::setAttributeType(const boost::shared_ptr<const XdmfAttributeType> attributeType)
{ {
mAttributeType = attributeType; mAttributeType = attributeType;
} }
......
#ifndef XDMFATTRIBUTE_HPP_ #ifndef XDMFATTRIBUTE_HPP_
#define XDMFATTRIBUTE_HPP_ #define XDMFATTRIBUTE_HPP_
// Forward Declarations
class XdmfAttributeCenter;
class XdmfAttributeType;
// Includes // Includes
#include "XdmfAttributeCenter.hpp"
#include "XdmfAttributeType.hpp"
#include "XdmfDataItem.hpp" #include "XdmfDataItem.hpp"
/** /**
...@@ -25,14 +27,14 @@ public: ...@@ -25,14 +27,14 @@ public:
* *
* @return XdmfAttributeCenter of the attribute. * @return XdmfAttributeCenter of the attribute.
*/ */
XdmfAttributeCenter getAttributeCenter() const; boost::shared_ptr<const XdmfAttributeCenter> getAttributeCenter() const;
/** /**
* Get the XdmfAttributeType associated with this attribute. * Get the XdmfAttributeType associated with this attribute.
* *
* @return XdmfAttributeType of the attribute. * @return XdmfAttributeType of the attribute.
*/ */
XdmfAttributeType getAttributeType() const; boost::shared_ptr<const XdmfAttributeType> getAttributeType() const;
std::map<std::string, std::string> getItemProperties() const; std::map<std::string, std::string> getItemProperties() const;
...@@ -50,14 +52,14 @@ public: ...@@ -50,14 +52,14 @@ public:
* *
* @param attributeCenter the XdmfAttributeCenter to set. * @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. * Set the XdmfAttributeType associated with this attribute.
* *
* @param attributeType XdmfAttributeType to set. * @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. * Set the name of the attribute.
...@@ -78,8 +80,8 @@ private: ...@@ -78,8 +80,8 @@ private:
void operator=(const XdmfAttribute & attribute); // Not implemented. void operator=(const XdmfAttribute & attribute); // Not implemented.
std::string mName; std::string mName;
XdmfAttributeType mAttributeType; boost::shared_ptr<const XdmfAttributeType> mAttributeType;
XdmfAttributeCenter mAttributeCenter; boost::shared_ptr<const XdmfAttributeCenter> mAttributeCenter;
}; };
#endif /* XDMFATTRIBUTE_HPP_ */ #endif /* XDMFATTRIBUTE_HPP_ */
...@@ -8,29 +8,34 @@ ...@@ -8,29 +8,34 @@
#include "XdmfAttributeCenter.hpp" #include "XdmfAttributeCenter.hpp"
// Supported XdmfAttributeCenters // 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) : XdmfAttributeCenter::XdmfAttributeCenter(const std::string & name) :
...@@ -38,12 +43,11 @@ XdmfAttributeCenter::XdmfAttributeCenter(const std::string & name) : ...@@ -38,12 +43,11 @@ XdmfAttributeCenter::XdmfAttributeCenter(const std::string & name) :
{ {
} }
XdmfAttributeCenter::XdmfAttributeCenter(const XdmfAttributeCenter & attributeCenter): XdmfAttributeCenter::~XdmfAttributeCenter()
mName(attributeCenter.mName)
{ {
} }
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"); std::map<std::string, std::string>::const_iterator center = itemProperties.find("Center");
if(center != itemProperties.end()) if(center != itemProperties.end())
...@@ -77,15 +81,6 @@ XdmfAttributeCenter XdmfAttributeCenter::New(const std::map<std::string, std::st ...@@ -77,15 +81,6 @@ XdmfAttributeCenter XdmfAttributeCenter::New(const std::map<std::string, std::st
assert(false); assert(false);
} }
XdmfAttributeCenter & XdmfAttributeCenter::operator=(const XdmfAttributeCenter & attributeCenter)
{
if(this != &attributeCenter)
{
mName = attributeCenter.mName;
}
return *this;
}
bool XdmfAttributeCenter::operator==(const XdmfAttributeCenter & attributeCenter) const bool XdmfAttributeCenter::operator==(const XdmfAttributeCenter & attributeCenter) const
{ {
return mName.compare(attributeCenter.mName) == 0; return mName.compare(attributeCenter.mName) == 0;
......
...@@ -23,13 +23,14 @@ class XdmfAttributeCenter : public XdmfItemProperty { ...@@ -23,13 +23,14 @@ class XdmfAttributeCenter : public XdmfItemProperty {
public: public:
friend class XdmfAttribute; friend class XdmfAttribute;
template <typename T> friend void boost::checked_delete(T * x);
// Supported Xdmf Attribute Centers // Supported Xdmf Attribute Centers
static XdmfAttributeCenter Grid(); static boost::shared_ptr<const XdmfAttributeCenter> Grid();
static XdmfAttributeCenter Cell(); static boost::shared_ptr<const XdmfAttributeCenter> Cell();
static XdmfAttributeCenter Face(); static boost::shared_ptr<const XdmfAttributeCenter> Face();
static XdmfAttributeCenter Edge(); static boost::shared_ptr<const XdmfAttributeCenter> Edge();
static XdmfAttributeCenter Node(); static boost::shared_ptr<const XdmfAttributeCenter> Node();
void getProperties(std::map<std::string, std::string> & collectedProperties) const; void getProperties(std::map<std::string, std::string> & collectedProperties) const;
...@@ -49,9 +50,6 @@ public: ...@@ -49,9 +50,6 @@ public:
*/ */
bool operator!=(const XdmfAttributeCenter & attributeCenter) const; bool operator!=(const XdmfAttributeCenter & attributeCenter) const;
XdmfAttributeCenter(const XdmfAttributeCenter & attributeCenter);
XdmfAttributeCenter & operator=(const XdmfAttributeCenter & attributeCenter);
protected: protected:
/** /**
...@@ -62,10 +60,14 @@ protected: ...@@ -62,10 +60,14 @@ protected:
* @param name the name of the XdmfAttributeCenter to construct. * @param name the name of the XdmfAttributeCenter to construct.
*/ */
XdmfAttributeCenter(const std::string & name); XdmfAttributeCenter(const std::string & name);
~XdmfAttributeCenter();
private: 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; std::string mName;
}; };
......
...@@ -8,52 +8,60 @@ ...@@ -8,52 +8,60 @@
#include "XdmfAttributeType.hpp" #include "XdmfAttributeType.hpp"
// Supported XdmfAttributeTypes // 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) : XdmfAttributeType::XdmfAttributeType(const std::string & name) :
mName(name) mName(name)
{ {
std::cout << "CRRRRREATED" << std::endl;
} }
XdmfAttributeType::XdmfAttributeType(const XdmfAttributeType & attributeType): XdmfAttributeType::~XdmfAttributeType()
mName(attributeType.mName)
{ {
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"); std::map<std::string, std::string>::const_iterator type = itemProperties.find("AttributeType");
if(type != itemProperties.end()) if(type != itemProperties.end())
...@@ -95,15 +103,6 @@ XdmfAttributeType XdmfAttributeType::New(const std::map<std::string, std::string ...@@ -95,15 +103,6 @@ XdmfAttributeType XdmfAttributeType::New(const std::map<std::string, std::string
assert(false); assert(false);
} }
XdmfAttributeType & XdmfAttributeType::operator=(const XdmfAttributeType & attributeType)
{
if(this != &attributeType)
{
mName = attributeType.mName;
}
return *this;
}
bool XdmfAttributeType::operator==(const XdmfAttributeType & attributeType) const bool XdmfAttributeType::operator==(const XdmfAttributeType & attributeType) const
{ {
return mName.compare(attributeType.mName) == 0; return mName.compare(attributeType.mName) == 0;
......
...@@ -25,15 +25,16 @@ class XdmfAttributeType : public XdmfItemProperty { ...@@ -25,15 +25,16 @@ class XdmfAttributeType : public XdmfItemProperty {
public: public:
friend class XdmfAttribute; friend class XdmfAttribute;
template <typename T> friend void boost::checked_delete(T * x);
// Supported Xdmf Attribute Types // Supported Xdmf Attribute Types
static XdmfAttributeType NoAttributeType(); static boost::shared_ptr<const XdmfAttributeType> NoAttributeType();
static XdmfAttributeType Scalar(); static boost::shared_ptr<const XdmfAttributeType> Scalar();
static XdmfAttributeType Vector(); static boost::shared_ptr<const XdmfAttributeType> Vector();
static XdmfAttributeType Tensor(); static boost::shared_ptr<const XdmfAttributeType> Tensor();
static XdmfAttributeType Matrix(); static boost::shared_ptr<const XdmfAttributeType> Matrix();
static XdmfAttributeType Tensor6(); static boost::shared_ptr<const XdmfAttributeType> Tensor6();
static XdmfAttributeType GlobalId(); static boost::shared_ptr<const XdmfAttributeType> GlobalId();
void getProperties(std::map<std::string, std::string> & collectedProperties) const; void getProperties(std::map<std::string, std::string> & collectedProperties) const;
...@@ -53,9 +54,6 @@ public: ...@@ -53,9 +54,6 @@ public:
*/ */
bool operator!=(const XdmfAttributeType & attributeType) const; bool operator!=(const XdmfAttributeType & attributeType) const;
XdmfAttributeType(const XdmfAttributeType & attributeType);
XdmfAttributeType & operator=(const XdmfAttributeType & attributeType);
protected: protected:
/** /**
...@@ -66,10 +64,14 @@ protected: ...@@ -66,10 +64,14 @@ protected:
* @param name the name of the XdmfAttributeType to construct. * @param name the name of the XdmfAttributeType to construct.
*/ */
XdmfAttributeType(const std::string & name); XdmfAttributeType(const std::string & name);
~XdmfAttributeType();
private: 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; std::string mName;
}; };
......
...@@ -45,7 +45,7 @@ void XdmfDataItem::setArray(boost::shared_ptr<XdmfArray> array) ...@@ -45,7 +45,7 @@ void XdmfDataItem::setArray(boost::shared_ptr<XdmfArray> array)
mArray = array; mArray = array;
} }
void XdmfDataItem::traverse(boost::shared_ptr<Loki::BaseVisitor> visitor) void XdmfDataItem::traverse(boost::shared_ptr<XdmfBaseVisitor> visitor)
{ {
mArray->accept(visitor); mArray->accept(visitor);
} }
...@@ -40,7 +40,7 @@ public: ...@@ -40,7 +40,7 @@ public:
*/ */
void setArray(boost::shared_ptr<XdmfArray> array); 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: protected:
......
...@@ -78,7 +78,7 @@ void XdmfDomain::removeGrid(const unsigned int index) ...@@ -78,7 +78,7 @@ void XdmfDomain::removeGrid(const unsigned int index)
mGrids.erase(mGrids.begin() + 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) for(std::vector<boost::shared_ptr<XdmfGrid> >::const_iterator iter = mGrids.begin(); iter != mGrids.end(); ++iter)
{ {
......
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
*/ */
void removeGrid(const unsigned int index); void removeGrid(const unsigned int index);
virtual void traverse(boost::shared_ptr<Loki::BaseVisitor> visitor); virtual void traverse(boost::shared_ptr<XdmfBaseVisitor> visitor);
protected: protected: