Switch to std::shared_ptr and std::weak_ptr.
This was SVN commit r16227.
This commit is contained in:
parent
0843100d11
commit
4c1903500b
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2009 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -20,12 +20,11 @@
|
||||
|
||||
#include "lib/file/vfs/vfs_path.h"
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <memory>
|
||||
|
||||
class CModelDef;
|
||||
typedef boost::shared_ptr<CModelDef> CModelDefPtr;
|
||||
typedef std::shared_ptr<CModelDef> CModelDefPtr;
|
||||
|
||||
class CColladaManager;
|
||||
|
||||
@ -39,7 +38,7 @@ public:
|
||||
CModelDefPtr GetMesh(const VfsPath& pathname);
|
||||
|
||||
private:
|
||||
typedef boost::unordered_map<VfsPath, boost::weak_ptr<CModelDef> > mesh_map;
|
||||
typedef boost::unordered_map<VfsPath, std::weak_ptr<CModelDef> > mesh_map;
|
||||
mesh_map m_MeshMap;
|
||||
CColladaManager& m_ColladaManager;
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -575,9 +575,9 @@ Status CShaderManager::ReloadChangedFile(const VfsPath& path)
|
||||
if (files != m_HotloadFiles.end())
|
||||
{
|
||||
// Reload all shaders using this file
|
||||
for (std::set<boost::weak_ptr<CShaderProgram> >::iterator it = files->second.begin(); it != files->second.end(); ++it)
|
||||
for (std::set<std::weak_ptr<CShaderProgram> >::iterator it = files->second.begin(); it != files->second.end(); ++it)
|
||||
{
|
||||
if (shared_ptr<CShaderProgram> program = it->lock())
|
||||
if (std::shared_ptr<CShaderProgram> program = it->lock())
|
||||
program->Reload();
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2012 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -21,7 +21,8 @@
|
||||
#define USE_SHADER_XML_VALIDATION 1
|
||||
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
|
||||
#include "graphics/ShaderDefines.h"
|
||||
#include "graphics/ShaderProgram.h"
|
||||
@ -31,7 +32,6 @@
|
||||
# include "ps/XML/RelaxNG.h"
|
||||
#endif
|
||||
|
||||
#include <set>
|
||||
|
||||
/**
|
||||
* Shader manager: loads and caches shader programs.
|
||||
@ -118,7 +118,7 @@ private:
|
||||
EffectCacheMap m_EffectCache;
|
||||
|
||||
// Store the set of shaders that need to be reloaded when the given file is modified
|
||||
typedef boost::unordered_map<VfsPath, std::set<boost::weak_ptr<CShaderProgram> > > HotloadFilesMap;
|
||||
typedef boost::unordered_map<VfsPath, std::set<std::weak_ptr<CShaderProgram>, std::owner_less<std::weak_ptr<CShaderProgram>>>> HotloadFilesMap;
|
||||
HotloadFilesMap m_HotloadFiles;
|
||||
|
||||
#if USE_SHADER_XML_VALIDATION
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2014 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -23,6 +23,6 @@
|
||||
* in the whole of ShaderProgram.h
|
||||
*/
|
||||
class CShaderProgram;
|
||||
typedef shared_ptr<CShaderProgram> CShaderProgramPtr;
|
||||
typedef std::shared_ptr<CShaderProgram> CShaderProgramPtr;
|
||||
|
||||
#endif // INCLUDED_SHADERPROGRAMPTR
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2012 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -27,9 +27,10 @@
|
||||
#ifndef INCLUDED_TERRAINPROPERTIES
|
||||
#define INCLUDED_TERRAINPROPERTIES
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "ps/CStr.h"
|
||||
#include "lib/file/vfs/vfs_path.h"
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
class CTerrainGroup;
|
||||
class XMBElement;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2010 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -18,9 +18,9 @@
|
||||
#ifndef INCLUDED_TERRAINTEXTUREMANAGER
|
||||
#define INCLUDED_TERRAINTEXTUREMANAGER
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "lib/res/graphics/ogl_tex.h"
|
||||
#include "lib/res/handle.h"
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2010 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -20,6 +20,6 @@
|
||||
|
||||
// Forward-declare for CTextureManager handles
|
||||
class CTexture;
|
||||
typedef shared_ptr<CTexture> CTexturePtr;
|
||||
typedef std::shared_ptr<CTexture> CTexturePtr;
|
||||
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -19,6 +19,11 @@
|
||||
|
||||
#include "TextureManager.h"
|
||||
|
||||
#include <boost/functional/hash.hpp>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/unordered_set.hpp>
|
||||
#include <iomanip>
|
||||
|
||||
#include "graphics/TextureConverter.h"
|
||||
#include "lib/allocators/shared_ptr.h"
|
||||
#include "lib/res/h_mgr.h"
|
||||
@ -31,11 +36,6 @@
|
||||
#include "ps/Filesystem.h"
|
||||
#include "ps/Profile.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include <boost/unordered_map.hpp>
|
||||
#include <boost/unordered_set.hpp>
|
||||
#include <boost/functional/hash.hpp>
|
||||
|
||||
struct TPhash
|
||||
: std::unary_function<CTextureProperties, std::size_t>,
|
||||
std::unary_function<CTexturePtr, std::size_t>
|
||||
@ -469,9 +469,9 @@ public:
|
||||
if (files != m_HotloadFiles.end())
|
||||
{
|
||||
// Flag all textures using this file as needing reloading
|
||||
for (std::set<boost::weak_ptr<CTexture> >::iterator it = files->second.begin(); it != files->second.end(); ++it)
|
||||
for (std::set<std::weak_ptr<CTexture> >::iterator it = files->second.begin(); it != files->second.end(); ++it)
|
||||
{
|
||||
if (shared_ptr<CTexture> texture = it->lock())
|
||||
if (std::shared_ptr<CTexture> texture = it->lock())
|
||||
{
|
||||
texture->m_State = CTexture::UNLOADED;
|
||||
texture->SetHandle(m_DefaultHandle);
|
||||
@ -507,7 +507,7 @@ private:
|
||||
|
||||
// Store the set of textures that need to be reloaded when the given file
|
||||
// (a source file or settings.xml) is modified
|
||||
typedef boost::unordered_map<VfsPath, std::set<boost::weak_ptr<CTexture> > > HotloadFilesMap;
|
||||
typedef boost::unordered_map<VfsPath, std::set<std::weak_ptr<CTexture>, std::owner_less<std::weak_ptr<CTexture>>>> HotloadFilesMap;
|
||||
HotloadFilesMap m_HotloadFiles;
|
||||
|
||||
// Cache for the conversion settings files
|
||||
@ -552,7 +552,7 @@ bool CTexture::TryLoad()
|
||||
// If we have already tried prefetch loading, and it failed, bump the conversion request to HIGH priority.
|
||||
if (m_State == UNLOADED || m_State == PREFETCH_NEEDS_LOADING || m_State == PREFETCH_NEEDS_CONVERTING)
|
||||
{
|
||||
if (shared_ptr<CTexture> self = m_Self.lock())
|
||||
if (std::shared_ptr<CTexture> self = m_Self.lock())
|
||||
{
|
||||
if (m_State != PREFETCH_NEEDS_CONVERTING && m_TextureManager->TryLoadingCached(self))
|
||||
m_State = LOADED;
|
||||
@ -568,7 +568,7 @@ void CTexture::Prefetch()
|
||||
{
|
||||
if (m_State == UNLOADED)
|
||||
{
|
||||
if (shared_ptr<CTexture> self = m_Self.lock())
|
||||
if (std::shared_ptr<CTexture> self = m_Self.lock())
|
||||
{
|
||||
m_State = PREFETCH_NEEDS_LOADING;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -20,12 +20,12 @@
|
||||
|
||||
#include "Texture.h"
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "lib/ogl.h"
|
||||
#include "lib/file/vfs/vfs.h"
|
||||
#include "lib/res/handle.h"
|
||||
|
||||
#include <boost/weak_ptr.hpp>
|
||||
|
||||
class CTextureProperties;
|
||||
class CTextureManagerImpl;
|
||||
|
||||
@ -303,7 +303,7 @@ private:
|
||||
|
||||
// Self-reference to let us recover the CTexturePtr for this object.
|
||||
// (weak pointer to avoid cycles)
|
||||
boost::weak_ptr<CTexture> m_Self;
|
||||
std::weak_ptr<CTexture> m_Self;
|
||||
};
|
||||
|
||||
#endif // INCLUDED_TEXTUREMANAGER
|
||||
|
@ -35,21 +35,4 @@
|
||||
#include <boost/filesystem.hpp>
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
// (these ones are used more rarely, so we don't enable them in minimal configurations)
|
||||
#if !MINIMAL_PCH
|
||||
#include <boost/array.hpp>
|
||||
using boost::array;
|
||||
|
||||
#include <boost/mem_fn.hpp>
|
||||
using boost::mem_fn;
|
||||
|
||||
#include <boost/function.hpp>
|
||||
using boost::function;
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
using boost::bind;
|
||||
#endif // !MINIMAL_PCH
|
||||
|
||||
#endif // #ifndef INCLUDED_PCH_BOOST
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2010 Wildfire Games
|
||||
/* Copyright (c) 2015 Wildfire Games
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -74,13 +74,12 @@ double __cdecl abs(double x); // not declared by mathimf
|
||||
|
||||
#if CONFIG_ENABLE_BOOST
|
||||
# include "lib/pch/pch_boost.h"
|
||||
using boost::shared_ptr;
|
||||
#else
|
||||
# include <array>
|
||||
# include <memory>
|
||||
using std::shared_ptr;
|
||||
#endif
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
using std::shared_ptr;
|
||||
|
||||
// (must come after boost and common lib headers, but before re-enabling
|
||||
// warnings to avoid boost spew)
|
||||
#include "lib/posix/posix.h"
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2010 Wildfire Games
|
||||
/* Copyright (c) 2015 Wildfire Games
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
@ -657,7 +657,7 @@ u32 Tex::get_average_colour() const
|
||||
Tex basetex = *this;
|
||||
uint8_t *data = new uint8_t[last_level_size];
|
||||
memcpy(data, m_Data.get() + m_Ofs + size - last_level_size, last_level_size);
|
||||
boost::shared_ptr<uint8_t> sdata(data, ArrayDeleter());
|
||||
shared_ptr<uint8_t> sdata(data, ArrayDeleter());
|
||||
basetex.wrap(1, 1, m_Bpp, m_Flags, sdata, 0);
|
||||
|
||||
// convert to BGRA
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2014 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -20,9 +20,9 @@
|
||||
#include "glooxwrapper.h"
|
||||
|
||||
#include <gloox/connectionlistener.h>
|
||||
#include <gloox/messagehandler.h>
|
||||
#include <gloox/error.h>
|
||||
#include <gloox/glooxversion.h>
|
||||
#include <gloox/messagehandler.h>
|
||||
|
||||
#if OS_WIN
|
||||
const std::string gloox::EmptyString = "";
|
||||
@ -355,21 +355,21 @@ void glooxwrapper::Client::registerConnectionListener(glooxwrapper::ConnectionLi
|
||||
{
|
||||
gloox::ConnectionListener* listener = new ConnectionListenerWrapper(hnd);
|
||||
m_Wrapped->registerConnectionListener(listener);
|
||||
m_Impl->m_ConnectionListeners.push_back(boost::shared_ptr<gloox::ConnectionListener>(listener));
|
||||
m_Impl->m_ConnectionListeners.push_back(shared_ptr<gloox::ConnectionListener>(listener));
|
||||
}
|
||||
|
||||
void glooxwrapper::Client::registerMessageHandler(glooxwrapper::MessageHandler* hnd)
|
||||
{
|
||||
gloox::MessageHandler* handler = new MessageHandlerWrapper(hnd);
|
||||
m_Wrapped->registerMessageHandler(handler);
|
||||
m_Impl->m_MessageHandlers.push_back(boost::shared_ptr<gloox::MessageHandler>(handler));
|
||||
m_Impl->m_MessageHandlers.push_back(shared_ptr<gloox::MessageHandler>(handler));
|
||||
}
|
||||
|
||||
void glooxwrapper::Client::registerIqHandler(glooxwrapper::IqHandler* ih, int exttype)
|
||||
{
|
||||
gloox::IqHandler* handler = new IqHandlerWrapper(ih);
|
||||
m_Wrapped->registerIqHandler(handler, exttype);
|
||||
m_Impl->m_IqHandlers.push_back(boost::shared_ptr<gloox::IqHandler>(handler));
|
||||
m_Impl->m_IqHandlers.push_back(shared_ptr<gloox::IqHandler>(handler));
|
||||
}
|
||||
|
||||
bool glooxwrapper::Client::removePresenceExtension(int type)
|
||||
@ -615,7 +615,7 @@ void glooxwrapper::Registration::registerRegistrationHandler(RegistrationHandler
|
||||
{
|
||||
gloox::RegistrationHandler* handler = new RegistrationHandlerWrapper(rh);
|
||||
m_Wrapped->registerRegistrationHandler(handler);
|
||||
m_RegistrationHandlers.push_back(boost::shared_ptr<gloox::RegistrationHandler>(handler));
|
||||
m_RegistrationHandlers.push_back(shared_ptr<gloox::RegistrationHandler>(handler));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2009 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -27,7 +27,5 @@
|
||||
// .. CStr is included very frequently, so a reasonable amount of time is
|
||||
// saved by including it here. (~10% in a full rebuild, as of r2365)
|
||||
#include "ps/CStr.h"
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/weak_ptr.hpp>
|
||||
|
||||
#endif // HAVE_PCH
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2009 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -20,5 +20,3 @@
|
||||
|
||||
// Minimal is a bit *too* minimal to let things compile, so include a few more headers
|
||||
#include "lib/debug.h"
|
||||
#include <boost/shared_ptr.hpp>
|
||||
using boost::shared_ptr;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2013 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -27,14 +27,12 @@
|
||||
#include <deque>
|
||||
#include <map>
|
||||
|
||||
#include "lib/input.h"
|
||||
#include "graphics/ShaderProgramPtr.h"
|
||||
#include "lib/file/vfs/vfs_path.h"
|
||||
#include "lib/input.h"
|
||||
#include "ps/CStr.h"
|
||||
#include "ps/ThreadUtil.h"
|
||||
|
||||
class CShaderProgram;
|
||||
typedef shared_ptr<CShaderProgram> CShaderProgramPtr;
|
||||
|
||||
class CTextRenderer;
|
||||
|
||||
#define CONSOLE_BUFFER_SIZE 1024 // for text being typed into the console
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2014 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -43,8 +43,6 @@
|
||||
#include "renderer/TimeManager.h"
|
||||
#include "renderer/WaterManager.h"
|
||||
|
||||
#include <boost/weak_ptr.hpp>
|
||||
|
||||
#if ARCH_X86_X64
|
||||
# include "lib/sysdep/arch/x86_x64/x86_x64.h"
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2012 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -24,7 +24,7 @@
|
||||
#ifndef INCLUDED_MODELRENDERER
|
||||
#define INCLUDED_MODELRENDERER
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <memory>
|
||||
|
||||
#include "graphics/MeshManager.h"
|
||||
#include "graphics/RenderableObject.h"
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2014 Wildfire Games.
|
||||
/* Copyright (C) 2015 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@ -19,7 +19,6 @@
|
||||
#define INCLUDED_SCRIPTVAL
|
||||
|
||||
#include "ScriptTypes.h"
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
/**
|
||||
* A default constructible wrapper around JS::PersistentRootedValue
|
||||
|
Loading…
Reference in New Issue
Block a user