Use boost::shared_ptr

Fixes https://github.com/IfcOpenShell/IfcOpenShell/issues/17
This commit is contained in:
aothms
2016-01-25 14:42:41 +01:00
parent 9b13ed3f38
commit ed8cc620ea
10 changed files with 26 additions and 71 deletions
+1 -1
View File
@@ -294,7 +294,7 @@ void SvgSerializer::finalize() {
const double cx = xmin * sc;
const double cy = ymin * sc;
{std::vector< SHARED_PTR<util::string_buffer::float_item> >::const_iterator it;
{std::vector< boost::shared_ptr<util::string_buffer::float_item> >::const_iterator it;
for (it = xcoords.begin(); it != xcoords.end(); ++it) {
double& v = (*it)->value();
v = v * sc - cx;
+6 -6
View File
@@ -40,9 +40,9 @@ protected:
boost::optional<double> section_height;
bool rescale;
std::multimap<IfcSchema::IfcBuildingStorey*, path_object> paths;
std::vector< SHARED_PTR<util::string_buffer::float_item> > xcoords;
std::vector< SHARED_PTR<util::string_buffer::float_item> > ycoords;
std::vector< SHARED_PTR<util::string_buffer::float_item> > radii;
std::vector< boost::shared_ptr<util::string_buffer::float_item> > xcoords;
std::vector< boost::shared_ptr<util::string_buffer::float_item> > ycoords;
std::vector< boost::shared_ptr<util::string_buffer::float_item> > 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<util::string_buffer::float_item>& fi) { xcoords.push_back(fi); }
virtual void addYCoordinate(const SHARED_PTR<util::string_buffer::float_item>& fi) { ycoords.push_back(fi); }
virtual void addSizeComponent(const SHARED_PTR<util::string_buffer::float_item>& fi) { radii.push_back(fi); }
virtual void addXCoordinate(const boost::shared_ptr<util::string_buffer::float_item>& fi) { xcoords.push_back(fi); }
virtual void addYCoordinate(const boost::shared_ptr<util::string_buffer::float_item>& fi) { ycoords.push_back(fi); }
virtual void addSizeComponent(const boost::shared_ptr<util::string_buffer::float_item>& 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();
+5 -5
View File
@@ -24,19 +24,19 @@
using namespace util;
SHARED_PTR<string_buffer::string_item> string_buffer::add(const std::string& s) {
SHARED_PTR<string_item> i = SHARED_PTR<string_item>(new string_item(s));
boost::shared_ptr<string_buffer::string_item> string_buffer::add(const std::string& s) {
boost::shared_ptr<string_item> i = boost::shared_ptr<string_item>(new string_item(s));
items.push_back(i);
return i;
}
SHARED_PTR<string_buffer::float_item> string_buffer::add(const double& d) {
SHARED_PTR<float_item> i = SHARED_PTR<float_item>(new float_item(d));
boost::shared_ptr<string_buffer::float_item> string_buffer::add(const double& d) {
boost::shared_ptr<float_item> i = boost::shared_ptr<float_item>(new float_item(d));
items.push_back(i);
return i;
}
std::string string_buffer::str() const {
std::stringstream ss;
for (std::vector< SHARED_PTR<item> >::const_iterator it = items.begin(); it != items.end(); ++it) {
for (std::vector< boost::shared_ptr<item> >::const_iterator it = items.begin(); it != items.end(); ++it) {
ss << (**it).str();
}
return ss.str();
+5 -5
View File
@@ -23,7 +23,7 @@
#include <sstream>
#include <vector>
#include "../ifcparse/SharedPointer.h"
#include <boost/shared_ptr.hpp>
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<item> > items;
std::vector< boost::shared_ptr<item> > items;
void clear();
void assign(const std::vector< SHARED_PTR<item> >& other);
void assign(const std::vector< boost::shared_ptr<item> >& other);
public:
SHARED_PTR<string_item> add(const std::string& s);
SHARED_PTR<float_item> add(const double& d);
boost::shared_ptr<string_item> add(const std::string& s);
boost::shared_ptr<float_item> add(const double& d);
std::string str() const;
};
}
+1 -1
View File
@@ -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<IfcSchema::IfcCartesianPoint> > cps = l->ControlPointsList();
boost::shared_ptr< IfcTemplatedEntityListList<IfcSchema::IfcCartesianPoint> > cps = l->ControlPointsList();
std::vector<double> uknots = l->UKnots();
std::vector<double> vknots = l->VKnots();
std::vector<int> umults = l->UMultiplicities();
+2 -1
View File
@@ -26,7 +26,8 @@
#include <iostream>
#include <algorithm>
#include "../ifcparse/SharedPointer.h"
#include <boost/shared_ptr.hpp>
#include "../ifcparse/IfcUtil.h"
#include "../ifcparse/IfcException.h"
+1 -1
View File
@@ -37,9 +37,9 @@
#include <cstring>
#include <map>
#include <boost/shared_ptr.hpp>
#include <boost/dynamic_bitset.hpp>
#include "../ifcparse/SharedPointer.h"
#include "../ifcparse/IfcCharacterDecoder.h"
#include "../ifcparse/IfcUtil.h"
+5 -6
View File
@@ -26,10 +26,9 @@
#include <sstream>
#include <algorithm>
#include <boost/shared_ptr.hpp>
#include <boost/dynamic_bitset.hpp>
#include "../ifcparse/SharedPointer.h"
#ifdef USE_IFC4
#include "../ifcparse/Ifc4enum.h"
#else
@@ -119,7 +118,7 @@ class IfcTemplatedEntityList;
class IfcEntityList {
std::vector<IfcUtil::IfcBaseClass*> ls;
public:
typedef SHARED_PTR<IfcEntityList> ptr;
typedef boost::shared_ptr<IfcEntityList> ptr;
typedef std::vector<IfcUtil::IfcBaseClass*>::const_iterator it;
void push(IfcUtil::IfcBaseClass* l);
void push(const ptr& l);
@@ -143,7 +142,7 @@ template <class T>
class IfcTemplatedEntityList {
std::vector<T*> ls;
public:
typedef SHARED_PTR< IfcTemplatedEntityList<T> > ptr;
typedef boost::shared_ptr< IfcTemplatedEntityList<T> > ptr;
typedef typename std::vector<T*>::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<IfcUtil::IfcBaseClass*> > ls;
public:
typedef SHARED_PTR< IfcEntityListList > ptr;
typedef boost::shared_ptr< IfcEntityListList > ptr;
typedef std::vector< std::vector<IfcUtil::IfcBaseClass*> >::const_iterator outer_it;
typedef std::vector<IfcUtil::IfcBaseClass*>::const_iterator inner_it;
void push(const std::vector<IfcUtil::IfcBaseClass*>& l) {
@@ -231,7 +230,7 @@ template <class T>
class IfcTemplatedEntityListList {
std::vector< std::vector<T*> > ls;
public:
typedef typename SHARED_PTR< IfcTemplatedEntityListList<T> > ptr;
typedef typename boost::shared_ptr< IfcTemplatedEntityListList<T> > ptr;
typedef typename std::vector< std::vector<T*> >::const_iterator outer_it;
typedef typename std::vector<T*>::const_iterator inner_it;
void push(const std::vector<T*>& t) {ls.push_back(t);}
-41
View File
@@ -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 <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
/********************************************************************************
* *
* This file defines the shared pointer implementation to use, shared pointers *
* are used extensively in IfcOpenShell *
* *
********************************************************************************/
#ifdef __GNUC__
#include <tr1/memory>
#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 <memory>
#define SHARED_PTR std::tr1::shared_ptr
#else
#include <boost/shared_ptr.hpp>
#define SHARED_PTR boost::shared_ptr
#endif
#endif
-4
View File
@@ -319,10 +319,6 @@
RelativePath="..\..\src\ifcparse\IfcWrite.h"
>
</File>
<File
RelativePath="..\..\src\ifcparse\SharedPointer.h"
>
</File>
</Filter>
</Files>
<Globals>