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

cleaning up code

parent db257fe6
...@@ -72,12 +72,7 @@ XdmfAttribute::getItemTag() const ...@@ -72,12 +72,7 @@ XdmfAttribute::getItemTag() const
std::string std::string
XdmfAttribute::getName() const XdmfAttribute::getName() const
{ {
if (mName.c_str() == NULL) {
return "";
}
else {
return mName; return mName;
}
} }
shared_ptr<const XdmfAttributeType> shared_ptr<const XdmfAttributeType>
...@@ -130,12 +125,7 @@ XdmfAttribute::setCenter(const shared_ptr<const XdmfAttributeCenter> center) ...@@ -130,12 +125,7 @@ XdmfAttribute::setCenter(const shared_ptr<const XdmfAttributeCenter> center)
void void
XdmfAttribute::setName(const std::string & name) 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 void
......
...@@ -241,9 +241,6 @@ XdmfCurvilinearGrid::getDimensions() ...@@ -241,9 +241,6 @@ XdmfCurvilinearGrid::getDimensions()
shared_ptr<const XdmfArray> shared_ptr<const XdmfArray>
XdmfCurvilinearGrid::getDimensions() const XdmfCurvilinearGrid::getDimensions() const
{ {
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Curvilinear Grid Internal Object is NULL");
}
return mImpl->mDimensions; return mImpl->mDimensions;
} }
...@@ -275,9 +272,6 @@ XdmfCurvilinearGrid::populateItem(const std::map<std::string, std::string> & ite ...@@ -275,9 +272,6 @@ XdmfCurvilinearGrid::populateItem(const std::map<std::string, std::string> & ite
void void
XdmfCurvilinearGrid::setDimensions(const shared_ptr<XdmfArray> dimensions) XdmfCurvilinearGrid::setDimensions(const shared_ptr<XdmfArray> dimensions)
{ {
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Curvilinear Grid Internal Object is NULL");
}
mImpl->mDimensions = dimensions; mImpl->mDimensions = dimensions;
} }
......
...@@ -73,12 +73,7 @@ XdmfGrid::getItemTag() const ...@@ -73,12 +73,7 @@ XdmfGrid::getItemTag() const
std::string std::string
XdmfGrid::getName() const XdmfGrid::getName() const
{ {
if (mName.c_str() == NULL) {
return "";
}
else {
return mName; return mName;
}
} }
shared_ptr<XdmfTime> shared_ptr<XdmfTime>
...@@ -148,12 +143,7 @@ XdmfGrid::populateItem(const std::map<std::string, std::string> & itemProperties ...@@ -148,12 +143,7 @@ XdmfGrid::populateItem(const std::map<std::string, std::string> & itemProperties
void void
XdmfGrid::setName(const std::string & name) 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 void
......
...@@ -343,9 +343,6 @@ XdmfRectilinearGrid::getCoordinates(const unsigned int axisIndex) ...@@ -343,9 +343,6 @@ XdmfRectilinearGrid::getCoordinates(const unsigned int axisIndex)
shared_ptr<const XdmfArray> shared_ptr<const XdmfArray>
XdmfRectilinearGrid::getCoordinates(const unsigned int axisIndex) const 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()) { if(axisIndex < mImpl->mCoordinates.size()) {
return mImpl->mCoordinates[axisIndex]; return mImpl->mCoordinates[axisIndex];
} }
...@@ -361,9 +358,6 @@ XdmfRectilinearGrid::getCoordinates() ...@@ -361,9 +358,6 @@ XdmfRectilinearGrid::getCoordinates()
const std::vector<shared_ptr<XdmfArray> > const std::vector<shared_ptr<XdmfArray> >
XdmfRectilinearGrid::getCoordinates() const XdmfRectilinearGrid::getCoordinates() const
{ {
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Xdmf Rectilinear Grid Internal Object is NULL");
}
return mImpl->mCoordinates; return mImpl->mCoordinates;
} }
...@@ -377,9 +371,6 @@ XdmfRectilinearGrid::getDimensions() ...@@ -377,9 +371,6 @@ XdmfRectilinearGrid::getDimensions()
shared_ptr<const XdmfArray> shared_ptr<const XdmfArray>
XdmfRectilinearGrid::getDimensions() const XdmfRectilinearGrid::getDimensions() const
{ {
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Xdmf Rectilinear Grid Internal Object is NULL");
}
shared_ptr<XdmfArray> dimensions = XdmfArray::New(); shared_ptr<XdmfArray> dimensions = XdmfArray::New();
dimensions->reserve(mImpl->mCoordinates.size()); dimensions->reserve(mImpl->mCoordinates.size());
for(std::vector<shared_ptr<XdmfArray> >::const_iterator iter = for(std::vector<shared_ptr<XdmfArray> >::const_iterator iter =
...@@ -416,9 +407,6 @@ void ...@@ -416,9 +407,6 @@ void
XdmfRectilinearGrid::setCoordinates(const unsigned int axisIndex, XdmfRectilinearGrid::setCoordinates(const unsigned int axisIndex,
const shared_ptr<XdmfArray> axisCoordinates) 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) { if(mImpl->mCoordinates.size() <= axisIndex) {
mImpl->mCoordinates.reserve(axisIndex + 1); mImpl->mCoordinates.reserve(axisIndex + 1);
unsigned int numArraysToInsert = unsigned int numArraysToInsert =
...@@ -433,8 +421,5 @@ XdmfRectilinearGrid::setCoordinates(const unsigned int axisIndex, ...@@ -433,8 +421,5 @@ XdmfRectilinearGrid::setCoordinates(const unsigned int axisIndex,
void void
XdmfRectilinearGrid::setCoordinates(const std::vector<shared_ptr<XdmfArray> > axesCoordinates) 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; mImpl->mCoordinates = axesCoordinates;
} }
...@@ -371,9 +371,6 @@ XdmfRegularGrid::getBrickSize() ...@@ -371,9 +371,6 @@ XdmfRegularGrid::getBrickSize()
shared_ptr<const XdmfArray> shared_ptr<const XdmfArray>
XdmfRegularGrid::getBrickSize() const XdmfRegularGrid::getBrickSize() const
{ {
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Regular Grid Internal Object is NULL");
}
return mImpl->mBrickSize; return mImpl->mBrickSize;
} }
...@@ -387,9 +384,6 @@ XdmfRegularGrid::getDimensions() ...@@ -387,9 +384,6 @@ XdmfRegularGrid::getDimensions()
shared_ptr<const XdmfArray> shared_ptr<const XdmfArray>
XdmfRegularGrid::getDimensions() const XdmfRegularGrid::getDimensions() const
{ {
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Regular Grid Internal Object is NULL");
}
return mImpl->mDimensions; return mImpl->mDimensions;
} }
...@@ -403,9 +397,6 @@ XdmfRegularGrid::getOrigin() ...@@ -403,9 +397,6 @@ XdmfRegularGrid::getOrigin()
shared_ptr<const XdmfArray> shared_ptr<const XdmfArray>
XdmfRegularGrid::getOrigin() const XdmfRegularGrid::getOrigin() const
{ {
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Regular Grid Internal Object is NULL");
}
return mImpl->mOrigin; return mImpl->mOrigin;
} }
...@@ -440,26 +431,17 @@ XdmfRegularGrid::populateItem(const std::map<std::string, std::string> & itemPro ...@@ -440,26 +431,17 @@ XdmfRegularGrid::populateItem(const std::map<std::string, std::string> & itemPro
void void
XdmfRegularGrid::setBrickSize(const shared_ptr<XdmfArray> brickSize) XdmfRegularGrid::setBrickSize(const shared_ptr<XdmfArray> brickSize)
{ {
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Regular Grid Internal Object is NULL");
}
mImpl->mBrickSize = brickSize; mImpl->mBrickSize = brickSize;
} }
void void
XdmfRegularGrid::setDimensions(const shared_ptr<XdmfArray> dimensions) XdmfRegularGrid::setDimensions(const shared_ptr<XdmfArray> dimensions)
{ {
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Regular Grid Internal Object is NULL");
}
mImpl->mDimensions = dimensions; mImpl->mDimensions = dimensions;
} }
void void
XdmfRegularGrid::setOrigin(const shared_ptr<XdmfArray> origin) XdmfRegularGrid::setOrigin(const shared_ptr<XdmfArray> origin)
{ {
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Regular Grid Internal Object is NULL");
}
mImpl->mOrigin = origin; mImpl->mOrigin = origin;
} }
...@@ -67,12 +67,7 @@ XdmfSet::getItemTag() const ...@@ -67,12 +67,7 @@ XdmfSet::getItemTag() const
std::string std::string
XdmfSet::getName() const XdmfSet::getName() const
{ {
if (mName.c_str() == NULL) {
return "";
}
else {
return mName; return mName;
}
} }
shared_ptr<const XdmfSetType> shared_ptr<const XdmfSetType>
...@@ -117,12 +112,7 @@ XdmfSet::populateItem(const std::map<std::string, std::string> & itemProperties, ...@@ -117,12 +112,7 @@ XdmfSet::populateItem(const std::map<std::string, std::string> & itemProperties,
void void
XdmfSet::setName(const std::string & name) 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 void
......
...@@ -706,23 +706,13 @@ XdmfArray::getItemTag() const ...@@ -706,23 +706,13 @@ XdmfArray::getItemTag() const
std::string std::string
XdmfArray::getName() const XdmfArray::getName() const
{ {
if (mName.c_str() == NULL) {
return "";
}
else {
return mName; return mName;
}
} }
XdmfArray::ReadMode XdmfArray::ReadMode
XdmfArray::getReadMode() const XdmfArray::getReadMode() const
{ {
if (mReadMode) {
return mReadMode; return mReadMode;
}
else {
return XdmfArray::Controller;
}
} }
unsigned int unsigned int
...@@ -1367,12 +1357,7 @@ XdmfArray::setHeavyDataController(shared_ptr<XdmfHeavyDataController> newControl ...@@ -1367,12 +1357,7 @@ XdmfArray::setHeavyDataController(shared_ptr<XdmfHeavyDataController> newControl
void void
XdmfArray::setName(const std::string & name) 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 void
......
...@@ -327,9 +327,6 @@ XdmfCoreReader::~XdmfCoreReader() ...@@ -327,9 +327,6 @@ XdmfCoreReader::~XdmfCoreReader()
shared_ptr<XdmfItem > shared_ptr<XdmfItem >
XdmfCoreReader::parse(const std::string & lightData) const XdmfCoreReader::parse(const std::string & lightData) const
{ {
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Reader Internal Object is NULL");
}
mImpl->parse(lightData); mImpl->parse(lightData);
const xmlNodePtr currNode = xmlDocGetRootElement(mImpl->mDocument); const xmlNodePtr currNode = xmlDocGetRootElement(mImpl->mDocument);
std::vector<shared_ptr<XdmfItem> > toReturn; std::vector<shared_ptr<XdmfItem> > toReturn;
...@@ -348,9 +345,6 @@ XdmfCoreReader::parse(const std::string & lightData) const ...@@ -348,9 +345,6 @@ XdmfCoreReader::parse(const std::string & lightData) const
std::vector<shared_ptr<XdmfItem> > std::vector<shared_ptr<XdmfItem> >
XdmfCoreReader::readItems(const std::string & filePath) const XdmfCoreReader::readItems(const std::string & filePath) const
{ {
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Reader Internal Object is NULL");
}
mImpl->openFile(filePath); mImpl->openFile(filePath);
const xmlNodePtr currNode = xmlDocGetRootElement(mImpl->mDocument); const xmlNodePtr currNode = xmlDocGetRootElement(mImpl->mDocument);
const std::vector<shared_ptr<XdmfItem> > toReturn = const std::vector<shared_ptr<XdmfItem> > toReturn =
...@@ -373,9 +367,6 @@ std::vector<shared_ptr<XdmfItem> > ...@@ -373,9 +367,6 @@ std::vector<shared_ptr<XdmfItem> >
XdmfCoreReader::read(const std::string & filePath, XdmfCoreReader::read(const std::string & filePath,
const std::string & xPath) const const std::string & xPath) const
{ {
if (mImpl == NULL) {
XdmfError::message(XdmfError::FATAL, "Error: Reader Internal Object is NULL");
}
mImpl->openFile(filePath); mImpl->openFile(filePath);
std::vector<shared_ptr<XdmfItem> > toReturn = this->readPathObjects(xPath); std::vector<shared_ptr<XdmfItem> > toReturn = this->readPathObjects(xPath);
mImpl->closeFile(); mImpl->closeFile();
...@@ -385,9 +376,6 @@ XdmfCoreReader::read(const std::string & filePath, ...@@ -385,9 +376,6 @@ XdmfCoreReader::read(const std::string & filePath,
std::vector<shared_ptr<XdmfItem> > std::vector<shared_ptr<XdmfItem> >
XdmfCoreReader::readPathObjects(const std::string & xPath) const 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; std::vector<shared_ptr<XdmfItem> > toReturn;
mImpl->readPathObjects(xPath, toReturn); mImpl->readPathObjects(xPath, toReturn);
return toReturn; return toReturn;
......
...@@ -748,12 +748,7 @@ XdmfFunction::evaluateFunction(std::vector<shared_ptr<XdmfArray> > valueVector, ...@@ -748,12 +748,7 @@ XdmfFunction::evaluateFunction(std::vector<shared_ptr<XdmfArray> > valueVector,
std::string std::string
XdmfFunction::getExpression() const XdmfFunction::getExpression() const
{ {
if (mExpression.c_str() == NULL) {
return "";
}
else {
return mExpression; return mExpression;
}
} }
std::string std::string
...@@ -1066,12 +1061,7 @@ XdmfFunction::removeVariable(std::string key) ...@@ -1066,12 +1061,7 @@ XdmfFunction::removeVariable(std::string key)
void void
XdmfFunction::setExpression(std::string newExpression) 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> shared_ptr<XdmfArray>
......
...@@ -940,14 +940,7 @@ XdmfHDF5Writer::createController(const shared_ptr<XdmfHeavyDataController> & ref ...@@ -940,14 +940,7 @@ XdmfHDF5Writer::createController(const shared_ptr<XdmfHeavyDataController> & ref
unsigned int unsigned int
XdmfHDF5Writer::getChunkSize() const XdmfHDF5Writer::getChunkSize() const
{ {
if (mImpl != NULL) {
return mImpl->mChunkSize; return mImpl->mChunkSize;
}
else {
// Fatal error if impl is null
XdmfError::message(XdmfError::FATAL, "Error: HDF5 internal object is NULL");
return 0;
}
} }
int int
...@@ -1000,13 +993,7 @@ XdmfHDF5Writer::getDataSetSize(const std::string & fileName, const std::string & ...@@ -1000,13 +993,7 @@ XdmfHDF5Writer::getDataSetSize(const std::string & fileName, const std::string &
void void
XdmfHDF5Writer::closeFile() XdmfHDF5Writer::closeFile()
{ {
if (mImpl != NULL) {
mImpl->closeFile(); mImpl->closeFile();
}
else {
// Fatal error if impl is null
XdmfError::message(XdmfError::FATAL, "Error: HDF5 internal object is NULL");
}
} }
void void
...@@ -1018,34 +1005,21 @@ XdmfHDF5Writer::openFile() ...@@ -1018,34 +1005,21 @@ XdmfHDF5Writer::openFile()
void void
XdmfHDF5Writer::openFile(const int fapl) XdmfHDF5Writer::openFile(const int fapl)
{ {
if (mImpl != NULL) {
mDataSetId = mImpl->openFile(mFilePath, mDataSetId = mImpl->openFile(mFilePath,
fapl, fapl,
mDataSetId); mDataSetId);
}
else {
// Fatal error if impl is null
XdmfError::message(XdmfError::FATAL, "Error: HDF5 internal object is NULL");
}
} }
void void
XdmfHDF5Writer::setChunkSize(const unsigned int chunkSize) XdmfHDF5Writer::setChunkSize(const unsigned int chunkSize)
{ {
if (mImpl != NULL) {
mImpl->mChunkSize = chunkSize; mImpl->mChunkSize = chunkSize;
}
else {
// Fatal error if impl is null
XdmfError::message(XdmfError::FATAL, "Error: HDF5 internal object is NULL");
}
} }
void void
XdmfHDF5Writer::visit(XdmfArray & array, XdmfHDF5Writer::visit(XdmfArray & array,
const shared_ptr<XdmfBaseVisitor> visitor) const shared_ptr<XdmfBaseVisitor> visitor)
{ {
if (mImpl != NULL) {
mImpl->mDepth++; mImpl->mDepth++;
std::set<const XdmfItem *>::iterator checkWritten = mImpl->mWrittenItems.find(&array); std::set<const XdmfItem *>::iterator checkWritten = mImpl->mWrittenItems.find(&array);
if (checkWritten == mImpl->mWrittenItems.end() || array.getItemTag() == "DataItem") { if (checkWritten == mImpl->mWrittenItems.end() || array.getItemTag() == "DataItem") {
...@@ -1062,11 +1036,6 @@ XdmfHDF5Writer::visit(XdmfArray & array, ...@@ -1062,11 +1036,6 @@ XdmfHDF5Writer::visit(XdmfArray & array,
if(mImpl->mDepth <= 0) { if(mImpl->mDepth <= 0) {
mImpl->mWrittenItems.clear(); mImpl->mWrittenItems.clear();
} }
}
else {
// Fatal error if impl is null
XdmfError::message(XdmfError::FATAL, "Error: HDF5 internal object is NULL");
}
} }
...@@ -1074,7 +1043,6 @@ void ...@@ -1074,7 +1043,6 @@ void
XdmfHDF5Writer::visit(XdmfItem & item, XdmfHDF5Writer::visit(XdmfItem & item,
const shared_ptr<XdmfBaseVisitor> visitor) const shared_ptr<XdmfBaseVisitor> visitor)
{ {
if (mImpl != NULL) {
mImpl->mDepth++; mImpl->mDepth++;
// This is similar to the algorithm for writing XPaths // 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 // shouldn't be a problem if XPaths are turned off because all this does is avoid writing an object twice
...@@ -1088,11 +1056,6 @@ XdmfHDF5Writer::visit(XdmfItem & item, ...@@ -1088,11 +1056,6 @@ XdmfHDF5Writer::visit(XdmfItem & item,
if(mImpl->mDepth <= 0) { if(mImpl->mDepth <= 0) {
mImpl->mWrittenItems.clear(); mImpl->mWrittenItems.clear();
} }
}
else {
// Fatal error if impl is null
XdmfError::message(XdmfError::FATAL, "Error: HDF5 internal object is NULL");
}
} }
...@@ -1100,11 +1063,6 @@ void ...@@ -1100,11 +1063,6 @@ void
XdmfHDF5Writer::write(XdmfArray & array, XdmfHDF5Writer::write(XdmfArray & array,
const int fapl) 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; hid_t datatype = -1;
bool closeDatatype = false; bool closeDatatype = false;
......
...@@ -48,12 +48,6 @@ XdmfHeavyDataController::getArrayOffset() const ...@@ -48,12 +48,6 @@ XdmfHeavyDataController::getArrayOffset() const
return mArrayStartOffset; return mArrayStartOffset;
} }
std::string
XdmfHeavyDataController::getDescriptor() const
{
return "";
}
std::vector<unsigned int> std::vector<unsigned int>
XdmfHeavyDataController::getDimensions() const XdmfHeavyDataController::getDimensions() const
{ {
......
...@@ -76,7 +76,7 @@ public: ...@@ -76,7 +76,7 @@ public:
* *
* @return A string that contains relevant information for the controller