Skip to content

Commit

Permalink
replaced boost smart pointers with c++11 smart pointers
Browse files Browse the repository at this point in the history
  • Loading branch information
mensinda committed Apr 5, 2016
1 parent cff5b0d commit 5dacda0
Show file tree
Hide file tree
Showing 95 changed files with 709 additions and 712 deletions.
4 changes: 2 additions & 2 deletions code/3DSConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../include/assimp/scene.h"
#include "../include/assimp/DefaultLogger.hpp"
#include "StringComparison.h"
#include <boost/scoped_array.hpp>
#include <memory>
#include <cctype>

using namespace Assimp;
Expand Down Expand Up @@ -359,7 +359,7 @@ void Discreet3DSImporter::ConvertMeshes(aiScene* pcOut)

// we need to split all meshes by their materials
for (std::vector<D3DS::Mesh>::iterator i = mScene->mMeshes.begin(); i != mScene->mMeshes.end();++i) {
boost::scoped_array< std::vector<unsigned int> > aiSplit(new std::vector<unsigned int>[mScene->mMaterials.size()]);
std::unique_ptr< std::vector<unsigned int>[] > aiSplit(new std::vector<unsigned int>[mScene->mMaterials.size()]);

name.length = ASSIMP_itoa10(name.data,num++);

Expand Down
4 changes: 2 additions & 2 deletions code/3DSExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ namespace {
// Worker function for exporting a scene to 3DS. Prototyped and registered in Exporter.cpp
void ExportScene3DS(const char* pFile, IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties)
{
boost::shared_ptr<IOStream> outfile (pIOSystem->Open(pFile, "wb"));
std::shared_ptr<IOStream> outfile (pIOSystem->Open(pFile, "wb"));
if(!outfile) {
throw DeadlyExportError("Could not open output .3ds file: " + std::string(pFile));
}
Expand Down Expand Up @@ -181,7 +181,7 @@ void ExportScene3DS(const char* pFile, IOSystem* pIOSystem, const aiScene* pScen
} // end of namespace Assimp

// ------------------------------------------------------------------------------------------------
Discreet3DSExporter:: Discreet3DSExporter(boost::shared_ptr<IOStream> outfile, const aiScene* scene)
Discreet3DSExporter:: Discreet3DSExporter(std::shared_ptr<IOStream> outfile, const aiScene* scene)
: scene(scene)
, writer(outfile)
{
Expand Down
4 changes: 2 additions & 2 deletions code/3DSExporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define AI_3DSEXPORTER_H_INC

#include <map>
#include <boost/shared_ptr.hpp>
#include <memory>

#include "StreamWriter.h"
#include "./../include/assimp/material.h"
Expand All @@ -64,7 +64,7 @@ namespace Assimp
class Discreet3DSExporter
{
public:
Discreet3DSExporter(boost::shared_ptr<IOStream> outfile, const aiScene* pScene);
Discreet3DSExporter(std::shared_ptr<IOStream> outfile, const aiScene* pScene);

private:

Expand Down
6 changes: 3 additions & 3 deletions code/ACLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../include/assimp/scene.h"
#include "../include/assimp/config.h"
#include "../include/assimp/IOSystem.hpp"
#include <boost/scoped_ptr.hpp>
#include <memory>

using namespace Assimp;

Expand Down Expand Up @@ -708,7 +708,7 @@ aiNode* AC3DImporter::ConvertObjectSection(Object& object,
// collect all meshes using the same material group.
if (object.subDiv) {
if (configEvalSubdivision) {
boost::scoped_ptr<Subdivider> div(Subdivider::Create(Subdivider::CATMULL_CLARKE));
std::unique_ptr<Subdivider> div(Subdivider::Create(Subdivider::CATMULL_CLARKE));
DefaultLogger::get()->info("AC3D: Evaluating subdivision surface: "+object.name);

std::vector<aiMesh*> cpy(meshes.size()-oldm,NULL);
Expand Down Expand Up @@ -787,7 +787,7 @@ void AC3DImporter::SetupProperties(const Importer* pImp)
void AC3DImporter::InternReadFile( const std::string& pFile,
aiScene* pScene, IOSystem* pIOHandler)
{
boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile, "rb"));
std::unique_ptr<IOStream> file( pIOHandler->Open( pFile, "rb"));

// Check whether we can read from the file
if( file.get() == NULL)
Expand Down
4 changes: 2 additions & 2 deletions code/ASELoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "SkeletonMeshBuilder.h"
#include "TargetAnimation.h"
#include "../include/assimp/Importer.hpp"
#include <boost/scoped_ptr.hpp>
#include <memory>
#include "../include/assimp/IOSystem.hpp"
#include "../include/assimp/DefaultLogger.hpp"
#include "../include/assimp/scene.h"
Expand Down Expand Up @@ -130,7 +130,7 @@ void ASEImporter::SetupProperties(const Importer* pImp)
void ASEImporter::InternReadFile( const std::string& pFile,
aiScene* pScene, IOSystem* pIOHandler)
{
boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile, "rb"));
std::unique_ptr<IOStream> file( pIOHandler->Open( pFile, "rb"));

// Check whether we can read from the file
if( file.get() == NULL) {
Expand Down
44 changes: 22 additions & 22 deletions code/B3DImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Copyright (c) 2006-2016, assimp team
All rights reserved.
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
Redistribution and use of this software in source and binary forms,
with or without modification, are permitted provided that the following
conditions are met:
* Redistributions of source code must retain the above
Expand All @@ -25,16 +25,16 @@ conditions are met:
derived from this software without specific prior
written permission of the assimp team.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
---------------------------------------------------------------------------
*/
Expand All @@ -51,7 +51,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "TextureTransform.h"
#include "ConvertToLHProcess.h"
#include "StringUtils.h"
#include <boost/scoped_ptr.hpp>
#include <memory>
#include "../include/assimp/IOSystem.hpp"
#include "../include/assimp/anim.h"
#include "../include/assimp/scene.h"
Expand All @@ -71,11 +71,11 @@ static const aiImporterDesc desc = {
0,
0,
0,
"b3d"
"b3d"
};

// (fixme, Aramis) quick workaround to get rid of all those signed to unsigned warnings
#ifdef _MSC_VER
#ifdef _MSC_VER
# pragma warning (disable: 4018)
#endif

Expand Down Expand Up @@ -114,7 +114,7 @@ void B3DImporter::InternReadFile( const std::string& pFile, aiScene* pScene, IOS
cout<<"Hello world from the B3DImporter!"<<endl;
#endif

boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile));
std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));

// Check whether we can read from the file
if( file.get() == NULL)
Expand Down Expand Up @@ -280,12 +280,12 @@ void B3DImporter::ReadBRUS(){

aiMaterial *mat=new aiMaterial;
_materials.push_back( mat );

// Name
aiString ainame( name );
mat->AddProperty( &ainame,AI_MATKEY_NAME );
// Diffuse color

// Diffuse color
mat->AddProperty( &color,1,AI_MATKEY_COLOR_DIFFUSE );

// Opacity
Expand All @@ -294,16 +294,16 @@ void B3DImporter::ReadBRUS(){
// Specular color
aiColor3D speccolor( shiny,shiny,shiny );
mat->AddProperty( &speccolor,1,AI_MATKEY_COLOR_SPECULAR );

// Specular power
float specpow=shiny*128;
mat->AddProperty( &specpow,1,AI_MATKEY_SHININESS );

// Double sided
if( fx & 0x10 ){
int i=1;
int i=1;
mat->AddProperty( &i,1,AI_MATKEY_TWOSIDED );
}
}

//Textures
for( int i=0;i<n_texs;++i ){
Expand Down Expand Up @@ -569,7 +569,7 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
string t=ReadChunk();
if( t=="BB3D" ){
int version=ReadInt();

if (!DefaultLogger::isNullLogger()) {
char dmp[128];
ai_snprintf(dmp, 128, "B3D file format version: %i",version);
Expand Down Expand Up @@ -669,7 +669,7 @@ void B3DImporter::ReadBB3D( aiScene *scene ){
}
scene->mNumMaterials=_materials.size();
scene->mMaterials=to_array( _materials );

//meshes
scene->mNumMeshes=_meshes.size();
scene->mMeshes=to_array( _meshes );
Expand Down
4 changes: 2 additions & 2 deletions code/BVHLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "fast_atof.h"
#include "SkeletonMeshBuilder.h"
#include "../include/assimp/Importer.hpp"
#include <boost/scoped_ptr.hpp>
#include <memory>
#include <boost/format.hpp>
#include "../include/assimp/IOSystem.hpp"
#include "../include/assimp/scene.h"
Expand Down Expand Up @@ -118,7 +118,7 @@ void BVHLoader::InternReadFile( const std::string& pFile, aiScene* pScene, IOSys
mFileName = pFile;

// read file into memory
boost::scoped_ptr<IOStream> file( pIOHandler->Open( pFile));
std::unique_ptr<IOStream> file( pIOHandler->Open( pFile));
if( file.get() == NULL)
throw DeadlyImportError( "Failed to open file " + pFile + ".");

Expand Down
9 changes: 4 additions & 5 deletions code/BaseImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "../include/assimp/postprocess.h"
#include <ios>
#include <list>
#include <boost/scoped_ptr.hpp>
#include <boost/scoped_array.hpp>
#include <memory>
#include <sstream>
#include <cctype>

Expand Down Expand Up @@ -149,10 +148,10 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions)
if (!pIOHandler)
return false;

boost::scoped_ptr<IOStream> pStream (pIOHandler->Open(pFile));
std::unique_ptr<IOStream> pStream (pIOHandler->Open(pFile));
if (pStream.get() ) {
// read 200 characters from the file
boost::scoped_array<char> _buffer (new char[searchBytes+1 /* for the '\0' */]);
std::unique_ptr<char[]> _buffer (new char[searchBytes+1 /* for the '\0' */]);
char* buffer = _buffer.get();
if( NULL == buffer ) {
return false;
Expand Down Expand Up @@ -256,7 +255,7 @@ void BaseImporter::GetExtensionList(std::set<std::string>& extensions)
const uint32_t* magic_u32;
};
magic = reinterpret_cast<const char*>(_magic);
boost::scoped_ptr<IOStream> pStream (pIOHandler->Open(pFile));
std::unique_ptr<IOStream> pStream (pIOHandler->Open(pFile));
if (pStream.get() ) {

// skip to offset
Expand Down
6 changes: 3 additions & 3 deletions code/BlenderDNA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,17 +268,17 @@ void DNA :: DumpToFile()
}

// ------------------------------------------------------------------------------------------------
boost::shared_ptr< ElemBase > DNA :: ConvertBlobToStructure(
std::shared_ptr< ElemBase > DNA :: ConvertBlobToStructure(
const Structure& structure,
const FileDatabase& db
) const
{
std::map<std::string, FactoryPair >::const_iterator it = converters.find(structure.name);
if (it == converters.end()) {
return boost::shared_ptr< ElemBase >();
return std::shared_ptr< ElemBase >();
}

boost::shared_ptr< ElemBase > ret = (structure.*((*it).second.first))();
std::shared_ptr< ElemBase > ret = (structure.*((*it).second.first))();
(structure.*((*it).second.second))(ret,db);

return ret;
Expand Down
Loading

0 comments on commit 5dacda0

Please sign in to comment.