Commit 46a937d0 authored by Ken Leiter (Civ's avatar Ken Leiter (Civ

ENH: Start separating XdmfItem properties from their respective classes - XdmfAttributeType.

parent 250eac6b
......@@ -21,6 +21,7 @@ endif(XDMF_WRAP_PYTHON)
set(XdmfSources
XdmfAttribute
XdmfAttributeType
XdmfGeometry
XdmfGrid
XdmfItem
......
......@@ -25,6 +25,7 @@ namespace boost {
%module Xdmf
%{
#include <XdmfAttribute.hpp>
#include <XdmfAttributeType.hpp>
#include <XdmfGeometry.hpp>
#include <XdmfGrid.hpp>
#include <XdmfItem.hpp>
......@@ -39,6 +40,7 @@ namespace boost {
%include XdmfVisitor.hpp
%include XdmfAttribute.hpp
%include XdmfAttributeType.hpp
%include XdmfGeometry.hpp
%include XdmfGrid.hpp
%include XdmfTopology.hpp
......@@ -338,6 +338,34 @@ def XdmfAttributeCenter_Node():
return _Xdmf.XdmfAttributeCenter_Node()
XdmfAttributeCenter_Node = _Xdmf.XdmfAttributeCenter_Node
class XdmfAttribute(XdmfItem):
__swig_setmethods__ = {}
for _s in [XdmfItem]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfAttribute, name, value)
__swig_getmethods__ = {}
for _s in [XdmfItem]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, XdmfAttribute, name)
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_getmethods__["New"] = lambda x: _Xdmf.XdmfAttribute_New
if _newclass:New = staticmethod(_Xdmf.XdmfAttribute_New)
def getName(self): return _Xdmf.XdmfAttribute_getName(self)
def setName(self, *args): return _Xdmf.XdmfAttribute_setName(self, *args)
def getAttributeType(self): return _Xdmf.XdmfAttribute_getAttributeType(self)
def setAttributeType(self, *args): return _Xdmf.XdmfAttribute_setAttributeType(self, *args)
def getAttributeTypeAsString(self): return _Xdmf.XdmfAttribute_getAttributeTypeAsString(self)
def getAttributeCenter(self): return _Xdmf.XdmfAttribute_getAttributeCenter(self)
def setAttributeCenter(self, *args): return _Xdmf.XdmfAttribute_setAttributeCenter(self, *args)
def getAttributeCenterAsString(self): return _Xdmf.XdmfAttribute_getAttributeCenterAsString(self)
def write(self, *args): return _Xdmf.XdmfAttribute_write(self, *args)
def printSelf(self): return _Xdmf.XdmfAttribute_printSelf(self)
XdmfAttribute_swigregister = _Xdmf.XdmfAttribute_swigregister
XdmfAttribute_swigregister(XdmfAttribute)
def XdmfAttribute_New():
return _Xdmf.XdmfAttribute_New()
XdmfAttribute_New = _Xdmf.XdmfAttribute_New
class XdmfAttributeType(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfAttributeType, name, value)
......@@ -398,34 +426,6 @@ def XdmfAttributeType_GlobalId():
return _Xdmf.XdmfAttributeType_GlobalId()
XdmfAttributeType_GlobalId = _Xdmf.XdmfAttributeType_GlobalId
class XdmfAttribute(XdmfItem):
__swig_setmethods__ = {}
for _s in [XdmfItem]: __swig_setmethods__.update(getattr(_s,'__swig_setmethods__',{}))
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfAttribute, name, value)
__swig_getmethods__ = {}
for _s in [XdmfItem]: __swig_getmethods__.update(getattr(_s,'__swig_getmethods__',{}))
__getattr__ = lambda self, name: _swig_getattr(self, XdmfAttribute, name)
def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined")
__repr__ = _swig_repr
__swig_getmethods__["New"] = lambda x: _Xdmf.XdmfAttribute_New
if _newclass:New = staticmethod(_Xdmf.XdmfAttribute_New)
def getName(self): return _Xdmf.XdmfAttribute_getName(self)
def setName(self, *args): return _Xdmf.XdmfAttribute_setName(self, *args)
def getAttributeType(self): return _Xdmf.XdmfAttribute_getAttributeType(self)
def setAttributeType(self, *args): return _Xdmf.XdmfAttribute_setAttributeType(self, *args)
def getAttributeTypeAsString(self): return _Xdmf.XdmfAttribute_getAttributeTypeAsString(self)
def getAttributeCenter(self): return _Xdmf.XdmfAttribute_getAttributeCenter(self)
def setAttributeCenter(self, *args): return _Xdmf.XdmfAttribute_setAttributeCenter(self, *args)
def getAttributeCenterAsString(self): return _Xdmf.XdmfAttribute_getAttributeCenterAsString(self)
def write(self, *args): return _Xdmf.XdmfAttribute_write(self, *args)
def printSelf(self): return _Xdmf.XdmfAttribute_printSelf(self)
XdmfAttribute_swigregister = _Xdmf.XdmfAttribute_swigregister
XdmfAttribute_swigregister(XdmfAttribute)
def XdmfAttribute_New():
return _Xdmf.XdmfAttribute_New()
XdmfAttribute_New = _Xdmf.XdmfAttribute_New
class XdmfGeometryType(_object):
__swig_setmethods__ = {}
__setattr__ = lambda self, name, value: _swig_setattr(self, XdmfGeometryType, name, value)
......
......@@ -53,61 +53,6 @@ std::string XdmfAttributeCenter::getName() const
return mName;
}
// Supported XdmfAttributeTypes
XdmfAttributeType XdmfAttributeType::NoAttributeType()
{
return XdmfAttributeType("None");
}
XdmfAttributeType XdmfAttributeType::Scalar()
{
return XdmfAttributeType("Scalar");
}
XdmfAttributeType XdmfAttributeType::Vector()
{
return XdmfAttributeType("Vector");
}
XdmfAttributeType XdmfAttributeType::Tensor()
{
return XdmfAttributeType("Tensor");
}
XdmfAttributeType XdmfAttributeType::Matrix()
{
return XdmfAttributeType("Matrix");
}
XdmfAttributeType XdmfAttributeType::Tensor6()
{
return XdmfAttributeType("Tensor6");
}
XdmfAttributeType XdmfAttributeType::GlobalId()
{
return XdmfAttributeType("GlobalId");
}
XdmfAttributeType::XdmfAttributeType(const XdmfAttributeType& attributeType):
mName(attributeType.mName)
{
}
XdmfAttributeType& XdmfAttributeType::operator=(const XdmfAttributeType& attributeType)
{
if(this != &attributeType)
{
mName = attributeType.mName;
}
return *this;
}
std::string XdmfAttributeType::getName() const
{
return mName;
}
XdmfAttribute::XdmfAttribute() :
mName(""),
mAttributeType(XdmfAttributeType::NoAttributeType()),
......
......@@ -9,6 +9,7 @@
#define XDMFATTRIBUTE_HPP_
#include "XdmfItem.hpp"
#include "XdmfAttributeType.hpp"
class XdmfAttributeCenter {
......@@ -68,66 +69,6 @@ private:
std::string mName;
};
class XdmfAttributeType {
public:
// 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();
/**
* Get the name of this attribute type
*
* @return a string containing the name.
*/
std::string getName() const;
/*
* Compare two XdmfAttribute types for equality.
*
* @param an XdmfAttributeType to compare equality to.
* @return true iff the XdmfAttributeTypes are equal.
*/
bool operator==(const XdmfAttributeType& top) const
{
return mName.compare(top.mName) == 0;
}
/**
* Compare two XdmfAttribute types for inequality.
*
* @param XdmfAttributeType to compare inequality to.
* @return true iff the XdmfAttributeTypes are not equal.
*/
bool operator!=(const XdmfAttributeType& top) const
{
return !this->operator ==(top);
}
XdmfAttributeType(const XdmfAttributeType&);
XdmfAttributeType& operator=(const XdmfAttributeType&);
protected:
/**
* Protected constructor for XdmfAttributeType. The constructor is protected because all attribute types supported
* by Xdmf should be accessed through more specific static methods that construct XdmfAttributeTypes - i.e. XdmfAttributeType::Scalar().
*/
XdmfAttributeType(const std::string& name) :
mName(name)
{};
private:
std::string mName;
};
class XdmfAttribute : public XdmfItem {
public:
......
/*
* XdmfAttribute.cpp
*
* Created on: Jan 29, 2010
* Author: kleiter
*/
#include "XdmfAttributeType.hpp"
// Supported XdmfAttributeTypes
XdmfAttributeType XdmfAttributeType::NoAttributeType()
{
return XdmfAttributeType("None");
}
XdmfAttributeType XdmfAttributeType::Scalar()
{
return XdmfAttributeType("Scalar");
}
XdmfAttributeType XdmfAttributeType::Vector()
{
return XdmfAttributeType("Vector");
}
XdmfAttributeType XdmfAttributeType::Tensor()
{
return XdmfAttributeType("Tensor");
}
XdmfAttributeType XdmfAttributeType::Matrix()
{
return XdmfAttributeType("Matrix");
}
XdmfAttributeType XdmfAttributeType::Tensor6()
{
return XdmfAttributeType("Tensor6");
}
XdmfAttributeType XdmfAttributeType::GlobalId()
{
return XdmfAttributeType("GlobalId");
}
XdmfAttributeType::XdmfAttributeType(const std::string& name) :
mName(name)
{};
XdmfAttributeType::XdmfAttributeType(const XdmfAttributeType& attributeType):
mName(attributeType.mName)
{
}
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;
}
bool XdmfAttributeType::operator!=(const XdmfAttributeType& attributeType) const
{
return !this->operator==(attributeType);
}
std::string XdmfAttributeType::getName() const
{
return mName;
}
/*
* XdmfAttributeType.hpp
*
* Created on: Jan 25, 2010
* Author: kleiter
*/
#ifndef XDMFATTRIBUTETYPE_HPP_
#define XDMFATTRIBUTETYPE_HPP_
#include <string>
class XdmfAttributeType {
public:
// 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();
/**
* Get the name of this attribute type
*
* @return a string containing the name.
*/
std::string getName() const;
/*
* Compare two XdmfAttributeTypes for equality.
*
* @param an XdmfAttributeType to compare equality to.
* @return true iff the XdmfAttributeTypes are equal.
*/
bool operator==(const XdmfAttributeType& attributeType) const;
/**
* Compare two XdmfAttributeTypes for inequality.
*
* @param XdmfAttributeType to compare inequality to.
* @return true iff the XdmfAttributeTypes are not equal.
*/
bool operator!=(const XdmfAttributeType& top) const;
XdmfAttributeType(const XdmfAttributeType&);
XdmfAttributeType& operator=(const XdmfAttributeType&);
protected:
/**
* Protected constructor for XdmfAttributeType. The constructor is protected because all attribute types supported
* by Xdmf should be accessed through more specific static methods that construct XdmfAttributeTypes - i.e. XdmfAttributeType::Scalar().
*/
XdmfAttributeType(const std::string& name);
private:
std::string mName;
};
#endif /* XDMFATTRIBUTETYPE_HPP_ */
This diff is collapsed.
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