Commit 795bcd09 authored by Robert Menzel's avatar Robert Menzel

Moved shared pointer includes

The shared and weak pointers are now included via ACGL.hh, this way there is one
one central place to replace the pointers if needed (C++11, TR1, boost, own variant).
For this, they are placed in a ptr namespace so std:: (C++11) and str::tr1:: (C++98)
variants as well as boost and own implementations can all get redirected.
C++11 detection added and correct non-tr1 header include added (should make VS2010
porting easier).
parent cff02428
......@@ -10,12 +10,44 @@
* Include this in all ACGL (header)-files. It will include stuff that is used in
* almost every file:
* the used datatypes
* including shared/weak pointers!
* macros and defines used at compile-time
* logging
*
* Also the librarys init function is defined here.
*/
/*!
* ACGL needs shared and weak pointers that behave like the C++11 smartpointers.
* The C++11, TR1 and boost variants should all be fine, you can also plug-in
* your own compatible pointers here.
*
* Place them in the ptr:: namespace with aliases.
*
* A detection for TR1 is missing, it is assumed that a pre-C++11 compiler has TR1.
* In case of porting this to a non-C++11/non-TR1 compiler add a check and e.g.
* add the boost shared and smart pointers:
*
* #include <boost...>
* namespace ptr = boost::tr1;
*
* Or roll your own pointers (in this case, add a compileflag and default to the
* std pointers!):
*
* # include <myOwnAwsomeSharedPointer.hh>
* namespace ptr = ACGL::Base;
*
*/
#if (__cplusplus >= 201103L)
// C++11:
# include <memory>
namespace ptr = std;
#else
// C++98 and TR1:
# include <tr1/memory>
namespace ptr = std::tr1;
#endif
#include <ACGL/Base/CompileTimeSettings.hh>
#include <ACGL/Types.hh>
#include <ACGL/Utils/Log.hh>
......@@ -34,7 +66,7 @@ namespace ACGL
*/
bool init(void);
};
}
#endif // ACGL_ACGL_HH
......@@ -6,11 +6,11 @@
#ifndef ACGL_ANIMATIONS_EASEFUNCTIONS_HH
#define ACGL_ANIMATIONS_EASEFUNCTIONS_HH
#include <ACGL/ACGL.hh>
#include <ACGL/Math/Math.hh>
#include <ACGL/Base/Macros.hh>
#include <tr1/memory>
namespace ACGL
{
namespace Animations
......
......@@ -6,13 +6,14 @@
#ifndef ACGL_ANIMATIONS_INTERPOLATOR_HH
#define ACGL_ANIMATIONS_INTERPOLATOR_HH
#include <ACGL/ACGL.hh>
#include <ACGL/Animations/EaseFunctions.hh>
#include <ACGL/Scene/NURBSCurve.hh>
#include <ACGL/Types.hh>
#include <ACGL/Base/Macros.hh>
#include <vector>
#include <tr1/memory>
namespace ACGL
{
......
......@@ -13,10 +13,10 @@ private:\
void operator=(Class& ){ }
#define ACGL_SHARED_TYPEDEF(Class) \
typedef std::tr1::shared_ptr<Class> Shared ## Class; \
typedef std::tr1::shared_ptr<const Class> ConstShared ## Class; \
typedef std::tr1::weak_ptr<Class> Weak ## Class; \
typedef std::tr1::weak_ptr<const Class> ConstWeak ## Class;
typedef ptr::shared_ptr<Class> Shared ## Class; \
typedef ptr::shared_ptr<const Class> ConstShared ## Class; \
typedef ptr::weak_ptr<Class> Weak ## Class; \
typedef ptr::weak_ptr<const Class> ConstWeak ## Class;
#endif // MACROS_HH
......@@ -12,7 +12,6 @@
*/
#include <ACGL/ACGL.hh>
#include <tr1/memory>
namespace ACGL{
namespace Base{
......@@ -23,7 +22,7 @@ class Singleton
public:
virtual ~Singleton(void) {}
static std::tr1::shared_ptr<CLASS> the(void)
static ptr::shared_ptr<CLASS> the(void)
{
if(!spInstance)
spInstance.reset(new CLASS());
......@@ -36,12 +35,12 @@ private:
Singleton(const Singleton&){}
private:
static std::tr1::shared_ptr<CLASS> spInstance;
static ptr::shared_ptr<CLASS> spInstance;
};
template<typename CLASS>
std::tr1::shared_ptr<CLASS> Singleton<CLASS>::spInstance = std::tr1::shared_ptr<CLASS>();
ptr::shared_ptr<CLASS> Singleton<CLASS>::spInstance = ptr::shared_ptr<CLASS>();
#define ACGL_SINGLETON(Class) \
friend class Base::Singleton< Class >; \
......
......@@ -40,9 +40,9 @@ public:
// ============================================================================================ OVERRIDE \/
// ===================================================================================================== \/
public:
virtual std::tr1::shared_ptr<UNIFORM> create(void)
virtual ptr::shared_ptr<UNIFORM> create(void)
{
std::tr1::shared_ptr<UNIFORM> uniform(new UNIFORM());
ptr::shared_ptr<UNIFORM> uniform(new UNIFORM());
uniform->setValue(mValue);
return uniform;
}
......
......@@ -32,7 +32,6 @@
#include <string>
#include <vector>
#include <tr1/memory>
#include <ACGL/OpenGL/Objects/Buffer.hh>
......
......@@ -26,7 +26,6 @@
#include <string>
#include <vector>
#include <tr1/memory>
namespace ACGL{
namespace OpenGL{
......@@ -58,7 +57,7 @@ public:
}
GLuint mObjectName;
};
typedef std::tr1::shared_ptr<BufferObject> SharedBufferObject;
typedef ptr::shared_ptr<BufferObject> SharedBufferObject;
/**
......
......@@ -27,7 +27,6 @@
#include <ACGL/OpenGL/Tools.hh>
#include <ACGL/OpenGL/Objects/Buffer.hh>
#include <tr1/memory>
namespace ACGL{
namespace OpenGL{
......
......@@ -35,7 +35,6 @@
#include <vector>
#include <map>
#include <tr1/memory>
namespace ACGL{
namespace OpenGL{
......
......@@ -12,7 +12,6 @@
#include <ACGL/OpenGL/GL.hh>
#include <ACGL/OpenGL/Tools.hh>
#include <tr1/memory>
namespace ACGL{
namespace OpenGL{
......
......@@ -12,7 +12,6 @@
#include <ACGL/OpenGL/GL.hh>
#include <ACGL/OpenGL/Tools.hh>
#include <tr1/memory>
namespace ACGL{
namespace OpenGL{
......
......@@ -35,7 +35,6 @@
#include <vector>
#include <string>
#include <tr1/memory>
#include <iostream>
#include <ACGL/Base/Macros.hh>
......
......@@ -17,7 +17,6 @@
#include <vector>
#include <string>
#include <tr1/memory>
#include <ACGL/ACGL.hh>
......
......@@ -51,7 +51,6 @@
#include <ACGL/Math/Math.hh>
#include <vector>
#include <tr1/memory>
namespace ACGL{
namespace OpenGL{
......
......@@ -27,7 +27,6 @@
#include <ACGL/OpenGL/Objects/ShaderProgram.hh>
#include <ACGL/OpenGL/Objects/Uniform.hh>
#include <tr1/memory>
namespace ACGL{
namespace OpenGL{
......
......@@ -19,7 +19,6 @@
#include <ACGL/Math/Math.hh>
#include <vector>
#include <tr1/memory>
namespace ACGL{
namespace OpenGL{
......
......@@ -23,7 +23,6 @@
#include <ACGL/Math/Math.hh>
#include <ACGL/OpenGL/Objects/Texture.hh>
#include <tr1/memory>
namespace ACGL{
namespace OpenGL{
......
......@@ -35,7 +35,6 @@
#include <ACGL/OpenGL/Objects/ShaderProgram.hh>
#include <vector>
#include <tr1/memory>
namespace ACGL{
namespace OpenGL{
......
......@@ -22,7 +22,6 @@
#include <ACGL/OpenGL/Objects/ElementArrayBuffer.hh>
#include <vector>
#include <tr1/memory>
namespace ACGL{
namespace OpenGL{
......
......@@ -8,7 +8,6 @@
#include <vector>
#include <string>
#include <tr1/memory>
#include <iostream>
#include <ACGL/ACGL.hh>
......
......@@ -13,8 +13,6 @@
* making managers more flexibe.
*/
#include <tr1/memory>
#include <ACGL/ACGL.hh>
namespace ACGL{
......@@ -27,7 +25,7 @@ class BasicCreateController
// ========================================================================================== INTERFACE \/
// ==================================================================================================== \/
public:
virtual std::tr1::shared_ptr<RESOURCE> create(void) = 0;
virtual ptr::shared_ptr<RESOURCE> create(void) = 0;
};
} // Resource
......
......@@ -13,8 +13,6 @@
* making managers more flexibe.
*/
#include <tr1/memory>
#include <ACGL/ACGL.hh>
namespace ACGL{
......@@ -27,7 +25,7 @@ class BasicUpdateController
// ========================================================================================== INTERFACE \/
// ==================================================================================================== \/
public:
virtual bool update(std::tr1::shared_ptr<RESOURCE>&) = 0;
virtual bool update(ptr::shared_ptr<RESOURCE>&) = 0;
};
} // Resource
......
......@@ -11,7 +11,6 @@
#include <ACGL/Base/Macros.hh>
#include <ACGL/Resource/FileController.hh>
#include <tr1/memory>
#include <map>
#include <string>
......@@ -24,7 +23,7 @@ class FileManager : public Base::Singleton< FileManager<RESOURCE> >
ACGL_SINGLETON(FileManager<RESOURCE>)
public:
typedef std::tr1::shared_ptr< FileController<RESOURCE> > SharedController;
typedef ptr::shared_ptr< FileController<RESOURCE> > SharedController;
ACGL_SHARED_TYPEDEF(RESOURCE)
struct Resource
{
......
......@@ -10,7 +10,6 @@
#include <ACGL/Base/Singleton.hh>
#include <ACGL/Resource/BasicCreateController.hh>
#include <tr1/memory>
#include <map>
#include <string>
......@@ -23,7 +22,7 @@ class NameManager : public Base::Singleton< NameManager<RESOURCE> >
friend class Base::Singleton< NameManager<RESOURCE> >;
public:
typedef std::tr1::shared_ptr<RESOURCE> SharedResource;
typedef ptr::shared_ptr<RESOURCE> SharedResource;
typedef std::map<std::string, SharedResource> ResourceMap;
typedef ResourceMap ResourceContainer;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment