Commit 701d36d4 authored by David E. DeMarle's avatar David E. DeMarle

Merge branch 'revert-noboost' into 'master'

Revert the removal of boost changes

See merge request !37
parents 5d1e9713 8e39bc04
......@@ -79,17 +79,13 @@ ENDMACRO()
# Output:
# is_core = variable is set to 'Core' is core was found in dir
MACRO(SET_CORE dir)
IF(NOT "${XDMF_SUBSECTION}" STREQUAL "")
set(is_core ${XDMF_SUBSECTION})
ELSE()
STRING(REGEX MATCH "core" is_core "${dir}")
STRING(REGEX MATCH "core" is_core "${dir}")
IF(EXISTS ${is_core})
SET(is_core "Core")
ELSE(EXISTS ${is_core})
STRING(REGEX MATCH "utils" is_core "${dir}")
IF(EXISTS ${is_core})
SET(is_core "Core")
ELSE(EXISTS ${is_core})
STRING(REGEX MATCH "utils" is_core "${dir}")
IF(EXISTS ${is_core})
SET(is_core "Util")
ENDIF(EXISTS ${is_core})
SET(is_core "Util")
ENDIF(EXISTS ${is_core})
ENDIF(NOT "${XDMF_SUBSECTION}" STREQUAL "")
ENDIF(EXISTS ${is_core})
ENDMACRO(SET_CORE dir)
......@@ -12,8 +12,6 @@ if(MSVC10)
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR})
endif()
include(CheckCXXSourceCompiles)
set(XDMF_LIBNAME "Xdmf" CACHE STRING "Name for this xdmf library to avoid collision")
set(XDMF_MAJOR_VERSION 3)
......@@ -50,7 +48,6 @@ if (XDMF_STATIC_AND_SHARED)
endif ()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/CMake/VersionSuite)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
list(APPEND CMAKE_MODULE_PATH
......@@ -103,33 +100,6 @@ endif (TIFF_FOUND)
# Test for DSM
option(XDMF_BUILD_DSM OFF)
mark_as_advanced(XDMF_BUILD_DSM)
option(XDMF_TRY_NOBOOST ON)
mark_as_advanced(XDMF_TRY_NOBOOST)
if (XDMF_TRY_NOBOOST)
# Test for Cxx11
unset(HAVE_CXX11_SHARED_PTR CACHE)
check_cxx_source_compiles("
#include <memory>
using namespace std;
struct Base { virtual ~Base(){} };
int main(int ac, char * av[])
{
shared_ptr<Base> ptr(new Base());
}
"
HAVE_CXX11_SHARED_PTR)
endif ()
# Cxx11 does not work with swig due to an issue with swig
if (HAVE_CXX11_SHARED_PTR AND NOT XDMF_WRAP_PYTHON)
add_definitions(-DHAVE_CXX11_SHARED_PTR)
endif ()
if(XDMF_BUILD_DSM)
find_package(MPI REQUIRED)
if(MPI_FOUND)
......@@ -403,15 +373,7 @@ if(NOT XDMF_BUILD_CORE_ONLY)
)
endif (BUILD_SHARED_LIBS)
else()
if (WIN32)
if (XDMF_BUILD_DSM)
add_library(${XDMF_LIBNAME} ${LIBTYPE} ${XdmfSources} ${XdmfCoreSources} ${XdmfDSMSources})
else ()
add_library(${XDMF_LIBNAME} ${LIBTYPE} ${XdmfSources} ${XdmfCoreSources})
endif ()
else ()
add_library(${XDMF_LIBNAME} ${LIBTYPE} ${XdmfSources})
endif ()
add_library(${XDMF_LIBNAME} ${LIBTYPE} ${XdmfSources})
endif()
SET_TARGET_PROPERTIES(
${XDMF_LIBNAME} PROPERTIES
......
......@@ -142,28 +142,22 @@
# define XDMF_TEMPLATE
#else
/* Used to export/import from the dlls */
# undef XDMFCORE_EXPORT
# define XDMFCORE_EXPORT __declspec(dllimport)
# undef XDMFCORE_TEMPLATE
# define XDMFCORE_TEMPLATE extern
# undef XDMFDSM_EXPORT
# define XDMFDSM_EXPORT __declspec(dllimport)
# undef XDMFDSM_TEMPLATE
# define XDMFDSM_TEMPLATE extern
# ifdef XDMF_EXPORTS
# define XDMF_EXPORT __declspec(dllexport)
# define XDMF_TEMPLATE
# undef XDMFCORE_EXPORT
# define XDMFCORE_EXPORT __declspec(dllexport)
# undef XDMFCORE_TEMPLATE
# define XDMFCORE_TEMPLATE
# undef XDMFDSM_EXPORT
# define XDMFDSM_EXPORT __declspec(dllexport)
# undef XDMFDSM_TEMPLATE
# define XDMFDSM_TEMPLATE
# define XDMF_EXPORT __declspec(dllexport)
# define XDMF_TEMPLATE
# else /* XDMF_EXPORTS */
# define XDMF_EXPORT __declspec(dllimport)
# define XDMF_TEMPLATE extern
# undef XDMFCORE_EXPORT
# define XDMFCORE_EXPORT __declspec(dllimport)
# undef XDMFCORE_TEMPLATE
# define XDMFCORE_TEMPLATE extern
# undef XDMFDSM_EXPORT
# define XDMFDSM_EXPORT __declspec(dllimport)
# undef XDMFDSM_TEMPLATE
# define XDMFDSM_TEMPLATE extern
# define XDMF_EXPORT __declspec(dllimport)
# define XDMF_TEMPLATE extern
# endif /* XDMF_EXPORTS */
#endif
......
......@@ -23,6 +23,7 @@
#include <numeric>
#include <functional>
#include <boost/tokenizer.hpp>
#include "XdmfArray.hpp"
#include "XdmfError.hpp"
#include "XdmfAggregate.hpp"
......
......@@ -114,7 +114,11 @@ XdmfAttribute::populateItem(const std::map<std::string, std::string> & itemPrope
iter != childItems.end();
++iter) {
if(shared_ptr<XdmfArray> array = shared_dynamic_cast<XdmfArray>(*iter)) {
this->populateArray(array);
this->swap(array);
if (array->getReference()) {
this->setReference(array->getReference());
this->setReadMode(XdmfArray::Reference);
}
break;
}
}
......
......@@ -276,7 +276,7 @@ XdmfCurvilinearGrid::copyGrid(shared_ptr<XdmfGrid> sourceGrid)
shared_ptr<XdmfArray>
XdmfCurvilinearGrid::getDimensions()
{
return const_pointer_cast<XdmfArray>
return boost::const_pointer_cast<XdmfArray>
(static_cast<const XdmfCurvilinearGrid &>(*this).getDimensions());
}
......@@ -289,7 +289,7 @@ XdmfCurvilinearGrid::getDimensions() const
shared_ptr<XdmfGeometry>
XdmfCurvilinearGrid::getGeometry()
{
return const_pointer_cast<XdmfGeometry>
return boost::const_pointer_cast<XdmfGeometry>
(static_cast<const XdmfGrid &>(*this).getGeometry());
}
......
......@@ -25,7 +25,7 @@
#include "XdmfGeometryType.hpp"
#include "XdmfError.hpp"
#include "XdmfFunction.hpp"
#include <cstring>
#include <boost/tokenizer.hpp>
shared_ptr<XdmfGeometry> XdmfGeometry::New()
{
......@@ -176,7 +176,11 @@ XdmfGeometry::populateItem(const std::map<std::string, std::string> & itemProper
iter != childItems.end();
++iter) {
if(shared_ptr<XdmfArray> array = shared_dynamic_cast<XdmfArray>(*iter)) {
this->populateArray(array);
this->swap(array);
if (array->getReference()) {
this->setReference(array->getReference());
this->setReadMode(XdmfArray::Reference);
}
break;
}
}
......@@ -191,25 +195,12 @@ XdmfGeometry::populateItem(const std::map<std::string, std::string> & itemProper
std::map<std::string, std::string>::const_iterator origin =
itemProperties.find("Origin");
if (origin != itemProperties.end()) {
#ifdef HAVE_CXX11_SHARED_PTR
char * originString = strdup(origin->second.c_str());
char * token = std::strtok(originString, " ");
while (token != NULL)
{
mOrigin.push_back(atof(token));
token = std::strtok(NULL, " ");
}
free(originString);
originString = NULL;
#else
boost::tokenizer<> tokens(origin->second);
for(boost::tokenizer<>::const_iterator iter = tokens.begin();
iter != tokens.end();
++iter) {
mOrigin.push_back(atof((*iter).c_str()));
}
#endif
}
}
......
......@@ -62,7 +62,7 @@ XdmfGraph::getItemTag() const
shared_ptr<XdmfTime>
XdmfGraph::getTime()
{
return const_pointer_cast<XdmfTime>
return boost::const_pointer_cast<XdmfTime>
(static_cast<const XdmfGraph &>(*this).getTime());
}
......
......@@ -141,7 +141,7 @@ XdmfGrid::getName() const
shared_ptr<XdmfTime>
XdmfGrid::getTime()
{
return const_pointer_cast<XdmfTime>
return boost::const_pointer_cast<XdmfTime>
(static_cast<const XdmfGrid &>(*this).getTime());
}
......
......@@ -42,6 +42,8 @@
#include "XdmfSystemUtils.hpp"
#include <boost/tokenizer.hpp>
#include <stdio.h>
shared_ptr<XdmfGridTemplate>
......
......@@ -21,9 +21,8 @@
/* */
/*****************************************************************************/
#include <algorithm>
#include <cctype>
#include <cstring>
#include <boost/tokenizer.hpp>
#include "XdmfAttribute.hpp"
#include "XdmfCurvilinearGrid.hpp"
#include "XdmfDomain.hpp"
......@@ -278,25 +277,12 @@ XdmfItemFactory::createItem(const std::string & itemTag,
if(dimensions != itemProperties.end()) {
dimensionsString = dimensions->second;
}
#ifdef HAVE_CXX11_SHARED_PTR
char * dimString = strdup(dimensionsString.c_str());
char * token = std::strtok(dimString, " ");
while (token != NULL)
{
dimensionsArray->pushBack(atoi(token));
token = std::strtok(NULL, " ");
}
free(dimString);
dimString = NULL;
#else
boost::tokenizer<> tokens(dimensionsString);
for(boost::tokenizer<>::const_iterator iter = tokens.begin();
iter != tokens.end();
++iter) {
dimensionsArray->pushBack<unsigned int>(atoi((*iter).c_str()));
}
#endif
if(typeVal.compare("2DCORECTMESH") == 0 ||
typeVal.compare("3DCORECTMESH") == 0 ||
typeVal.compare("CORECTMESH") == 0) {
......
......@@ -333,7 +333,7 @@ XdmfRectilinearGrid::copyGrid(shared_ptr<XdmfGrid> sourceGrid)
shared_ptr<XdmfArray>
XdmfRectilinearGrid::getCoordinates(const unsigned int axisIndex)
{
return const_pointer_cast<XdmfArray>
return boost::const_pointer_cast<XdmfArray>
(static_cast<const XdmfRectilinearGrid &>
(*this).getCoordinates(axisIndex));
}
......@@ -362,7 +362,7 @@ XdmfRectilinearGrid::getCoordinates() const
shared_ptr<XdmfArray>
XdmfRectilinearGrid::getDimensions()
{
return const_pointer_cast<XdmfArray>
return boost::const_pointer_cast<XdmfArray>
(static_cast<const XdmfRectilinearGrid &>(*this).getDimensions());
}
......
......@@ -373,7 +373,7 @@ XdmfRegularGrid::copyGrid(shared_ptr<XdmfGrid> sourceGrid)
shared_ptr<XdmfArray>
XdmfRegularGrid::getBrickSize()
{
return const_pointer_cast<XdmfArray>
return boost::const_pointer_cast<XdmfArray>
(static_cast<const XdmfRegularGrid &>(*this).getBrickSize());
}
......@@ -386,7 +386,7 @@ XdmfRegularGrid::getBrickSize() const
shared_ptr<XdmfArray>
XdmfRegularGrid::getDimensions()
{
return const_pointer_cast<XdmfArray>
return boost::const_pointer_cast<XdmfArray>
(static_cast<const XdmfRegularGrid &>(*this).getDimensions());
}
......@@ -399,7 +399,7 @@ XdmfRegularGrid::getDimensions() const
shared_ptr<XdmfArray>
XdmfRegularGrid::getOrigin()
{
return const_pointer_cast<XdmfArray>
return boost::const_pointer_cast<XdmfArray>
(static_cast<const XdmfRegularGrid &>(*this).getOrigin());
}
......
......@@ -107,7 +107,7 @@ XdmfSet::populateItem(const std::map<std::string, std::string> & itemProperties,
else if(shared_ptr<XdmfArray> array =
shared_dynamic_cast<XdmfArray>(*iter)) {
if (!filled) {
this->populateArray(array);
this->swap(array);
filled = true;
}
if (array->getReference()) {
......
......@@ -24,7 +24,6 @@
#include <sstream>
#include <utility>
#include <climits>
#include <cstring>
#include <set>
#include "XdmfArray.hpp"
#include "XdmfHDF5Controller.hpp"
......@@ -39,6 +38,8 @@
#include "XdmfSystemUtils.hpp"
#include <boost/tokenizer.hpp>
#include <stdio.h>
std::vector<shared_ptr<XdmfHeavyDataController> >
......@@ -887,9 +888,7 @@ XdmfTemplate::preallocateSteps(unsigned int numSteps)
//printf("allocating subsection %u\n", allocateIteration);
//*/
//printf("initializing base array\n");
std::vector<unsigned int> preallocatedSizeVector;
preallocatedSizeVector.push_back(preallocatedSize);
tempArray->initialize(mTrackedArrays[i]->getArrayType(), preallocatedSizeVector);
tempArray->initialize(mTrackedArrays[i]->getArrayType(), preallocatedSize);
//printf("writing subsection");
tempArray->accept(mHeavyWriter);
//printf("subsection written\n");
......@@ -1115,28 +1114,6 @@ XdmfTemplate::setStep(unsigned int stepId)
mTrackedArrays[i]->initialize(mTrackedArrayTypes[i], mTrackedArrayDims[i]);
unsigned int index = 0;
#ifdef HAVE_CXX11_SHARED_PTR
char * trackedString = strdup(content.c_str());
char * token = std::strtok(trackedString, " \t\n");
if(mTrackedArrayTypes[i] == XdmfArrayType::String()) {
while (token != NULL)
{
mTrackedArrays[i]->insert(index, std::string(token));
token = std::strtok(NULL, " \t\n");
++index;
}
}
else {
while (token != NULL)
{
mTrackedArrays[i]->insert(index, atof(token));
token = std::strtok(NULL, " \t\n");
++index;
}
}
free(trackedString);
trackedString = NULL;
#else
boost::char_separator<char> sep(" \t\n");
boost::tokenizer<boost::char_separator<char> > valtokens(content, sep);
if(mTrackedArrayTypes[i] == XdmfArrayType::String()) {
......@@ -1155,7 +1132,6 @@ XdmfTemplate::setStep(unsigned int stepId)
mTrackedArrays[i]->insert(index, atof((*iter).c_str()));
}
}
#endif
}
}
}
......
......@@ -158,7 +158,11 @@ XdmfTopology::populateItem(const std::map<std::string, std::string> & itemProper
iter != childItems.end();
++iter) {
if(shared_ptr<XdmfArray> array = shared_dynamic_cast<XdmfArray>(*iter)) {
this->populateArray(array);
this->swap(array);
if (array->getReference()) {
this->setReference(array->getReference());
this->setReadMode(XdmfArray::Reference);
}
break;
}
}
......
......@@ -259,7 +259,7 @@ XdmfUnstructuredGrid::copyGrid(shared_ptr<XdmfGrid> sourceGrid)
shared_ptr<XdmfGeometry>
XdmfUnstructuredGrid::getGeometry()
{
return const_pointer_cast<XdmfGeometry>
return boost::const_pointer_cast<XdmfGeometry>
(static_cast<const XdmfGrid &>(*this).getGeometry());
}
......@@ -272,7 +272,7 @@ XdmfUnstructuredGrid::getItemTag() const
shared_ptr<XdmfTopology>
XdmfUnstructuredGrid::getTopology()
{
return const_pointer_cast<XdmfTopology>
return boost::const_pointer_cast<XdmfTopology>
(static_cast<const XdmfGrid &>(*this).getTopology());
}
......
......@@ -39,7 +39,7 @@ if(XDMF_BUILD_DSM)
endif()
mark_as_advanced(CLEAR Boost_INCLUDE_DIR)
find_package(Boost)
find_package(Boost REQUIRED)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
mark_as_advanced(FORCE Boost_INCLUDE_DIR)
......@@ -117,8 +117,7 @@ endif()
TEST_BIG_ENDIAN(XDMF_BIG_ENDIAN)
unset(HAVE_BOOST_SHARED_DYNAMIC_CAST CACHE)
unset(HAVE_CXX11_SHARED_PTR CACHE)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${Boost_INCLUDE_DIRS})
check_cxx_source_compiles("
#include <boost/shared_ptr.hpp>
......@@ -133,26 +132,6 @@ int main(int ac, char * av[])
"
HAVE_BOOST_SHARED_DYNAMIC_CAST)
if (XDMF_TRY_NOBOOST)
check_cxx_source_compiles("
#include <memory>
using namespace std;
struct Base { virtual ~Base(){} };
int main(int ac, char * av[])
{
shared_ptr<Base> ptr(new Base());
}
"
HAVE_CXX11_SHARED_PTR)
endif ()
if (HAVE_CXX11_SHARED_PTR AND NOT XDMF_WRAP_PYTHON)
add_definitions(-DHAVE_CXX11_SHARED_PTR)
endif ()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/XdmfCoreConfig.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/XdmfCoreConfig.hpp)
......@@ -245,9 +224,6 @@ SET_TARGET_PROPERTIES(
SOVERSION ${XDMF_MAJOR_VERSION}
)
set(XDMF_LIBRARY_DIRS ${XDMF_LIBRARY_DIRS} PARENT_SCOPE)
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} PARENT_SCOPE)
link_directories(${XDMF_LIBRARY_DIRS})
target_link_libraries(XdmfCore ${XDMF_LIBRARIES})
......@@ -350,6 +326,7 @@ set(XdmfCore_INCLUDE_DIRS
CACHE INTERNAL "")
set(XDMF_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include PARENT_SCOPE)
set(XDMF_LIBRARIES ${XDMF_LIBRARIES} ${CMAKE_INSTALL_PREFIX}/lib)
set(XDMF_DIR ${CMAKE_INSTALL_PREFIX} PARENT_SCOPE)
set(XDMF_BINARIES ${XDMF_BINARIES} ${CMAKE_INSTALL_PREFIX}/bin)
......
......@@ -21,12 +21,13 @@
/* */
/*****************************************************************************/
#include <boost/tokenizer.hpp>
#include <limits>
#include <sstream>
#include <utility>
#include <stack>
#include <math.h>
#include <cstring>
#include <string.h>
#include "XdmfArray.hpp"
#include "XdmfArrayType.hpp"
#include "XdmfArrayReference.hpp"
......@@ -43,143 +44,518 @@ XDMF_CHILDREN_IMPLEMENTATION(XdmfArray,
HeavyDataController,
Name)
template<>
void
XdmfArray::setArrayType<std::string>();
class XdmfArray::Clear : public boost::static_visitor<void> {
public:
template<>
XDMFCORE_EXPORT
std::string
XdmfArray::GetValuesString<std::string>::getValuesString<void, void>(const void * const array,
const int numValues) const
{
const int lastIndex = numValues - 1;
Clear(XdmfArray * const array) :
mArray(array)
{
}
if(lastIndex < 0) {
return "";
void
operator()(const boost::blank & array) const
{
return;
}
std::stringstream toReturn;
toReturn.precision(std::numeric_limits<char>::digits10 + 2);
for(int i=0; i<lastIndex; ++i) {
toReturn << (char)((char *)array)[i] << " ";
template<typename T>
void
operator()(const shared_ptr<std::vector<T> > & array) const
{
array->clear();
}
toReturn << (char)((char *)array)[lastIndex];
return toReturn.str();
}
template <>
XDMFCORE_EXPORT
std::string
XdmfArray::getValue<std::string>(const unsigned int index) const
{
std::string * internalRef = NULL;
XdmfArray::GetValue<std::string> visitor = GetValue<std::string>(this, index);
return ApplyVisitor(this,
visitor,
mArray,
internalRef);
}
template<typename T>
void
operator()(const boost::shared_array<const T> & array) const
{
mArray->internalizeArrayPointer();
boost::apply_visitor(*this,
mArray->mArray);
}
template <>
XDMFCORE_EXPORT
void *
XdmfArray::initialize<void>(const unsigned int size)
{
return this->initialize<char>(size);
}
private:
XdmfArray * const mArray;
};
template <>
XDMFCORE_EXPORT
std::string *
XdmfArray::initialize<std::string>(const unsigned int size)
{
// Set type of variant to type of pointer
if (mCapacity.size() == 0)
class XdmfArray::Erase : public boost::static_visitor<void> {
public:
Erase(XdmfArray * const array,
const unsigned int index) :
mArray(array),
mIndex(index)
{
mCapacity.push_back(0);
}
if (size * mStringSize > mCapacity[0] * getArrayType()->getElementSize())
void
operator()(const boost::blank & array) const
{
if (size >= mTmpReserveSize)
{
if (mArray)
{
void * newArray = calloc(size, mStringSize);
memcpy(newArray, mArray, mCapacity[0] * getArrayType()->getElementSize());
std::swap(mArray, newArray);
free(newArray);
}
else
{
void * newArray = calloc(size, mStringSize);
std::swap(mArray, newArray);
}
if (mArray == NULL)
{
XdmfError::message(XdmfError::FATAL,
"Error: Allocation Failed.");
}
mCapacity[0] = size;
return;
}
template<typename T>
void
operator()(const shared_ptr<std::vector<T> > & array) const
{
array->erase(array->begin() + mIndex);
}
template<typename T>
void
operator()(const boost::shared_array<const T> & array) const
{
mArray->internalizeArrayPointer();
boost::apply_visitor(*this,
mArray->mArray);
}
private:
XdmfArray * const mArray;
const unsigned int mIndex;
};
class XdmfArray::GetArrayType :
public boost::static_visitor<shared_ptr<const XdmfArrayType> > {
public:
GetArrayType(const shared_ptr<XdmfHeavyDataController> & heavyDataController) :
mHeavyDataController(heavyDataController)
{
}
shared_ptr<const XdmfArrayType>
getArrayType(const char * const) const
{
return XdmfArrayType::Int8();
}
shared_ptr<const XdmfArrayType>
getArrayType(const short * const) const
{
return XdmfArrayType::Int16();
}
shared_ptr<const XdmfArrayType>
getArrayType(const int * const) const
{
return XdmfArrayType::Int32();
}
shared_ptr<const XdmfArrayType>
getArrayType(const long * const) const
{
return XdmfArrayType::Int64();
}
shared_ptr<const XdmfArrayType>
getArrayType(const float * const) const
{
return XdmfArrayType::Float32();
}
shared_ptr<const XdmfArrayType>
getArrayType(const double * const) const
{
return XdmfArrayType::Float64();
}
shared_ptr<const XdmfArrayType>
getArrayType(const unsigned char * const) const
{
return XdmfArrayType::UInt8();
}