ENH: Add initialize() method that allows user to specify the type of data to...

ENH: Add initialize() method that allows user to specify the type of data to store in an XdmfArray if desired.
parent 5e476e23
......@@ -135,6 +135,12 @@ public:
*/
virtual std::string getValuesString() const;
/**
* Initializes the array to contain an empty container of a particular type.
*/
template <typename T>
void initialize();
virtual std::string printSelf() const;
/**
......
......@@ -45,10 +45,7 @@ void XdmfArray::copyValues(int startIndex, T * valuesPointer, int numValues, int
{
if(!mInitialized)
{
// Set type of variant to type of pointer
boost::shared_ptr<std::vector<T> > newArray(new std::vector<T>());
mArray = newArray;
mInitialized = true;
initialize<T>();
}
boost::apply_visitor( XdmfArrayCopyValues<T>(startIndex, valuesPointer, numValues, arrayStride, valuesStride), mArray);
}
......@@ -81,6 +78,15 @@ const boost::shared_ptr<const std::vector<T> > XdmfArray::getValues() const
}
}
template <typename T>
void XdmfArray::initialize()
{
// Set type of variant to type of pointer
boost::shared_ptr<std::vector<T> > newArray(new std::vector<T>());
mArray = newArray;
mInitialized = true;
}
template<typename T>
void XdmfArray::setValues(boost::shared_ptr<std::vector<T> > array)
{
......@@ -93,10 +99,7 @@ bool XdmfArray::swap(std::vector<T> & array)
{
if(!mInitialized)
{
// Set type of variant to type of pointer
boost::shared_ptr<std::vector<T> > newArray(new std::vector<T>());
mArray = newArray;
mInitialized = true;
initialize<T>();
}
try
{
......
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