Skip to content

Commit

Permalink
now using std::tr1 smart pointers if available, or boost's implementa…
Browse files Browse the repository at this point in the history
…tion otherwise; we're using <boost/tr1/memory.hpp> to pull in either. Should fix GitHub issue #8.

corresponds to Perforce change 6132.
  • Loading branch information
c-lipka committed Dec 16, 2013
1 parent a417f97 commit c69dd33
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 89 deletions.
14 changes: 5 additions & 9 deletions source/backend/support/randomsequences.cpp
Expand Up @@ -22,11 +22,11 @@
* DKBTrace was originally written by David K. Buck.
* DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
* ---------------------------------------------------------------------------
* $File: //depot/public/povray/3.x/source/backend/support/randomsequences.cpp $
* $Revision: #1 $
* $Change: 6069 $
* $DateTime: 2013/11/06 11:59:40 $
* $Author: chrisc $
* $File: //depot/povray/smp/source/backend/support/randomsequences.cpp $
* $Revision: #23 $
* $Change: 6132 $
* $DateTime: 2013/11/25 14:23:41 $
* $Author: clipka $
*******************************************************************************/

#include <cassert>
Expand All @@ -38,8 +38,6 @@
#include <boost/random/uniform_real.hpp>
#include <boost/random/variate_generator.hpp>

#include <boost/weak_ptr.hpp>

// frame.h must always be the first POV file included (pulls in platform config)
#include "backend/frame.h"
#include "backend/support/randomsequences.h"
Expand All @@ -57,8 +55,6 @@ using boost::uniform_real;
using boost::variate_generator;
using boost::mt19937;

using boost::weak_ptr;

#ifndef SIZE_MAX
#define SIZE_MAX ((size_t)-1)
#endif
Expand Down
16 changes: 8 additions & 8 deletions source/base/image/colourspace.cpp
Expand Up @@ -22,11 +22,11 @@
* DKBTrace was originally written by David K. Buck.
* DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
* ---------------------------------------------------------------------------
* $File: //depot/public/povray/3.x/source/base/image/colourspace.cpp $
* $Revision: #1 $
* $Change: 6069 $
* $DateTime: 2013/11/06 11:59:40 $
* $Author: chrisc $
* $File: //depot/povray/smp/source/base/image/colourspace.cpp $
* $Revision: #8 $
* $Change: 6132 $
* $DateTime: 2013/11/25 14:23:41 $
* $Author: clipka $
*******************************************************************************/

