Replaced std::auto_ptr<> usage as it's deprecated in C++11 and will be removed in C++17

This commit is contained in:
Robert Osfield 2018-05-05 12:28:45 +01:00
parent a15d4532fa
commit f49e1d32c9
10 changed files with 30 additions and 16 deletions

View File

@ -554,7 +554,7 @@ class OSGDB_EXPORT Registry : public osg::Referenced
public: public:
/** Functor used in internal implementations.*/ /** Functor used in internal implementations.*/
struct ReadFunctor struct ReadFunctor : public osg::Referenced
{ {
ReadFunctor(const std::string& filename, const Options* options): ReadFunctor(const std::string& filename, const Options* options):
_filename(filename), _filename(filename),

View File

@ -1168,7 +1168,7 @@ ReaderWriter::ReadResult Registry::read(const ReadFunctor& readFunctor)
options->setDatabasePath(archiveName); options->setDatabasePath(archiveName);
std::auto_ptr<ReadFunctor> rf(readFunctor.cloneType(fileName, options.get())); osg::ref_ptr<ReadFunctor> rf(readFunctor.cloneType(fileName, options.get()));
result = rf->doRead(*archive); result = rf->doRead(*archive);

View File

@ -184,10 +184,10 @@ private:
typedef std::vector< osg::ref_ptr<osg::StateSet> > StateSetStack; typedef std::vector< osg::ref_ptr<osg::StateSet> > StateSetStack;
StateSetStack _stateSetStack; StateSetStack _stateSetStack;
std::auto_ptr<MaterialPaletteManager> _materialPalette; osg::ref_ptr<MaterialPaletteManager> _materialPalette;
std::auto_ptr<TexturePaletteManager> _texturePalette; osg::ref_ptr<TexturePaletteManager> _texturePalette;
std::auto_ptr<LightSourcePaletteManager> _lightSourcePalette; osg::ref_ptr<LightSourcePaletteManager> _lightSourcePalette;
std::auto_ptr<VertexPaletteManager> _vertexPalette; osg::ref_ptr<VertexPaletteManager> _vertexPalette;
// Used to avoid duplicate Header/Group records at top of output FLT file. // Used to avoid duplicate Header/Group records at top of output FLT file.
bool _firstNode; bool _firstNode;

View File

@ -33,7 +33,7 @@ namespace flt
class DataOutputStream; class DataOutputStream;
class LightSourcePaletteManager class LightSourcePaletteManager : public osg::Referenced
{ {
public: public:
LightSourcePaletteManager(); LightSourcePaletteManager();

View File

@ -32,7 +32,7 @@ namespace flt
class DataOutputStream; class DataOutputStream;
class MaterialPaletteManager class MaterialPaletteManager : public osg::Referenced
{ {
public: public:
MaterialPaletteManager( ExportOptions& fltOpt ); MaterialPaletteManager( ExportOptions& fltOpt );
@ -45,6 +45,9 @@ class MaterialPaletteManager
private: private:
virtual ~MaterialPaletteManager() {}
int _currIndex; int _currIndex;
// Helper struct to hold material palette records // Helper struct to hold material palette records

View File

@ -35,7 +35,7 @@ class DataOutputStream;
class FltExportVisitor; class FltExportVisitor;
class TexturePaletteManager class TexturePaletteManager : public osg::Referenced
{ {
public: public:
TexturePaletteManager( const FltExportVisitor& nv, const ExportOptions& fltOpt ); TexturePaletteManager( const FltExportVisitor& nv, const ExportOptions& fltOpt );

View File

@ -40,11 +40,10 @@ namespace flt
file and copies it to FltExportVisitor::_dos after the scene graph file and copies it to FltExportVisitor::_dos after the scene graph
has been completely walked. has been completely walked.
*/ */
class VertexPaletteManager class VertexPaletteManager : public osg::Referenced
{ {
public: public:
VertexPaletteManager( const ExportOptions& fltOpt ); VertexPaletteManager( const ExportOptions& fltOpt );
~VertexPaletteManager();
void add( const osg::Geometry& geom ); void add( const osg::Geometry& geom );
void add( const osg::Array* key, void add( const osg::Array* key,
@ -66,6 +65,8 @@ public:
static osg::ref_ptr< const osg::Vec4Array > asVec4Array( const osg::Array* in, const unsigned int n ); static osg::ref_ptr< const osg::Vec4Array > asVec4Array( const osg::Array* in, const unsigned int n );
protected: protected:
virtual ~VertexPaletteManager();
typedef enum { typedef enum {
VERTEX_C, VERTEX_C,
VERTEX_CN, VERTEX_CN,

View File

@ -9,6 +9,10 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
STRING(REGEX REPLACE "-Wextra" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") STRING(REGEX REPLACE "-Wextra" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
ENDIF() ENDIF()
IF(CMAKE_COMPILER_IS_GNUCXX OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
ENDIF()
SET(TARGET_SRC SET(TARGET_SRC
daeReader.cpp daeReader.cpp

View File

@ -32,6 +32,11 @@
#define SERIALIZER() OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex) #define SERIALIZER() OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> lock(_serializerMutex)
#if __cplusplus > 199711L
#define smart_ptr std::unique_ptr
#else
#define smart_prt std::auto_ptr
#endif
osgDB::ReaderWriter::ReadResult osgDB::ReaderWriter::ReadResult
ReaderWriterDAE::readNode(std::istream& fin, ReaderWriterDAE::readNode(std::istream& fin,
@ -73,7 +78,7 @@ ReaderWriterDAE::readNode(std::istream& fin,
#endif #endif
} }
std::auto_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit smart_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit
osgDAE::daeReader daeReader(pDAE, &pluginOptions); osgDAE::daeReader daeReader(pDAE, &pluginOptions);
@ -150,7 +155,8 @@ ReaderWriterDAE::readNode(const std::string& fname,
pDAE = new DAE; pDAE = new DAE;
#endif #endif
} }
std::auto_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit
smart_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit
osgDAE::daeReader daeReader(pDAE, &pluginOptions); osgDAE::daeReader daeReader(pDAE, &pluginOptions);
@ -247,7 +253,7 @@ ReaderWriterDAE::writeNode( const osg::Node& node,
pDAE = new DAE; pDAE = new DAE;
#endif #endif
} }
std::auto_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit smart_ptr<DAE> scopedDae(bOwnDAE ? pDAE : NULL); // Deallocates locally created structure at scope exit
// Convert file name to URI // Convert file name to URI
std::string fileURI = ConvertFilePathToColladaCompatibleURI(fname); std::string fileURI = ConvertFilePathToColladaCompatibleURI(fname);

View File

@ -113,7 +113,7 @@ public:
virtual WriteResult writeNode(const osg::Node& node, const std::string& fileName, const Options* = NULL) const; virtual WriteResult writeNode(const osg::Node& node, const std::string& fileName, const Options* = NULL) const;
private: private:
class ReaderObject class ReaderObject : public osg::Referenced
{ {
public: public:
ReaderObject(bool noTriStripPolygons, bool generateNormals = true): ReaderObject(bool noTriStripPolygons, bool generateNormals = true):
@ -526,7 +526,7 @@ osgDB::ReaderWriter::ReadResult ReaderWriterSTL::readNode(const std::string& fil
else else
readerObject = new AsciiReaderObject(localOptions.noTriStripPolygons); readerObject = new AsciiReaderObject(localOptions.noTriStripPolygons);
std::auto_ptr<ReaderObject> readerPtr(readerObject); osg::ref_ptr<ReaderObject> readerPtr(readerObject);
while (1) while (1)
{ {