Commit ef98c862 authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Clean up a bit of const-correctness related things.

parent 94f61d16
......@@ -691,12 +691,12 @@ void XdmfArray::reserve(const unsigned int size)
}
}
void XdmfArray::setHDF5Controller(boost::shared_ptr<XdmfHDF5Controller> hdf5Controller)
void XdmfArray::setHDF5Controller(const boost::shared_ptr<XdmfHDF5Controller> hdf5Controller)
{
mHDF5Controller = hdf5Controller;
}
void XdmfArray::swap(boost::shared_ptr<XdmfArray> array)
void XdmfArray::swap(const boost::shared_ptr<XdmfArray> array)
{
ArrayVariant tmpArray = array->mArray;
ArrayPointerVariant tmpArrayPointer = array->mArrayPointer;
......
......@@ -163,7 +163,7 @@ public:
* @param valuesStride number of values to stride in the pointer between each copy.
*/
template <typename T>
void getValuesCopy(const unsigned int startIndex, T * valuesPointer, const unsigned int numValues = 1, const unsigned int arrayStride = 1, const unsigned int valuesStride = 1) const;
void getValuesCopy(const unsigned int startIndex, T * const valuesPointer, const unsigned int numValues = 1, const unsigned int arrayStride = 1, const unsigned int valuesStride = 1) const;
/**
* Get a pointer to the values stored in this array (const version).
......@@ -230,7 +230,7 @@ public:
*
* @param hdf5Controller the hdf5 controller to attach to this XdmfArray.
*/
void setHDF5Controller(boost::shared_ptr<XdmfHDF5Controller> hdf5Controller);
void setHDF5Controller(const boost::shared_ptr<XdmfHDF5Controller> hdf5Controller);
/**
* Sets the values of this array to the values stored in the arrayPointer array. No copy is made. Modifications to the array are
......@@ -266,7 +266,7 @@ public:
* @param array a smart pointer to a vector to store in this array.
*/
template<typename T>
void setValues(boost::shared_ptr<std::vector<T> > array);
void setValues(const boost::shared_ptr<std::vector<T> > array);
/**
* Exchange the contents of the vector with the contents of this XdmfArray. No copy is made. The internal arrays are swapped.
......@@ -283,7 +283,7 @@ public:
* @param array a smart pointer to a vector to exchange values with.
*/
template<typename T>
bool swap(boost::shared_ptr<std::vector<T> > array);
bool swap(const boost::shared_ptr<std::vector<T> > array);
/**
* Exchange the contents of an XdmfArray with the contents of this XdmfArray. No copy is made. The internal arrays are swapped.
......@@ -291,7 +291,7 @@ public:
* @param array a smart pointer to a vector to exchange values with.
* @return bool whether the swap was successful.
*/
void swap(boost::shared_ptr<XdmfArray> array);
void swap(const boost::shared_ptr<XdmfArray> array);
protected:
......
......@@ -185,7 +185,7 @@ boost::shared_ptr<std::vector<T> > XdmfArray::getValues()
//}
template <typename T>
void XdmfArray::getValuesCopy(const unsigned int startIndex, T * valuesPointer, const unsigned int numValues, const unsigned int arrayStride, const unsigned int valuesStride) const
void XdmfArray::getValuesCopy(const unsigned int startIndex, T * const valuesPointer, const unsigned int numValues, const unsigned int arrayStride, const unsigned int valuesStride) const
{
if(mHaveArray)
{
......@@ -287,7 +287,7 @@ void XdmfArray::setValues(std::vector<T> & array, const bool transferOwnership)
}
template <typename T>
void XdmfArray::setValues(boost::shared_ptr<std::vector<T> > array)
void XdmfArray::setValues(const boost::shared_ptr<std::vector<T> > array)
{
if(mHaveArrayPointer)
{
......@@ -321,7 +321,7 @@ bool XdmfArray::swap(std::vector<T> & array)
}
template <typename T>
bool XdmfArray::swap(boost::shared_ptr<std::vector<T> > array)
bool XdmfArray::swap(const boost::shared_ptr<std::vector<T> > array)
{
return this->swap(*array.get());
}
......@@ -40,12 +40,12 @@ void XdmfDataItem::populateItem(const std::map<std::string, std::string> & itemP
}
}
void XdmfDataItem::setArray(boost::shared_ptr<XdmfArray> array)
void XdmfDataItem::setArray(const boost::shared_ptr<XdmfArray> array)
{
mArray = array;
}
void XdmfDataItem::traverse(boost::shared_ptr<XdmfBaseVisitor> visitor)
void XdmfDataItem::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const
{
mArray->accept(visitor);
}
......@@ -38,9 +38,9 @@ public:
*
* @param array a smart pointer to the XdmfArray.
*/
void setArray(boost::shared_ptr<XdmfArray> array);
void setArray(const boost::shared_ptr<XdmfArray> array);
virtual void traverse(boost::shared_ptr<XdmfBaseVisitor> visitor);
virtual void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const;
protected:
......
......@@ -20,12 +20,12 @@ XdmfDomain::~XdmfDomain()
std::string XdmfDomain::ItemTag = "Domain";
void XdmfDomain::insert(boost::shared_ptr<XdmfGrid> grid)
void XdmfDomain::insert(const boost::shared_ptr<XdmfGrid> grid)
{
mGrids.push_back(grid);
}
boost::shared_ptr<XdmfGrid> XdmfDomain::getGrid(unsigned int index)
boost::shared_ptr<XdmfGrid> XdmfDomain::getGrid(const unsigned int index)
{
if(index >= mGrids.size())
{
......@@ -35,7 +35,7 @@ boost::shared_ptr<XdmfGrid> XdmfDomain::getGrid(unsigned int index)
return mGrids[index];
}
boost::shared_ptr<const XdmfGrid> XdmfDomain::getGrid(unsigned int index) const
boost::shared_ptr<const XdmfGrid> XdmfDomain::getGrid(const unsigned int index) const
{
if(index >= mGrids.size())
{
......@@ -78,7 +78,7 @@ void XdmfDomain::removeGrid(const unsigned int index)
mGrids.erase(mGrids.begin() + index);
}
void XdmfDomain::traverse(boost::shared_ptr<XdmfBaseVisitor> visitor)
void XdmfDomain::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const
{
for(std::vector<boost::shared_ptr<XdmfGrid> >::const_iterator iter = mGrids.begin(); iter != mGrids.end(); ++iter)
{
......
......@@ -27,7 +27,7 @@ public:
* @param index an unsigned int of the grid to retrieve.
* @return smart pointer to the grid at the specified index attached to this domain.
*/
boost::shared_ptr<XdmfGrid> getGrid(unsigned int index);
boost::shared_ptr<XdmfGrid> getGrid(const unsigned int index);
/**
* Get a XdmfGrid attached to this domain (const version).
......@@ -35,7 +35,7 @@ public:
* @param index of the grid to retrieve.
* @return pointer to the grid attached to this domain.
*/
boost::shared_ptr<const XdmfGrid> getGrid(unsigned int index) const;
boost::shared_ptr<const XdmfGrid> getGrid(const unsigned int index) const;
std::map<std::string, std::string> getItemProperties() const;
......@@ -53,7 +53,7 @@ public:
*
* @param grid a shared pointer to an XdmfGrid to insert into the domain.
*/
void insert(boost::shared_ptr<XdmfGrid> grid);
void insert(const boost::shared_ptr<XdmfGrid> grid);
/**
* Remove an XdmfGrid from the domain.
......@@ -62,7 +62,7 @@ public:
*/
void removeGrid(const unsigned int index);
virtual void traverse(boost::shared_ptr<XdmfBaseVisitor> visitor);
virtual void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const;
protected:
......
......@@ -118,12 +118,12 @@ boost::shared_ptr<const XdmfTopology> XdmfGrid::getTopology() const
return boost::const_pointer_cast<XdmfTopology>(static_cast<const XdmfGrid &>(*this).getTopology());
}
void XdmfGrid::insert(boost::shared_ptr<XdmfAttribute> attribute)
void XdmfGrid::insert(const boost::shared_ptr<XdmfAttribute> attribute)
{
mAttributes.push_back(attribute);
}
void XdmfGrid::insert(boost::shared_ptr<XdmfSet> set)
void XdmfGrid::insert(const boost::shared_ptr<XdmfSet> set)
{
mSets.push_back(set);
}
......@@ -182,7 +182,7 @@ void XdmfGrid::removeSet(const unsigned int index)
mSets.erase(mSets.begin() + index);
}
void XdmfGrid::setGeometry(boost::shared_ptr<XdmfGeometry> geometry)
void XdmfGrid::setGeometry(const boost::shared_ptr<XdmfGeometry> geometry)
{
mGeometry = geometry;
}
......@@ -192,12 +192,12 @@ void XdmfGrid::setName(const std::string & name)
mName= name;
}
void XdmfGrid::setTopology(boost::shared_ptr<XdmfTopology> topology)
void XdmfGrid::setTopology(const boost::shared_ptr<XdmfTopology> topology)
{
mTopology = topology;
}
void XdmfGrid::traverse(boost::shared_ptr<XdmfBaseVisitor> visitor)
void XdmfGrid::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const
{
mGeometry->accept(visitor);
mTopology->accept(visitor);
......
......@@ -132,14 +132,14 @@ public:
*
* @param attribute an XdmfAttribute to attach to this grid.
*/
void insert(boost::shared_ptr<XdmfAttribute> attribute);
void insert(const boost::shared_ptr<XdmfAttribute> attribute);
/**
* Insert an XdmfSet into the grid.
*
* @param set an XdmfSet to attach to this grid.
*/
void insert(boost::shared_ptr<XdmfSet> set);
void insert(const boost::shared_ptr<XdmfSet> set);
/**
* Remove an XdmfAttribute from the grid.
......@@ -160,14 +160,14 @@ public:
*
* @param geometry an XdmfGeometry to attach to this grid.
*/
void setGeometry(boost::shared_ptr<XdmfGeometry> geometry);
void setGeometry(const boost::shared_ptr<XdmfGeometry> geometry);
/**
* Set the XdmfTopology associated with this grid.
*
* @param topology an XdmfTopology to attach to this grid.
*/
void setTopology(boost::shared_ptr<XdmfTopology> topology);
void setTopology(const boost::shared_ptr<XdmfTopology> topology);
/**
* Set the name of the grid.
......@@ -176,7 +176,7 @@ public:
*/
void setName(const std::string & name);
virtual void traverse(boost::shared_ptr<XdmfBaseVisitor> visitor);
virtual void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const;
protected:
......
......@@ -22,7 +22,7 @@ XdmfGridCollection::~XdmfGridCollection()
std::string XdmfGridCollection::ItemTag = "Grid";
boost::shared_ptr<XdmfGrid> XdmfGridCollection::getGrid(unsigned int index)
boost::shared_ptr<XdmfGrid> XdmfGridCollection::getGrid(const unsigned int index)
{
if(index >= mGrids.size())
{
......@@ -31,7 +31,7 @@ boost::shared_ptr<XdmfGrid> XdmfGridCollection::getGrid(unsigned int index)
return mGrids[index];
}
boost::shared_ptr<const XdmfGrid> XdmfGridCollection::getGrid(unsigned int index) const
boost::shared_ptr<const XdmfGrid> XdmfGridCollection::getGrid(const unsigned int index) const
{
if(index >= mGrids.size())
{
......@@ -59,7 +59,7 @@ unsigned int XdmfGridCollection::getNumberOfGrids() const
return mGrids.size();
}
void XdmfGridCollection::insert(boost::shared_ptr<XdmfGrid> grid)
void XdmfGridCollection::insert(const boost::shared_ptr<XdmfGrid> grid)
{
mGrids.push_back(grid);
}
......@@ -95,7 +95,7 @@ void XdmfGridCollection::setGridCollectionType(const boost::shared_ptr<const Xdm
mCollectionType = collectionType;
}
void XdmfGridCollection::traverse(boost::shared_ptr<XdmfBaseVisitor> visitor)
void XdmfGridCollection::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const
{
for(std::vector<boost::shared_ptr<XdmfGrid> >::const_iterator iter = mGrids.begin(); iter != mGrids.end(); ++iter)
{
......
......@@ -29,7 +29,7 @@ public:
* @param index of grid to retrieve.
* @return the requested XdmfGrid.
*/
boost::shared_ptr<XdmfGrid> getGrid(unsigned int index);
boost::shared_ptr<XdmfGrid> getGrid(const unsigned int index);
/**
* Get a grid from this collection (const version).
......@@ -37,7 +37,7 @@ public:
* @param index of the grid to retrieve.
* @return the requested XdmfGrid.
*/
boost::shared_ptr<const XdmfGrid> getGrid(unsigned int index) const;
boost::shared_ptr<const XdmfGrid> getGrid(const unsigned int index) const;
/**
* Get the XdmfGridCollectionType associated with this grid collection.
......@@ -60,7 +60,7 @@ public:
*
* @param grid an XdmfGrid to insert into this collection.
*/
void insert(boost::shared_ptr<XdmfGrid> grid);
void insert(const boost::shared_ptr<XdmfGrid> grid);
/**
* Remove a grid from this collection.
......@@ -76,7 +76,7 @@ public:
*/
void setGridCollectionType(const boost::shared_ptr<const XdmfGridCollectionType> collectionType);
virtual void traverse(boost::shared_ptr<XdmfBaseVisitor> visitor);
virtual void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const;
protected:
......
......@@ -6,7 +6,7 @@
#include "XdmfArray.hpp"
#include "XdmfHDF5Controller.hpp"
XdmfHDF5Controller::XdmfHDF5Controller(const std::string & hdf5DataSetPath, const int precision, const int size, const std::string & type) :
XdmfHDF5Controller::XdmfHDF5Controller(const std::string & hdf5DataSetPath, const unsigned int precision, const unsigned int size, const std::string & type) :
mPrecision(precision),
mSize(size),
mType(type)
......@@ -41,12 +41,12 @@ std::string XdmfHDF5Controller::getDataSetPath() const
return toReturn.str();
}
int XdmfHDF5Controller::getPrecision() const
unsigned int XdmfHDF5Controller::getPrecision() const
{
return mPrecision;
}
int XdmfHDF5Controller::getSize() const
unsigned int XdmfHDF5Controller::getSize() const
{
return mSize;
}
......
......@@ -23,7 +23,7 @@ public:
/**
* Create a new controller for an hdf5 data set on disk.
*/
static boost::shared_ptr<XdmfHDF5Controller> New(const std::string & hdf5DataSetPath, const int precision, const int size, const std::string & type)
static boost::shared_ptr<XdmfHDF5Controller> New(const std::string & hdf5DataSetPath, const unsigned int precision, const unsigned int size, const std::string & type)
{
boost::shared_ptr<XdmfHDF5Controller> p(new XdmfHDF5Controller(hdf5DataSetPath, precision, size, type));
return p;
......@@ -41,14 +41,14 @@ public:
*
* @return a int containing the precision of the hdf5 data set.
*/
int getPrecision() const;
unsigned int getPrecision() const;
/**
* Get the size of the hdf5 data set owned by this controller.
*
* @return a int containing the size of the hdf5 data set.
*/
int getSize() const;
unsigned int getSize() const;
/**
* Get the data type of the hdf5 data set owned by this controller.
......@@ -66,7 +66,7 @@ public:
protected:
XdmfHDF5Controller(const std::string & hdf5DataSetPath, const int precision, const int size, const std::string & type);
XdmfHDF5Controller(const std::string & hdf5DataSetPath, const unsigned int precision, const unsigned int size, const std::string & type);
virtual ~XdmfHDF5Controller();
private:
......@@ -76,8 +76,8 @@ private:
std::string mDataSetName;
std::string mHDF5FilePath;
int mPrecision;
int mSize;
unsigned int mPrecision;
unsigned int mSize;
std::string mType;
};
......
......@@ -111,7 +111,7 @@ std::string XdmfHDF5Writer::getLastWrittenDataSet() const
return mImpl->mLastWrittenDataSet;
}
void XdmfHDF5Writer::visit(XdmfArray & array, boost::shared_ptr<XdmfBaseVisitor> visitor)
void XdmfHDF5Writer::visit(XdmfArray & array, const boost::shared_ptr<XdmfBaseVisitor> visitor)
{
hid_t datatype = -1;
mImpl->mLastWrittenDataSet = "";
......
......@@ -45,7 +45,7 @@ public:
* @param array an XdmfArray to write to HDF5.
* @param visitor a smart pointer to this visitor --- aids in grid traversal.
*/
void visit(XdmfArray & array, boost::shared_ptr<XdmfBaseVisitor> visitor);
void visit(XdmfArray & array, const boost::shared_ptr<XdmfBaseVisitor> visitor);
protected:
......
......@@ -8,7 +8,7 @@ XdmfItem::~XdmfItem()
{
}
void XdmfItem::traverse(boost::shared_ptr<XdmfBaseVisitor> visitor)
void XdmfItem::traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const
{
return;
}
......@@ -49,7 +49,7 @@ public:
*
* @param a visitor to pass to this XdmfItem's children.
*/
virtual void traverse(boost::shared_ptr<XdmfBaseVisitor> visitor);
virtual void traverse(const boost::shared_ptr<XdmfBaseVisitor> visitor) const;
protected:
......
......@@ -12,7 +12,7 @@ XdmfVisitor::~XdmfVisitor()
{
}
void XdmfVisitor::visit(XdmfItem & item, boost::shared_ptr<XdmfBaseVisitor> visitor)
void XdmfVisitor::visit(XdmfItem & item, const boost::shared_ptr<XdmfBaseVisitor> visitor)
{
std::cout << "Writing in base" << std::endl;
item.traverse(visitor);
......
......@@ -20,7 +20,7 @@ class XdmfVisitor : public XdmfObject,
public:
virtual void visit(XdmfItem & item, boost::shared_ptr<XdmfBaseVisitor> visitor);
virtual void visit(XdmfItem & item, const boost::shared_ptr<XdmfBaseVisitor> visitor);
protected:
......
......@@ -15,7 +15,7 @@ class XdmfWriter::XdmfWriterImpl {
public:
XdmfWriterImpl(const std::string & xmlFilePath, boost::shared_ptr<XdmfHDF5Writer> hdf5Writer) :
XdmfWriterImpl(const std::string & xmlFilePath, const boost::shared_ptr<XdmfHDF5Writer> hdf5Writer) :
mHDF5Writer(hdf5Writer),
mLightDataLimit(100),
mXMLFilePath(xmlFilePath),
......@@ -81,12 +81,12 @@ void XdmfWriter::openFile()
xmlDocSetRootElement(mImpl->mXMLDocument, mImpl->mXMLCurrentNode);
}
void XdmfWriter::setLightDataLimit(unsigned int numValues)
void XdmfWriter::setLightDataLimit(const unsigned int numValues)
{
mImpl->mLightDataLimit = numValues;
}
void XdmfWriter::visit(XdmfArray & array, boost::shared_ptr<XdmfBaseVisitor> visitor)
void XdmfWriter::visit(XdmfArray & array, const boost::shared_ptr<XdmfBaseVisitor> visitor)
{
std::stringstream xmlTextValues;
if(array.getHDF5Controller() || array.getSize() > mImpl->mLightDataLimit)
......@@ -103,7 +103,7 @@ void XdmfWriter::visit(XdmfArray & array, boost::shared_ptr<XdmfBaseVisitor> vis
xmlAddChild(mImpl->mXMLCurrentNode->children, xmlNewText((xmlChar*)xmlTextValues.str().c_str()));
}
void XdmfWriter::visit(XdmfItem & item, boost::shared_ptr<XdmfBaseVisitor> visitor)
void XdmfWriter::visit(XdmfItem & item, const boost::shared_ptr<XdmfBaseVisitor> visitor)
{
if(mImpl->mTraverseLevel == 0)
{
......
......@@ -44,7 +44,7 @@ public:
* @param hdf5Writer the heavy data writer to use when writing.
* @return the new XdmfWriter.
*/
static boost::shared_ptr<XdmfWriter> New(const std::string & xmlFilePath, boost::shared_ptr<XdmfHDF5Writer> hdf5Writer)
static boost::shared_ptr<XdmfWriter> New(const std::string & xmlFilePath, const boost::shared_ptr<XdmfHDF5Writer> hdf5Writer)
{
boost::shared_ptr<XdmfWriter> p(new XdmfWriter(xmlFilePath, hdf5Writer));
return p;
......@@ -62,7 +62,7 @@ public:
*
* @param numValues an unsigned int containing the number of values.
*/
void setLightDataLimit(unsigned int numValues);
void setLightDataLimit(const unsigned int numValues);
/**
* Write an XdmfArray to disk
......@@ -70,7 +70,7 @@ public:
* @param array an XdmfArray to write to disk.
* @param visitor a smart pointer to this visitor --- aids in grid traversal.
*/
void visit(XdmfArray & array, boost::shared_ptr<XdmfBaseVisitor> visitor);
void visit(XdmfArray & array, const boost::shared_ptr<XdmfBaseVisitor> visitor);
/**
* Write an XdmfItem to disk
......@@ -78,7 +78,7 @@ public:
* @param item an XdmfItem to write to disk.
* @param visitor a smart pointer to this visitor --- aids in grid traversal.
*/
void visit(XdmfItem & item, boost::shared_ptr<XdmfBaseVisitor> visitor);
void visit(XdmfItem & item, const boost::shared_ptr<XdmfBaseVisitor> visitor);
protected:
......
......@@ -255,12 +255,12 @@ struct DefaultCatchAll
public:
typedef R ReturnType;
virtual ~BaseVisitable() {}
virtual ReturnType accept(boost::shared_ptr<BaseVisitor>) = 0;
virtual ReturnType accept(const boost::shared_ptr<BaseVisitor>) = 0;
protected: // give access only to the hierarchy
template <class T>
static ReturnType acceptImpl(T& visited, boost::shared_ptr<BaseVisitor> guest)
static ReturnType acceptImpl(T& visited, const boost::shared_ptr<BaseVisitor> guest)
{
// Apply the Acyclic Visitor
if (Visitor<T,R>* p = dynamic_cast<Visitor<T,R>*>(guest.get()))
......@@ -281,7 +281,7 @@ struct DefaultCatchAll
protected: // give access only to the hierarchy
template <class T>
static ReturnType acceptImpl(const T& visited, boost::shared_ptr<BaseVisitor> guest)
static ReturnType acceptImpl(const T& visited, const boost::shared_ptr<BaseVisitor> guest)
{
// Apply the Acyclic Visitor
if (Visitor<T,R,true>* p = dynamic_cast<Visitor<T,R,true>*>(guest.get))
......@@ -300,11 +300,11 @@ struct DefaultCatchAll
////////////////////////////////////////////////////////////////////////////////
#define LOKI_DEFINE_VISITABLE_BASE() \
virtual ReturnType accept(boost::shared_ptr<Loki::BaseVisitor> guest) \
virtual ReturnType accept(const boost::shared_ptr<Loki::BaseVisitor> guest) \
{ return acceptImpl(*this, guest); }
#define LOKI_DEFINE_VISITABLE(my_class, my_base) \
virtual ReturnType accept(boost::shared_ptr<Loki::BaseVisitor> guest) \
virtual ReturnType accept(const boost::shared_ptr<Loki::BaseVisitor> guest) \
{ \
if (Loki::Visitor<my_class,ReturnType>* p = dynamic_cast<Loki::Visitor<my_class,ReturnType>*>(guest.get())) \
{ \
......@@ -324,7 +324,7 @@ struct DefaultCatchAll
////////////////////////////////////////////////////////////////////////////////
#define LOKI_DEFINE_CONST_VISITABLE() \
virtual ReturnType accept(boost::shared_ptr<::Loki::BaseVisitor> guest) const \
virtual ReturnType accept(const boost::shared_ptr<::Loki::BaseVisitor> guest) const \
{ return acceptImpl(*this, guest); }
////////////////////////////////////////////////////////////////////////////////
......
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