#include <vector>
Expand All @@ -46,7 +46,7 @@ namespace pov_base
{

// definitions of static GammaCurve member variables to satisfy the linker
list<boost::weak_ptr<GammaCurve> > GammaCurve::cache;
list<weak_ptr<GammaCurve> > GammaCurve::cache;
boost::mutex GammaCurve::cacheMutex;

// definitions of static GammaCurve-derivatives' member variables to satisfy the linker
Expand Down Expand Up @@ -95,7 +95,7 @@ GammaCurvePtr GammaCurve::GetMatching(const GammaCurvePtr& newInstance)
// Check if we already have created a matching gamma curve object; if so, return that object instead.
// Also, make sure we get the new object stored (as we're using weak pointers, we may have stale entries;
// it also won't hurt if we store the new instance, even if we decide to discard it)
for(list<boost::weak_ptr<GammaCurve> >::iterator i(cache.begin()); i != cache.end(); i++)
for(list<weak_ptr<GammaCurve> >::iterator i(cache.begin()); i != cache.end(); i++)
{
oldInstance = (*i).lock();
if (!oldInstance)
Expand Down Expand Up @@ -247,7 +247,7 @@ SimpleGammaCurvePtr PowerLawGammaCurve::GetByEncodingGamma(float gamma)
{
if (IsNeutral(gamma))
return NeutralGammaCurve::Get();
return boost::dynamic_pointer_cast<SimpleGammaCurve,GammaCurve>(GetMatching(GammaCurvePtr(new PowerLawGammaCurve(gamma))));
return std::tr1::dynamic_pointer_cast<SimpleGammaCurve,GammaCurve>(GetMatching(GammaCurvePtr(new PowerLawGammaCurve(gamma))));
}
SimpleGammaCurvePtr PowerLawGammaCurve::GetByDecodingGamma(float gamma)
{
Expand Down
13 changes: 6 additions & 7 deletions source/base/image/colourspace.h
Expand Up @@ -25,9 +25,9 @@
* DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
* ---------------------------------------------------------------------------
* $File: //depot/povray/smp/source/base/image/colourspace.h $
* $Revision: #8 $
* $Change: 6089 $
* $DateTime: 2013/11/11 09:18:35 $
* $Revision: #9 $
* $Change: 6132 $
* $DateTime: 2013/11/25 14:23:41 $
* $Author: clipka $
*******************************************************************************/

Expand All @@ -36,7 +36,6 @@

#include <vector>

#include <boost/weak_ptr.hpp>
#include <boost/thread.hpp>

#include "base/configbase.h"
Expand All @@ -52,12 +51,12 @@ class SimpleGammaCurve;
/**
* Class holding a shared reference to a gamma curve.
*/
typedef boost::shared_ptr<GammaCurve> GammaCurvePtr;
typedef shared_ptr<GammaCurve> GammaCurvePtr;

/**
* Class holding a shared reference to a simple gamma curve.
*/
typedef boost::shared_ptr<SimpleGammaCurve> SimpleGammaCurvePtr;
typedef shared_ptr<SimpleGammaCurve> SimpleGammaCurvePtr;

/**
* Abstract class representing an encoding gamma curve (or, more generally, transfer function).
Expand Down Expand Up @@ -201,7 +200,7 @@ class GammaCurve
* This static member variable caches pointers of gamma curve instances currently in use, forming the basis
* of the @c GetMatching() mechanism to avoid duplicate instances.
*/
static list<boost::weak_ptr<GammaCurve> > cache;
static list<weak_ptr<GammaCurve> > cache;

/**
* Mutex to guard access to @c cache.
Expand Down
8 changes: 4 additions & 4 deletions source/base/image/encoding.h
Expand Up @@ -25,9 +25,9 @@
* DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
* ---------------------------------------------------------------------------
* $File: //depot/povray/smp/source/base/image/encoding.h $
* $Revision: #5 $
* $Change: 6096 $
* $DateTime: 2013/11/18 14:11:26 $
* $Revision: #6 $
* $Change: 6132 $
* $DateTime: 2013/11/25 14:23:41 $
* $Author: clipka $
*******************************************************************************/

Expand Down Expand Up @@ -77,7 +77,7 @@ class DitherHandler
virtual void setError(unsigned int x, unsigned int y, const OffsetInfo& err) {}
};

typedef boost::shared_ptr<DitherHandler> DitherHandlerPtr;
typedef shared_ptr<DitherHandler> DitherHandlerPtr;

/// Factory class to get a dithering rule and state.
DitherHandlerPtr GetDitherHandler(int method, unsigned int imageWidth);
Expand Down
12 changes: 6 additions & 6 deletions source/frontend/shelloutprocessing.h
Expand Up @@ -22,11 +22,11 @@
* DKBTrace was originally written by David K. Buck.
* DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
* ---------------------------------------------------------------------------
* $File: //depot/public/povray/3.x/source/frontend/shelloutprocessing.h $
* $Revision: #1 $
* $Change: 6069 $
* $DateTime: 2013/11/06 11:59:40 $
* $Author: chrisc $
* $File: //depot/povray/smp/source/frontend/shelloutprocessing.h $
* $Revision: #9 $
* $Change: 6132 $
* $DateTime: 2013/11/25 14:23:41 $
* $Author: clipka $
*******************************************************************************/

#ifndef POVRAY_FRONTEND_SHELLOUTPROCESSING_H
Expand Down Expand Up @@ -84,7 +84,7 @@ class ShelloutProcessing
friend class ShelloutAction;

public:
typedef boost::shared_ptr<ShelloutAction> ShelloutPtr;
typedef shared_ptr<ShelloutAction> ShelloutPtr;

typedef enum
{
Expand Down
12 changes: 6 additions & 6 deletions source/precomp.h
@@ -1,9 +1,9 @@
/*******************************************************************************
* $File: //depot/public/povray/3.x/source/precomp.h $
* $Revision: #1 $
* $Change: 6069 $
* $DateTime: 2013/11/06 11:59:40 $
* $Author: chrisc $
* $File: //depot/povray/smp/source/precomp.h $
* $Revision: #3 $
* $Change: 6132 $
* $DateTime: 2013/11/25 14:23:41 $
* $Author: clipka $
*******************************************************************************/

#include <algorithm>
Expand Down Expand Up @@ -37,6 +37,6 @@
#include <boost/thread.hpp>
#include <boost/thread/condition.hpp>
#include <boost/unordered_map.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/tr1/memory.hpp>


12 changes: 6 additions & 6 deletions unix/disp.h
Expand Up @@ -27,11 +27,11 @@
* DKBTrace was originally written by David K. Buck.
* DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
* ---------------------------------------------------------------------------
* $File: //depot/public/povray/3.x/unix/disp.h $
* $Revision: #1 $
* $Change: 6069 $
* $DateTime: 2013/11/06 11:59:40 $
* $Author: chrisc $
* $File: //depot/povray/smp/unix/disp.h $
* $Revision: #11 $
* $Change: 6132 $
* $DateTime: 2013/11/25 14:23:41 $
* $Author: clipka $
*******************************************************************************/

#ifndef _DISP_H
Expand All @@ -46,7 +46,7 @@ namespace pov_frontend
using namespace std;
using namespace vfe;

extern boost::shared_ptr<Display> gDisplay;
extern shared_ptr<Display> gDisplay;

class UnixDisplay : public vfeDisplay
{
Expand Down
12 changes: 6 additions & 6 deletions unix/disp_sdl.cpp
Expand Up @@ -26,11 +26,11 @@
* DKBTrace was originally written by David K. Buck.
* DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
* ---------------------------------------------------------------------------
* $File: //depot/public/povray/3.x/unix/disp_sdl.cpp $
* $Revision: #1 $
* $Change: 6069 $
* $DateTime: 2013/11/06 11:59:40 $
* $Author: chrisc $
* $File: //depot/povray/smp/unix/disp_sdl.cpp $
* $Revision: #23 $
* $Change: 6132 $
* $DateTime: 2013/11/25 14:23:41 $
* $Author: clipka $
*******************************************************************************/

#include "config.h"
Expand All @@ -51,7 +51,7 @@ namespace pov_frontend
using namespace vfe;
using namespace vfePlatform;

extern boost::shared_ptr<Display> gDisplay;
extern shared_ptr<Display> gDisplay;

const UnixOptionsProcessor::Option_Info UnixSDLDisplay::Options[] =
{
Expand Down
13 changes: 7 additions & 6 deletions vfe/unix/syspovconfig.h
Expand Up @@ -25,9 +25,9 @@
* DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
* ---------------------------------------------------------------------------
* $File: //depot/povray/smp/vfe/unix/syspovconfig.h $
* $Revision: #15 $
* $Change: 6129 $
* $DateTime: 2013/11/25 11:09:30 $
* $Revision: #17 $
* $Change: 6133 $
* $DateTime: 2013/11/25 15:28:53 $
* $Author: clipka $
*******************************************************************************/

Expand Down Expand Up @@ -64,7 +64,7 @@ using std::min;
#include <string>
#include <vector>
#include <list>
#include <boost/shared_ptr.hpp>
#include <boost/tr1/memory.hpp>

// when we say 'string' we mean std::string
using std::string;
Expand All @@ -79,8 +79,9 @@ using std::list;
// to in a few other places.
using std::runtime_error;

// C++0x has a shared_ptr, but we currently use the boost one.
using boost::shared_ptr;
// these may actually be the boost implementations, depending on what boost/tr1/memory.hpp has pulled in
using std::tr1::shared_ptr;
using std::tr1::weak_ptr;

#endif // STD_POV_TYPES_DECLARED

Expand Down
2 changes: 1 addition & 1 deletion vfe/unix/unixconsole.cpp
Expand Up @@ -46,7 +46,7 @@

namespace pov_frontend
{
boost::shared_ptr<Display> gDisplay;
shared_ptr<Display> gDisplay;
}

using namespace vfe;
Expand Down
8 changes: 4 additions & 4 deletions vfe/unix/vfeplatform.cpp
Expand Up @@ -27,9 +27,9 @@
* DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
* ---------------------------------------------------------------------------
* $File: //depot/povray/smp/vfe/unix/vfeplatform.cpp $
* $Revision: #17 $
* $Change: 6130 $
* $DateTime: 2013/11/25 11:36:19 $
* $Revision: #18 $
* $Change: 6132 $
* $DateTime: 2013/11/25 14:23:41 $
* $Author: clipka $
*******************************************************************************/

Expand Down Expand Up @@ -72,7 +72,7 @@ namespace vfePlatform
vfeUnixSession::vfeUnixSession(int id) :
m_LastTimestamp(0), m_TimestampOffset(0), vfeSession(id)
{
m_OptionsProc = boost::shared_ptr<UnixOptionsProcessor>(new UnixOptionsProcessor(this));
m_OptionsProc = shared_ptr<UnixOptionsProcessor>(new UnixOptionsProcessor(this));
}

/////////////////////////////////////////////////////////////////////////
Expand Down
10 changes: 5 additions & 5 deletions vfe/unix/vfeplatform.h
Expand Up @@ -27,9 +27,9 @@
* DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
* ---------------------------------------------------------------------------
* $File: //depot/povray/smp/vfe/unix/vfeplatform.h $
* $Revision: #11 $
* $Change: 6130 $
* $DateTime: 2013/11/25 11:36:19 $
* $Revision: #12 $
* $Change: 6132 $
* $DateTime: 2013/11/25 14:23:41 $
* $Author: clipka $
*******************************************************************************/

Expand Down Expand Up @@ -91,7 +91,7 @@ namespace vfePlatform
virtual ShelloutProcessing *CreateShelloutProcessing(POVMS_Object& opts, const string& scene, unsigned int width, unsigned int height)
{ return new UnixShelloutProcessing(opts, scene, width, height); }

boost::shared_ptr<UnixOptionsProcessor> GetUnixOptions(void) { return m_OptionsProc; }
shared_ptr<UnixOptionsProcessor> GetUnixOptions(void) { return m_OptionsProc; }

protected:
virtual void WorkerThreadStartup();
Expand All @@ -117,7 +117,7 @@ namespace vfePlatform
mutable POV_LONG m_TimestampOffset;

// platform specific configuration options
boost::shared_ptr<UnixOptionsProcessor> m_OptionsProc;
shared_ptr<UnixOptionsProcessor> m_OptionsProc;
} ;

///////////////////////////////////////////////////////////////////////
Expand Down
12 changes: 6 additions & 6 deletions vfe/vfe.h
Expand Up @@ -24,11 +24,11 @@
* DKBTrace was originally written by David K. Buck.
* DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
* ---------------------------------------------------------------------------
* $File: //depot/public/povray/3.x/vfe/vfe.h $
* $Revision: #1 $
* $Change: 6069 $
* $DateTime: 2013/11/06 11:59:40 $
* $Author: chrisc $
* $File: //depot/povray/smp/vfe/vfe.h $
* $Revision: #19 $
* $Change: 6132 $
* $DateTime: 2013/11/25 14:23:41 $
* $Author: clipka $
*******************************************************************************/

#ifndef __VFE_H__
Expand Down Expand Up @@ -222,7 +222,7 @@ namespace vfe
virtual bool IsPausable() ;
virtual bool Paused() ;
virtual bool PausePending() { return m_PauseRequested; }
virtual boost::shared_ptr<Display> GetDisplay() { return renderFrontend.GetDisplay(viewId); }
virtual shared_ptr<Display> GetDisplay() { return renderFrontend.GetDisplay(viewId); }

// TODO: take care of any pending messages (e.g. a thread waiting on a blocking send)
virtual void InvalidateBackend() { backendAddress = POVMSInvalidAddress; }
Expand Down
2 changes: 1 addition & 1 deletion vfe/vfesession.cpp
Expand Up @@ -540,7 +540,7 @@ const char *vfeSession::GetBackendStateName (void) const
// Returns a copy of the shared pointer containing the current instance
// of a pov_frontend::Display-derived render preview instance, which may
// be NULL.
boost::shared_ptr<Display> vfeSession::GetDisplay() const
shared_ptr<Display> vfeSession::GetDisplay() const
{
if (m_Frontend == NULL)
return (shared_ptr<Display>());
Expand Down
8 changes: 4 additions & 4 deletions vfe/vfesession.h
Expand Up @@ -27,9 +27,9 @@
* DKBTrace Ver 2.0-2.12 were written by David K. Buck & Aaron A. Collins.
* ---------------------------------------------------------------------------
* $File: //depot/povray/smp/vfe/vfesession.h $
* $Revision: #32 $
* $Change: 6130 $
* $DateTime: 2013/11/25 11:36:19 $
* $Revision: #33 $
* $Change: 6132 $
* $DateTime: 2013/11/25 14:23:41 $
* $Author: clipka $
*******************************************************************************/

Expand Down Expand Up @@ -516,7 +516,7 @@ namespace vfe
// Returns a copy of the shared pointer containing the current instance
// of a pov_frontend::Display-derived render preview instance, which may
// be NULL.
virtual boost::shared_ptr<Display> GetDisplay() const;
virtual shared_ptr<Display> GetDisplay() const;

// If a VFE implementation has provided a display creator functor via
// vfeSession::SetDisplayCreator(), this method will call it with the
Expand Down

0 comments on commit c69dd33

Please sign in to comment.