Commit 939ff6ce authored by Andrew J. Burns (Cont's avatar Andrew J. Burns (Cont

cleaning up code

parent db257fe6
......@@ -72,12 +72,7 @@ XdmfAttribute::getItemTag() const
std::string
XdmfAttribute::getName() const
{
if (mName.c_str() == NULL) {
return "";
}
else {
return mName;
}
return mName;
}
shared_ptr<const XdmfAttributeType>
......@@ -130,12 +125,7 @@ XdmfAttribute::setCenter(const shared_ptr<const XdmfAttributeCenter> center)
void
XdmfAttribute::setName(const std::string & name)
{
if (mName.c_str() == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Internal Name String is a null reference");
}
else {
mName = name;
}
mName = name;
}
void
......
......@@ -241,9 +241,6 @@ XdmfCurvilinearGrid::getDimensions()
shared_ptr<const XdmfArray>
XdmfCurvilinearGrid::getDimensions() const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Curvilinear Grid Internal Object is NULL");
}
return mImpl->mDimensions;
}
......@@ -275,9 +272,6 @@ XdmfCurvilinearGrid::populateItem(const std::map<std::string, std::string> & ite
void
XdmfCurvilinearGrid::setDimensions(const shared_ptr<XdmfArray> dimensions)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Curvilinear Grid Internal Object is NULL");
}
mImpl->mDimensions = dimensions;
}
......
......@@ -73,12 +73,7 @@ XdmfGrid::getItemTag() const
std::string
XdmfGrid::getName() const
{
if (mName.c_str() == NULL) {
return "";
}
else {
return mName;
}
}
shared_ptr<XdmfTime>
......@@ -148,12 +143,7 @@ XdmfGrid::populateItem(const std::map<std::string, std::string> & itemProperties
void
XdmfGrid::setName(const std::string & name)
{
if (mName.c_str() == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Internal Name String is a null reference");
}
else {
mName = name;
}
mName = name;
}
void
......
......@@ -343,9 +343,6 @@ XdmfRectilinearGrid::getCoordinates(const unsigned int axisIndex)
shared_ptr<const XdmfArray>
XdmfRectilinearGrid::getCoordinates(const unsigned int axisIndex) const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Xdmf Rectilinear Grid Internal Object is NULL");
}
if(axisIndex < mImpl->mCoordinates.size()) {
return mImpl->mCoordinates[axisIndex];
}
......@@ -361,9 +358,6 @@ XdmfRectilinearGrid::getCoordinates()
const std::vector<shared_ptr<XdmfArray> >
XdmfRectilinearGrid::getCoordinates() const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Xdmf Rectilinear Grid Internal Object is NULL");
}
return mImpl->mCoordinates;
}
......@@ -377,9 +371,6 @@ XdmfRectilinearGrid::getDimensions()
shared_ptr<const XdmfArray>
XdmfRectilinearGrid::getDimensions() const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Xdmf Rectilinear Grid Internal Object is NULL");
}
shared_ptr<XdmfArray> dimensions = XdmfArray::New();
dimensions->reserve(mImpl->mCoordinates.size());
for(std::vector<shared_ptr<XdmfArray> >::const_iterator iter =
......@@ -416,9 +407,6 @@ void
XdmfRectilinearGrid::setCoordinates(const unsigned int axisIndex,
const shared_ptr<XdmfArray> axisCoordinates)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Xdmf Rectilinear Grid Internal Object is NULL");
}
if(mImpl->mCoordinates.size() <= axisIndex) {
mImpl->mCoordinates.reserve(axisIndex + 1);
unsigned int numArraysToInsert =
......@@ -433,8 +421,5 @@ XdmfRectilinearGrid::setCoordinates(const unsigned int axisIndex,
void
XdmfRectilinearGrid::setCoordinates(const std::vector<shared_ptr<XdmfArray> > axesCoordinates)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Xdmf Rectilinear Grid Internal Object is NULL");
}
mImpl->mCoordinates = axesCoordinates;
}
......@@ -371,9 +371,6 @@ XdmfRegularGrid::getBrickSize()
shared_ptr<const XdmfArray>
XdmfRegularGrid::getBrickSize() const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Regular Grid Internal Object is NULL");
}
return mImpl->mBrickSize;
}
......@@ -387,9 +384,6 @@ XdmfRegularGrid::getDimensions()
shared_ptr<const XdmfArray>
XdmfRegularGrid::getDimensions() const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Regular Grid Internal Object is NULL");
}
return mImpl->mDimensions;
}
......@@ -403,9 +397,6 @@ XdmfRegularGrid::getOrigin()
shared_ptr<const XdmfArray>
XdmfRegularGrid::getOrigin() const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Regular Grid Internal Object is NULL");
}
return mImpl->mOrigin;
}
......@@ -440,26 +431,17 @@ XdmfRegularGrid::populateItem(const std::map<std::string, std::string> & itemPro
void
XdmfRegularGrid::setBrickSize(const shared_ptr<XdmfArray> brickSize)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Regular Grid Internal Object is NULL");
}
mImpl->mBrickSize = brickSize;
}
void
XdmfRegularGrid::setDimensions(const shared_ptr<XdmfArray> dimensions)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Regular Grid Internal Object is NULL");
}
mImpl->mDimensions = dimensions;
}
void
XdmfRegularGrid::setOrigin(const shared_ptr<XdmfArray> origin)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Regular Grid Internal Object is NULL");
}
mImpl->mOrigin = origin;
}
......@@ -67,12 +67,7 @@ XdmfSet::getItemTag() const
std::string
XdmfSet::getName() const
{
if (mName.c_str() == NULL) {
return "";
}
else {
return mName;
}
return mName;
}
shared_ptr<const XdmfSetType>
......@@ -117,12 +112,7 @@ XdmfSet::populateItem(const std::map<std::string, std::string> & itemProperties,
void
XdmfSet::setName(const std::string & name)
{
if (mName.c_str() == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Internal Name String is a null reference");
}
else {
mName = name;
}
mName = name;
}
void
......
......@@ -706,23 +706,13 @@ XdmfArray::getItemTag() const
std::string
XdmfArray::getName() const
{
if (mName.c_str() == NULL) {
return "";
}
else {
return mName;
}
return mName;
}
XdmfArray::ReadMode
XdmfArray::getReadMode() const
{
if (mReadMode) {
return mReadMode;
}
else {
return XdmfArray::Controller;
}
return mReadMode;
}
unsigned int
......@@ -1367,12 +1357,7 @@ XdmfArray::setHeavyDataController(shared_ptr<XdmfHeavyDataController> newControl
void
XdmfArray::setName(const std::string & name)
{
if (mName.c_str() == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Internal Name String is a null reference");
}
else {
mName = name;
}
mName = name;
}
void
......
......@@ -327,9 +327,6 @@ XdmfCoreReader::~XdmfCoreReader()
shared_ptr<XdmfItem >
XdmfCoreReader::parse(const std::string & lightData) const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Reader Internal Object is NULL");
}
mImpl->parse(lightData);
const xmlNodePtr currNode = xmlDocGetRootElement(mImpl->mDocument);
std::vector<shared_ptr<XdmfItem> > toReturn;
......@@ -348,9 +345,6 @@ XdmfCoreReader::parse(const std::string & lightData) const
std::vector<shared_ptr<XdmfItem> >
XdmfCoreReader::readItems(const std::string & filePath) const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Reader Internal Object is NULL");
}
mImpl->openFile(filePath);
const xmlNodePtr currNode = xmlDocGetRootElement(mImpl->mDocument);
const std::vector<shared_ptr<XdmfItem> > toReturn =
......@@ -373,9 +367,6 @@ std::vector<shared_ptr<XdmfItem> >
XdmfCoreReader::read(const std::string & filePath,
const std::string & xPath) const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Reader Internal Object is NULL");
}
mImpl->openFile(filePath);
std::vector<shared_ptr<XdmfItem> > toReturn = this->readPathObjects(xPath);
mImpl->closeFile();
......@@ -385,9 +376,6 @@ XdmfCoreReader::read(const std::string & filePath,
std::vector<shared_ptr<XdmfItem> >
XdmfCoreReader::readPathObjects(const std::string & xPath) const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Reader Internal Object is NULL");
}
std::vector<shared_ptr<XdmfItem> > toReturn;
mImpl->readPathObjects(xPath, toReturn);
return toReturn;
......
......@@ -748,12 +748,7 @@ XdmfFunction::evaluateFunction(std::vector<shared_ptr<XdmfArray> > valueVector,
std::string
XdmfFunction::getExpression() const
{
if (mExpression.c_str() == NULL) {
return "";
}
else {
return mExpression;
}
return mExpression;
}
std::string
......@@ -1066,12 +1061,7 @@ XdmfFunction::removeVariable(std::string key)
void
XdmfFunction::setExpression(std::string newExpression)
{
if (mExpression.c_str() == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Internal Expression String is a null reference");
}
else {
mExpression = newExpression;
}
mExpression = newExpression;
}
shared_ptr<XdmfArray>
......
......@@ -940,14 +940,7 @@ XdmfHDF5Writer::createController(const shared_ptr<XdmfHeavyDataController> & ref
unsigned int
XdmfHDF5Writer::getChunkSize() const
{
if (mImpl != NULL) {
return mImpl->mChunkSize;
}
else {
// Fatal error if impl is null
XdmfError::message(XdmfError::FATAL, "Error: HDF5 internal object is NULL");
return 0;
}
return mImpl->mChunkSize;
}
int
......@@ -1000,13 +993,7 @@ XdmfHDF5Writer::getDataSetSize(const std::string & fileName, const std::string &
void
XdmfHDF5Writer::closeFile()
{
if (mImpl != NULL) {
mImpl->closeFile();
}
else {
// Fatal error if impl is null
XdmfError::message(XdmfError::FATAL, "Error: HDF5 internal object is NULL");
}
mImpl->closeFile();
}
void
......@@ -1018,54 +1005,36 @@ XdmfHDF5Writer::openFile()
void
XdmfHDF5Writer::openFile(const int fapl)
{
if (mImpl != NULL) {
mDataSetId = mImpl->openFile(mFilePath,
fapl,
mDataSetId);
}
else {
// Fatal error if impl is null
XdmfError::message(XdmfError::FATAL, "Error: HDF5 internal object is NULL");
}
mDataSetId = mImpl->openFile(mFilePath,
fapl,
mDataSetId);
}
void
XdmfHDF5Writer::setChunkSize(const unsigned int chunkSize)
{
if (mImpl != NULL) {
mImpl->mChunkSize = chunkSize;
}
else {
// Fatal error if impl is null
XdmfError::message(XdmfError::FATAL, "Error: HDF5 internal object is NULL");
}
mImpl->mChunkSize = chunkSize;
}
void
XdmfHDF5Writer::visit(XdmfArray & array,
const shared_ptr<XdmfBaseVisitor> visitor)
{
if (mImpl != NULL) {
mImpl->mDepth++;
std::set<const XdmfItem *>::iterator checkWritten = mImpl->mWrittenItems.find(&array);
if (checkWritten == mImpl->mWrittenItems.end() || array.getItemTag() == "DataItem") {
// If it has children send the writer to them too.
array.traverse(visitor);
if (array.isInitialized()) {
// Only do this if the object has not already been written
this->write(array, H5P_DEFAULT);
mImpl->mWrittenItems.insert(&array);
}
}
// If the object has already been written, just end, it already has the data
mImpl->mDepth--;
if(mImpl->mDepth <= 0) {
mImpl->mWrittenItems.clear();
mImpl->mDepth++;
std::set<const XdmfItem *>::iterator checkWritten = mImpl->mWrittenItems.find(&array);
if (checkWritten == mImpl->mWrittenItems.end() || array.getItemTag() == "DataItem") {
// If it has children send the writer to them too.
array.traverse(visitor);
if (array.isInitialized()) {
// Only do this if the object has not already been written
this->write(array, H5P_DEFAULT);
mImpl->mWrittenItems.insert(&array);
}
}
else {
// Fatal error if impl is null
XdmfError::message(XdmfError::FATAL, "Error: HDF5 internal object is NULL");
// If the object has already been written, just end, it already has the data
mImpl->mDepth--;
if(mImpl->mDepth <= 0) {
mImpl->mWrittenItems.clear();
}
}
......@@ -1074,24 +1043,18 @@ void
XdmfHDF5Writer::visit(XdmfItem & item,
const shared_ptr<XdmfBaseVisitor> visitor)
{
if (mImpl != NULL) {
mImpl->mDepth++;
// This is similar to the algorithm for writing XPaths
// shouldn't be a problem if XPaths are turned off because all this does is avoid writing an object twice
// if it was written once then all instances of the object should have the controller
std::set<const XdmfItem *>::iterator checkWritten = mImpl->mWrittenItems.find(&item);
if (checkWritten == mImpl->mWrittenItems.end()) {
mImpl->mWrittenItems.insert(&item);
item.traverse(visitor);
}
mImpl->mDepth--;
if(mImpl->mDepth <= 0) {
mImpl->mWrittenItems.clear();
}
mImpl->mDepth++;
// This is similar to the algorithm for writing XPaths
// shouldn't be a problem if XPaths are turned off because all this does is avoid writing an object twice
// if it was written once then all instances of the object should have the controller
std::set<const XdmfItem *>::iterator checkWritten = mImpl->mWrittenItems.find(&item);
if (checkWritten == mImpl->mWrittenItems.end()) {
mImpl->mWrittenItems.insert(&item);
item.traverse(visitor);
}
else {
// Fatal error if impl is null
XdmfError::message(XdmfError::FATAL, "Error: HDF5 internal object is NULL");
mImpl->mDepth--;
if(mImpl->mDepth <= 0) {
mImpl->mWrittenItems.clear();
}
}
......@@ -1100,11 +1063,6 @@ void
XdmfHDF5Writer::write(XdmfArray & array,
const int fapl)
{
if (mImpl == NULL) {
// Fatal error if impl is null
XdmfError::message(XdmfError::FATAL, "Error: HDF5 internal object is NULL");
}
hid_t datatype = -1;
bool closeDatatype = false;
......
......@@ -48,12 +48,6 @@ XdmfHeavyDataController::getArrayOffset() const
return mArrayStartOffset;
}
std::string
XdmfHeavyDataController::getDescriptor() const
{
return "";
}
std::vector<unsigned int>
XdmfHeavyDataController::getDimensions() const
{
......
......@@ -76,7 +76,7 @@ public:
*
* @return A string that contains relevant information for the controller
*/
virtual std::string getDescriptor() const;
virtual std::string getDescriptor() const = 0;
/**
* Get the dimensions of the heavy data set owned by this controller.
......
......@@ -74,23 +74,13 @@ XdmfInformation::getItemTag() const
std::string
XdmfInformation::getKey() const
{
if (mKey.c_str() == NULL) {
return "";
}
else {
return mKey;
}
return mKey;
}
std::string
XdmfInformation::getValue() const
{
if (mValue.c_str() == NULL) {
return "";
}
else {
return mValue;
}
return mValue;
}
void
......@@ -140,23 +130,13 @@ XdmfInformation::populateItem(const std::map<std::string, std::string> & itemPro
void
XdmfInformation::setKey(const std::string & key)
{
if (mKey.c_str() == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Internal Key String is a null reference");
}
else {
mKey = key;
}
mKey = key;
}
void
XdmfInformation::setValue(const std::string & value)
{
if (mValue.c_str() == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Internal Value String is a null reference");
}
else {
mValue = value;
}
mValue = value;
}
void
......
......@@ -57,9 +57,6 @@ const std::string XdmfSparseMatrix::ItemTag = "SparseMatrix";
shared_ptr<XdmfArray>
XdmfSparseMatrix::getColumnIndex()
{
if (!mColumnIndex) {
XdmfError::message(XdmfError::FATAL, "Error: Sparse Matrix Column Index is Null");
}
return mColumnIndex;
}
......@@ -111,18 +108,12 @@ XdmfSparseMatrix::getNumberRows() const
shared_ptr<XdmfArray>
XdmfSparseMatrix::getRowPointer()
{
if (!mRowPointer) {
XdmfError::message(XdmfError::FATAL, "Error: Sparse Matrix Row Pointer is Null");
}
return mRowPointer;
}
shared_ptr<XdmfArray>
XdmfSparseMatrix::getValues()
{
if (!mValues) {
XdmfError::message(XdmfError::FATAL, "Error: Sparse Matrix Values are Null");
}
return mValues;
}
......@@ -222,38 +213,24 @@ XdmfSparseMatrix::populateItem(const std::map<std::string, std::string> & itemPr
void
XdmfSparseMatrix::setColumnIndex(const shared_ptr<XdmfArray> columnIndex)
{
if (!mColumnIndex) {
XdmfError::message(XdmfError::FATAL, "Error: Sparse Matrix Column Index is Null");
}
mColumnIndex = columnIndex;
}
void
XdmfSparseMatrix::setName(const std::string & name)
{
if (mName.c_str() == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Internal Name String is a null reference");
}
else {
mName = name;
}
mName = name;
}
void
XdmfSparseMatrix::setRowPointer(const shared_ptr<XdmfArray> rowPointer)
{
if (!mRowPointer) {
XdmfError::message(XdmfError::FATAL, "Error: Sparse Matrix Row Pointer is Null");
}
mRowPointer = rowPointer;
}
void
XdmfSparseMatrix::setValues(const shared_ptr<XdmfArray> values)
{
if (!mValues) {
XdmfError::message(XdmfError::FATAL, "Error: Sparse Matrix Values are Null");
}
mValues = values;
}
......
......@@ -207,116 +207,78 @@ XdmfWriter::getHeavyDataWriter()
shared_ptr<const XdmfHeavyDataWriter>
XdmfWriter::getHeavyDataWriter() const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Writer Internal Object is Null");
}
return mImpl->mHeavyDataWriter;
}
std::string
XdmfWriter::getFilePath() const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Writer Internal Object is Null");
}
return mImpl->mXMLFilePath;
}
unsigned int
XdmfWriter::getLightDataLimit() const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Writer Internal Object is Null");
}
return mImpl->mLightDataLimit;
}
XdmfWriter::Mode
XdmfWriter::getMode() const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Writer Internal Object is Null");
}
return mImpl->mMode;
}
bool
XdmfWriter::getWriteXPaths() const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Writer Internal Object is Null");
}
return mImpl->mWriteXPaths;
}
bool
XdmfWriter::getXPathParse() const
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Writer Internal Object is Null");
}
return mImpl->mXPathParse;
}
void
XdmfWriter::setDocumentTitle(std::string title)
{ if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Writer Internal Object is Null");
}
{
mImpl->mDocumentTitle = title;
}
void
XdmfWriter::setHeavyDataWriter(shared_ptr<XdmfHeavyDataWriter> heavyDataWriter)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Writer Internal Object is Null");
}
mImpl->mHeavyDataWriter = heavyDataWriter;
}
void
XdmfWriter::setLightDataLimit(const unsigned int numValues)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Writer Internal Object is Null");
}
mImpl->mLightDataLimit = numValues;
}
void
XdmfWriter::setMode(const Mode mode)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Writer Internal Object is Null");
}
mImpl->mMode = mode;
}
void
XdmfWriter::setVersionString(std::string version)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Writer Internal Object is Null");
}
mImpl->mVersionString = version;
}
void
XdmfWriter::setWriteXPaths(const bool writeXPaths)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Writer Internal Object is Null");
}
mImpl->mWriteXPaths = writeXPaths;
}
void
XdmfWriter::setXPathParse(const bool xPathParse)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Writer Internal Object is Null");
}
mImpl->mXPathParse = xPathParse;
}
......@@ -324,9 +286,6 @@ void
XdmfWriter::visit(XdmfArray & array,
const shared_ptr<XdmfBaseVisitor> visitor)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Writer Internal Object is Null");
}
if (mImpl->mDepth == 0) {
mImpl->openFile();
}
......@@ -467,9 +426,6 @@ void
XdmfWriter::visit(XdmfItem & item,
const shared_ptr<XdmfBaseVisitor> visitor)
{
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Writer Internal Object is Null");
}
if (mImpl->mDepth == 0) {
mImpl->openFile();
}
......