Newer
Older
* Distributed under the OSI-approved Apache License, Version 2.0. See
* accompanying file Copyright.txt for details.
*
* Heap.cpp
*
* Created on: Dec 22, 2016
* Author: wfg
*/
/// \cond EXCLUDE_FROM_DOXYGEN
#include <new> //std::bad_alloc
#include <stdexcept> //std::runtime_error
/// \endcond
#include "STLVector.h"
namespace adios
{
namespace capsule
{
STLVector::STLVector(std::string accessMode, int rankMPI, bool debugMode)
: Capsule{"Heap", std::move(accessMode), rankMPI, debugMode}
}
char *STLVector::GetData() { return m_Data.data(); }
char *STLVector::GetMetadata() { return m_Metadata.data(); }
std::size_t STLVector::GetDataSize() const { return m_Data.size(); }
std::size_t STLVector::GetMetadataSize() const { return m_Metadata.size(); }
void STLVector::ResizeData(const std::size_t size)
{
try
{
m_Data.resize(size);
}
catch (std::bad_alloc &e)
{
throw std::runtime_error("ERROR: bad_alloc detected when resizing "
"data buffer with size " +
std::to_string(size) + "\n");
}
}
}
void STLVector::ResizeMetadata(const std::size_t size)
{
try
{
m_Metadata.resize(size);
}
catch (std::bad_alloc &e)
{
throw std::runtime_error("ERROR: bad_alloc detected when resizing "
"metadata buffer with size " +
std::to_string(size) + "\n");
}
} // end namespace capsule
} // end namespace adios