Commit 259e3eba authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Remove XdmfGrid inheritance from XdmfGridCollection. If there is a need...

ENH: Remove XdmfGrid inheritance from XdmfGridCollection.  If there is a need for Sets/Attributes at the "global" collection level then we can deal with it in the future.
parent 16a914c6
...@@ -14,7 +14,7 @@ class XdmfGridCollection; ...@@ -14,7 +14,7 @@ class XdmfGridCollection;
* XdmfDomain is the top XdmfItem in an Xdmf structure. It can store a number of grids and * XdmfDomain is the top XdmfItem in an Xdmf structure. It can store a number of grids and
* provides methods to insert, retrieve, and remove these grids. * provides methods to insert, retrieve, and remove these grids.
*/ */
class XdmfDomain : public virtual XdmfItem { class XdmfDomain : public XdmfItem {
public: public:
......
...@@ -20,7 +20,7 @@ class XdmfTopology; ...@@ -20,7 +20,7 @@ class XdmfTopology;
* into the XdmfGrid to specify values attached at various parts of the mesh. XdmfSets can be inserted in the XdmfGrid * into the XdmfGrid to specify values attached at various parts of the mesh. XdmfSets can be inserted in the XdmfGrid
* to specify collections of mesh elements. * to specify collections of mesh elements.
*/ */
class XdmfGrid : public virtual XdmfItem { class XdmfGrid : public XdmfItem {
public: public:
...@@ -265,19 +265,18 @@ protected: ...@@ -265,19 +265,18 @@ protected:
XdmfGrid(); XdmfGrid();
virtual void populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems, const XdmfCoreReader * const reader); virtual void populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems, const XdmfCoreReader * const reader);
boost::shared_ptr<XdmfGeometry> mGeometry;
std::string mName;
boost::shared_ptr<XdmfTopology> mTopology;
private: private:
XdmfGrid(const XdmfGrid & grid); // Not implemented. XdmfGrid(const XdmfGrid & grid); // Not implemented.
void operator=(const XdmfGrid & grid); // Not implemented. void operator=(const XdmfGrid & grid); // Not implemented.
std::vector<boost::shared_ptr<XdmfAttribute> > mAttributes; std::vector<boost::shared_ptr<XdmfAttribute> > mAttributes;
boost::shared_ptr<XdmfGeometry> mGeometry;
boost::shared_ptr<XdmfMap> mMap; boost::shared_ptr<XdmfMap> mMap;
std::string mName;
std::vector<boost::shared_ptr<XdmfSet> > mSets; std::vector<boost::shared_ptr<XdmfSet> > mSets;
boost::shared_ptr<XdmfTime> mTime; boost::shared_ptr<XdmfTime> mTime;
boost::shared_ptr<XdmfTopology> mTopology;
}; };
#endif /* XDMFGRID_HPP_ */ #endif /* XDMFGRID_HPP_ */
...@@ -15,12 +15,9 @@ boost::shared_ptr<XdmfGridCollection> XdmfGridCollection::New() ...@@ -15,12 +15,9 @@ boost::shared_ptr<XdmfGridCollection> XdmfGridCollection::New()
}; };
XdmfGridCollection::XdmfGridCollection() : XdmfGridCollection::XdmfGridCollection() :
XdmfGrid(), mCollectionType(XdmfGridCollectionType::NoCollectionType()),
mCollectionType(XdmfGridCollectionType::NoCollectionType()) mName("Collection")
{ {
mGeometry = boost::shared_ptr<XdmfGeometry>();
mName = "Collection";
mTopology = boost::shared_ptr<XdmfTopology>();
} }
XdmfGridCollection::~XdmfGridCollection() XdmfGridCollection::~XdmfGridCollection()
...@@ -43,6 +40,11 @@ std::string XdmfGridCollection::getItemTag() const ...@@ -43,6 +40,11 @@ std::string XdmfGridCollection::getItemTag() const
return ItemTag; return ItemTag;
} }
std::string XdmfGridCollection::getName() const
{
return mName;
}
boost::shared_ptr<const XdmfGridCollectionType> XdmfGridCollection::getType() const boost::shared_ptr<const XdmfGridCollectionType> XdmfGridCollection::getType() const
{ {
return mCollectionType; return mCollectionType;
...@@ -51,17 +53,24 @@ boost::shared_ptr<const XdmfGridCollectionType> XdmfGridCollection::getType() co ...@@ -51,17 +53,24 @@ boost::shared_ptr<const XdmfGridCollectionType> XdmfGridCollection::getType() co
void XdmfGridCollection::populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems, const XdmfCoreReader * const reader) void XdmfGridCollection::populateItem(const std::map<std::string, std::string> & itemProperties, std::vector<boost::shared_ptr<XdmfItem> > & childItems, const XdmfCoreReader * const reader)
{ {
mCollectionType = XdmfGridCollectionType::New(itemProperties); mCollectionType = XdmfGridCollectionType::New(itemProperties);
std::map<std::string, std::string>::const_iterator name = itemProperties.find("Name");
if(name != itemProperties.end())
{
mName = name->second;
}
else
{
mName = "";
}
XdmfDomain::populateItem(itemProperties, childItems, reader); XdmfDomain::populateItem(itemProperties, childItems, reader);
XdmfGrid::populateItem(itemProperties, childItems, reader);
} }
void XdmfGridCollection::setType(const boost::shared_ptr<const XdmfGridCollectionType> collectionType) void XdmfGridCollection::setName(const std::string & name)
{ {
mCollectionType = collectionType; mName = name;
} }
void XdmfGridCollection::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) void XdmfGridCollection::setType(const boost::shared_ptr<const XdmfGridCollectionType> collectionType)
{ {
XdmfGrid::traverse(visitor); mCollectionType = collectionType;
XdmfDomain::traverse(visitor);
} }
...@@ -6,7 +6,6 @@ class XdmfGridCollectionType; ...@@ -6,7 +6,6 @@ class XdmfGridCollectionType;
// Includes // Includes
#include "XdmfDomain.hpp" #include "XdmfDomain.hpp"
#include "XdmfGrid.hpp"
/** /**
* @brief A spatial or temporal collection of XdmfGrids. * @brief A spatial or temporal collection of XdmfGrids.
...@@ -16,8 +15,7 @@ class XdmfGridCollectionType; ...@@ -16,8 +15,7 @@ class XdmfGridCollectionType;
* *
* It is valid to nest collections. A spatial collection within a temporal collection is commonly used. * It is valid to nest collections. A spatial collection within a temporal collection is commonly used.
*/ */
class XdmfGridCollection : public XdmfGrid, class XdmfGridCollection : public XdmfDomain {
public XdmfDomain {
public: public:
...@@ -30,13 +28,20 @@ public: ...@@ -30,13 +28,20 @@ public:
virtual ~XdmfGridCollection(); virtual ~XdmfGridCollection();
LOKI_DEFINE_VISITABLE(XdmfGridCollection, XdmfGrid) LOKI_DEFINE_VISITABLE(XdmfGridCollection, XdmfDomain)
static const std::string ItemTag; static const std::string ItemTag;
std::map<std::string, std::string> getItemProperties() const; std::map<std::string, std::string> getItemProperties() const;
std::string getItemTag() const; std::string getItemTag() const;
/**
* Get the name of the grid collection.
*
* @return the name of the grid collection.
*/
std::string getName() const;
/** /**
* Get the XdmfGridCollectionType associated with this grid collection. * Get the XdmfGridCollectionType associated with this grid collection.
* *
...@@ -44,8 +49,12 @@ public: ...@@ -44,8 +49,12 @@ public:
*/ */
boost::shared_ptr<const XdmfGridCollectionType> getType() const; boost::shared_ptr<const XdmfGridCollectionType> getType() const;
using XdmfDomain::insert; /**
using XdmfGrid::insert; * Set the name of the grid collection.
*
* @param name of the grid collection to set.
*/
void setName(const std::string & name);
/** /**
* Set the XdmfGridCollectionType associated with this grid collection. * Set the XdmfGridCollectionType associated with this grid collection.
...@@ -54,8 +63,6 @@ public: ...@@ -54,8 +63,6 @@ public:
*/ */
void setType(const boost::shared_ptr<const XdmfGridCollectionType> collectionType); void setType(const boost::shared_ptr<const XdmfGridCollectionType> collectionType);
void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor);
protected: protected:
XdmfGridCollection(); XdmfGridCollection();
...@@ -67,6 +74,7 @@ private: ...@@ -67,6 +74,7 @@ private:
void operator=(const XdmfGridCollection & collection); // Not implemented. void operator=(const XdmfGridCollection & collection); // Not implemented.
boost::shared_ptr<const XdmfGridCollectionType> mCollectionType; boost::shared_ptr<const XdmfGridCollectionType> mCollectionType;
std::string mName;
}; };
#endif /* XDMFGRID_HPP_ */ #endif /* XDMFGRID_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