From ed8cc620ead159bf7d6d6dea8f45dc601a2fe4bf Mon Sep 17 00:00:00 2001 From: aothms Date: Mon, 25 Jan 2016 14:42:41 +0100 Subject: [PATCH] Use boost::shared_ptr Fixes https://github.com/IfcOpenShell/IfcOpenShell/issues/17 --- src/ifcconvert/SvgSerializer.cpp | 2 +- src/ifcconvert/SvgSerializer.h | 12 ++++----- src/ifcconvert/util.cpp | 10 ++++---- src/ifcconvert/util.h | 10 ++++---- src/ifcgeom/IfcGeomFaces.cpp | 2 +- src/ifcparse/IfcEntityDescriptor.h | 3 ++- src/ifcparse/IfcParse.h | 2 +- src/ifcparse/IfcUtil.h | 11 ++++---- src/ifcparse/SharedPointer.h | 41 ------------------------------ win/sln/IfcParse.vcproj | 4 --- 10 files changed, 26 insertions(+), 71 deletions(-) delete mode 100644 src/ifcparse/SharedPointer.h diff --git a/src/ifcconvert/SvgSerializer.cpp b/src/ifcconvert/SvgSerializer.cpp index 32827ec2a7..310750ee73 100644 --- a/src/ifcconvert/SvgSerializer.cpp +++ b/src/ifcconvert/SvgSerializer.cpp @@ -294,7 +294,7 @@ void SvgSerializer::finalize() { const double cx = xmin * sc; const double cy = ymin * sc; - {std::vector< SHARED_PTR >::const_iterator it; + {std::vector< boost::shared_ptr >::const_iterator it; for (it = xcoords.begin(); it != xcoords.end(); ++it) { double& v = (*it)->value(); v = v * sc - cx; diff --git a/src/ifcconvert/SvgSerializer.h b/src/ifcconvert/SvgSerializer.h index 1c553e451d..46e44f73bb 100644 --- a/src/ifcconvert/SvgSerializer.h +++ b/src/ifcconvert/SvgSerializer.h @@ -40,9 +40,9 @@ protected: boost::optional section_height; bool rescale; std::multimap paths; - std::vector< SHARED_PTR > xcoords; - std::vector< SHARED_PTR > ycoords; - std::vector< SHARED_PTR > radii; + std::vector< boost::shared_ptr > xcoords; + std::vector< boost::shared_ptr > ycoords; + std::vector< boost::shared_ptr > radii; IfcParse::IfcFile* file; public: explicit SvgSerializer(const std::string& out_filename) @@ -55,9 +55,9 @@ public: , rescale(false) , file(0) {} - virtual void addXCoordinate(const SHARED_PTR& fi) { xcoords.push_back(fi); } - virtual void addYCoordinate(const SHARED_PTR& fi) { ycoords.push_back(fi); } - virtual void addSizeComponent(const SHARED_PTR& fi) { radii.push_back(fi); } + virtual void addXCoordinate(const boost::shared_ptr& fi) { xcoords.push_back(fi); } + virtual void addYCoordinate(const boost::shared_ptr& fi) { ycoords.push_back(fi); } + virtual void addSizeComponent(const boost::shared_ptr& fi) { radii.push_back(fi); } virtual void growBoundingBox(double x, double y) { if (x < xmin) xmin = x; if (x > xmax) xmax = x; if (y < ymin) ymin = y; if (y > ymax) ymax = y; } virtual ~SvgSerializer() {} virtual void writeHeader(); diff --git a/src/ifcconvert/util.cpp b/src/ifcconvert/util.cpp index 3e6668f53b..cde3645d72 100644 --- a/src/ifcconvert/util.cpp +++ b/src/ifcconvert/util.cpp @@ -24,19 +24,19 @@ using namespace util; -SHARED_PTR string_buffer::add(const std::string& s) { - SHARED_PTR i = SHARED_PTR(new string_item(s)); +boost::shared_ptr string_buffer::add(const std::string& s) { + boost::shared_ptr i = boost::shared_ptr(new string_item(s)); items.push_back(i); return i; } -SHARED_PTR string_buffer::add(const double& d) { - SHARED_PTR i = SHARED_PTR(new float_item(d)); +boost::shared_ptr string_buffer::add(const double& d) { + boost::shared_ptr i = boost::shared_ptr(new float_item(d)); items.push_back(i); return i; } std::string string_buffer::str() const { std::stringstream ss; - for (std::vector< SHARED_PTR >::const_iterator it = items.begin(); it != items.end(); ++it) { + for (std::vector< boost::shared_ptr >::const_iterator it = items.begin(); it != items.end(); ++it) { ss << (**it).str(); } return ss.str(); diff --git a/src/ifcconvert/util.h b/src/ifcconvert/util.h index ee69f9f3b6..3a52c05973 100644 --- a/src/ifcconvert/util.h +++ b/src/ifcconvert/util.h @@ -23,7 +23,7 @@ #include #include -#include "../ifcparse/SharedPointer.h" +#include namespace util { class string_buffer { @@ -51,12 +51,12 @@ namespace util { std::string str() const { std::stringstream ss; ss << d; return ss.str(); } }; private: - std::vector< SHARED_PTR > items; + std::vector< boost::shared_ptr > items; void clear(); - void assign(const std::vector< SHARED_PTR >& other); + void assign(const std::vector< boost::shared_ptr >& other); public: - SHARED_PTR add(const std::string& s); - SHARED_PTR add(const double& d); + boost::shared_ptr add(const std::string& s); + boost::shared_ptr add(const double& d); std::string str() const; }; } diff --git a/src/ifcgeom/IfcGeomFaces.cpp b/src/ifcgeom/IfcGeomFaces.cpp index c655308b72..1e03911238 100644 --- a/src/ifcgeom/IfcGeomFaces.cpp +++ b/src/ifcgeom/IfcGeomFaces.cpp @@ -892,7 +892,7 @@ bool IfcGeom::Kernel::convert(const IfcSchema::IfcDerivedProfileDef* l, TopoDS_S #ifdef USE_IFC4 bool IfcGeom::Kernel::convert(const IfcSchema::IfcBSplineSurfaceWithKnots* l, TopoDS_Shape& face) { - SHARED_PTR< IfcTemplatedEntityListList > cps = l->ControlPointsList(); + boost::shared_ptr< IfcTemplatedEntityListList > cps = l->ControlPointsList(); std::vector uknots = l->UKnots(); std::vector vknots = l->VKnots(); std::vector umults = l->UMultiplicities(); diff --git a/src/ifcparse/IfcEntityDescriptor.h b/src/ifcparse/IfcEntityDescriptor.h index f65fb6d54e..12aa562c70 100644 --- a/src/ifcparse/IfcEntityDescriptor.h +++ b/src/ifcparse/IfcEntityDescriptor.h @@ -26,7 +26,8 @@ #include #include -#include "../ifcparse/SharedPointer.h" +#include + #include "../ifcparse/IfcUtil.h" #include "../ifcparse/IfcException.h" diff --git a/src/ifcparse/IfcParse.h b/src/ifcparse/IfcParse.h index 785e93f1f5..2733f26d83 100644 --- a/src/ifcparse/IfcParse.h +++ b/src/ifcparse/IfcParse.h @@ -37,9 +37,9 @@ #include #include +#include #include -#include "../ifcparse/SharedPointer.h" #include "../ifcparse/IfcCharacterDecoder.h" #include "../ifcparse/IfcUtil.h" diff --git a/src/ifcparse/IfcUtil.h b/src/ifcparse/IfcUtil.h index f0347cffe2..19ffead06c 100644 --- a/src/ifcparse/IfcUtil.h +++ b/src/ifcparse/IfcUtil.h @@ -26,10 +26,9 @@ #include #include +#include #include -#include "../ifcparse/SharedPointer.h" - #ifdef USE_IFC4 #include "../ifcparse/Ifc4enum.h" #else @@ -119,7 +118,7 @@ class IfcTemplatedEntityList; class IfcEntityList { std::vector ls; public: - typedef SHARED_PTR ptr; + typedef boost::shared_ptr ptr; typedef std::vector::const_iterator it; void push(IfcUtil::IfcBaseClass* l); void push(const ptr& l); @@ -143,7 +142,7 @@ template class IfcTemplatedEntityList { std::vector ls; public: - typedef SHARED_PTR< IfcTemplatedEntityList > ptr; + typedef boost::shared_ptr< IfcTemplatedEntityList > ptr; typedef typename std::vector::const_iterator it; void push(T* t) { if (t) { ls.push_back(t); } } void push(ptr t) { if (t) { for ( typename T::list::it it = t->begin(); it != t->end(); ++it ) push(*it); } } @@ -177,7 +176,7 @@ class IfcTemplatedEntityListList; class IfcEntityListList { std::vector< std::vector > ls; public: - typedef SHARED_PTR< IfcEntityListList > ptr; + typedef boost::shared_ptr< IfcEntityListList > ptr; typedef std::vector< std::vector >::const_iterator outer_it; typedef std::vector::const_iterator inner_it; void push(const std::vector& l) { @@ -231,7 +230,7 @@ template class IfcTemplatedEntityListList { std::vector< std::vector > ls; public: - typedef typename SHARED_PTR< IfcTemplatedEntityListList > ptr; + typedef typename boost::shared_ptr< IfcTemplatedEntityListList > ptr; typedef typename std::vector< std::vector >::const_iterator outer_it; typedef typename std::vector::const_iterator inner_it; void push(const std::vector& t) {ls.push_back(t);} diff --git a/src/ifcparse/SharedPointer.h b/src/ifcparse/SharedPointer.h deleted file mode 100644 index 3d261aa8c8..0000000000 --- a/src/ifcparse/SharedPointer.h +++ /dev/null @@ -1,41 +0,0 @@ -/******************************************************************************** - * * - * This file is part of IfcOpenShell. * - * * - * IfcOpenShell is free software: you can redistribute it and/or modify * - * it under the terms of the Lesser GNU General Public License as published by * - * the Free Software Foundation, either version 3.0 of the License, or * - * (at your option) any later version. * - * * - * IfcOpenShell is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * Lesser GNU General Public License for more details. * - * * - * You should have received a copy of the Lesser GNU General Public License * - * along with this program. If not, see . * - * * - ********************************************************************************/ - -/******************************************************************************** - * * - * This file defines the shared pointer implementation to use, shared pointers * - * are used extensively in IfcOpenShell * - * * - ********************************************************************************/ - -#ifdef __GNUC__ -#include -#define SHARED_PTR std::tr1::shared_ptr -#else -#if _MSC_VER >= 1600 -// MSVC 2008 does not have shared_ptr by default, but it comes -// in a feature pack. Therefore for IDEs prior to MSVC 2010 the -// shared_ptr that ships with boost is used. -#include -#define SHARED_PTR std::tr1::shared_ptr -#else -#include -#define SHARED_PTR boost::shared_ptr -#endif -#endif \ No newline at end of file diff --git a/win/sln/IfcParse.vcproj b/win/sln/IfcParse.vcproj index fa96845a7a..e36d27bd4c 100644 --- a/win/sln/IfcParse.vcproj +++ b/win/sln/IfcParse.vcproj @@ -319,10 +319,6 @@ RelativePath="..\..\src\ifcparse\IfcWrite.h" > - -