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

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 @@ ...@@ -10,12 +10,44 @@
* Include this in all ACGL (header)-files. It will include stuff that is used in * Include this in all ACGL (header)-files. It will include stuff that is used in
* almost every file: * almost every file:
* the used datatypes * the used datatypes
* including shared/weak pointers!
* macros and defines used at compile-time * macros and defines used at compile-time
* logging * logging
* *
* Also the librarys init function is defined here. * 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/Base/CompileTimeSettings.hh>
#include <ACGL/Types.hh> #include <ACGL/Types.hh>
#include <ACGL/Utils/Log.hh> #include <ACGL/Utils/Log.hh>
...@@ -34,7 +66,7 @@ namespace ACGL ...@@ -34,7 +66,7 @@ namespace ACGL
*/ */
bool init(void); bool init(void);
}; }
#endif // ACGL_ACGL_HH #endif // ACGL_ACGL_HH
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
#ifndef ACGL_ANIMATIONS_EASEFUNCTIONS_HH #ifndef ACGL_ANIMATIONS_EASEFUNCTIONS_HH
#define ACGL_ANIMATIONS_EASEFUNCTIONS_HH #define ACGL_ANIMATIONS_EASEFUNCTIONS_HH
#include <ACGL/ACGL.hh>
#include <ACGL/Math/Math.hh> #include <ACGL/Math/Math.hh>
#include <ACGL/Base/Macros.hh> #include <ACGL/Base/Macros.hh>
#include <tr1/memory>
namespace ACGL namespace ACGL
{ {
namespace Animations namespace Animations
......
...@@ -6,13 +6,14 @@ ...@@ -6,13 +6,14 @@
#ifndef ACGL_ANIMATIONS_INTERPOLATOR_HH #ifndef ACGL_ANIMATIONS_INTERPOLATOR_HH
#define ACGL_ANIMATIONS_INTERPOLATOR_HH #define ACGL_ANIMATIONS_INTERPOLATOR_HH
#include <ACGL/ACGL.hh>
#include <ACGL/Animations/EaseFunctions.hh> #include <ACGL/Animations/EaseFunctions.hh>
#include <ACGL/Scene/NURBSCurve.hh> #include <ACGL/Scene/NURBSCurve.hh>
#include <ACGL/Types.hh> #include <ACGL/Types.hh>
#include <ACGL/Base/Macros.hh> #include <ACGL/Base/Macros.hh>
#include <vector> #include <vector>
#include <tr1/memory>
namespace ACGL namespace ACGL
{ {
......
...@@ -13,10 +13,10 @@ private:\ ...@@ -13,10 +13,10 @@ private:\
void operator=(Class& ){ } void operator=(Class& ){ }
#define ACGL_SHARED_TYPEDEF(Class) \ #define ACGL_SHARED_TYPEDEF(Class) \
typedef std::tr1::shared_ptr<Class> Shared ## Class; \ typedef ptr::shared_ptr<Class> Shared ## Class; \
typedef std::tr1::shared_ptr<const Class> ConstShared ## Class; \ typedef ptr::shared_ptr<const Class> ConstShared ## Class; \
typedef std::tr1::weak_ptr<Class> Weak ## Class; \ typedef ptr::weak_ptr<Class> Weak ## Class; \
typedef std::tr1::weak_ptr<const Class> ConstWeak ## Class; typedef ptr::weak_ptr<const Class> ConstWeak ## Class;
#endif // MACROS_HH #endif // MACROS_HH
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
*/ */
#include <ACGL/ACGL.hh> #include <ACGL/ACGL.hh>
#include <tr1/memory>
namespace ACGL{ namespace ACGL{
namespace Base{ namespace Base{
...@@ -23,7 +22,7 @@ class Singleton ...@@ -23,7 +22,7 @@ class Singleton
public: public:
virtual ~Singleton(void) {} virtual ~Singleton(void) {}
static std::tr1::shared_ptr<CLASS> the(void) static ptr::shared_ptr<CLASS> the(void)
{ {
if(!spInstance) if(!spInstance)
spInstance.reset(new CLASS()); spInstance.reset(new CLASS());
...@@ -36,12 +35,12 @@ private: ...@@ -36,12 +35,12 @@ private:
Singleton(const Singleton&){} Singleton(const Singleton&){}
private: private:
static std::tr1::shared_ptr<CLASS> spInstance; static ptr::shared_ptr<CLASS> spInstance;
}; };
template<typename CLASS> 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) \ #define ACGL_SINGLETON(Class) \
friend class Base::Singleton< Class >; \ friend class Base::Singleton< Class >; \
......
...@@ -40,9 +40,9 @@ public: ...@@ -40,9 +40,9 @@ public:
// ============================================================================================ OVERRIDE \/ // ============================================================================================ OVERRIDE \/
// ===================================================================================================== \/ // ===================================================================================================== \/
public: 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); uniform->setValue(mValue);
return uniform; return uniform;
} }
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <tr1/memory>
#include <ACGL/OpenGL/Objects/Buffer.hh> #include <ACGL/OpenGL/Objects/Buffer.hh>
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <tr1/memory>
namespace ACGL{ namespace ACGL{
namespace OpenGL{ namespace OpenGL{
...@@ -58,7 +57,7 @@ public: ...@@ -58,7 +57,7 @@ public:
} }
GLuint mObjectName; GLuint mObjectName;
}; };
typedef std::tr1::shared_ptr<BufferObject> SharedBufferObject; typedef ptr::shared_ptr<BufferObject> SharedBufferObject;
/** /**
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <ACGL/OpenGL/Tools.hh> #include <ACGL/OpenGL/Tools.hh>
#include <ACGL/OpenGL/Objects/Buffer.hh> #include <ACGL/OpenGL/Objects/Buffer.hh>
#include <tr1/memory>
namespace ACGL{ namespace ACGL{
namespace OpenGL{ namespace OpenGL{
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include <vector> #include <vector>
#include <map> #include <map>
#include <tr1/memory>
namespace ACGL{ namespace ACGL{
namespace OpenGL{ namespace OpenGL{
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <ACGL/OpenGL/GL.hh> #include <ACGL/OpenGL/GL.hh>
#include <ACGL/OpenGL/Tools.hh> #include <ACGL/OpenGL/Tools.hh>
#include <tr1/memory>
namespace ACGL{ namespace ACGL{
namespace OpenGL{ namespace OpenGL{
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <ACGL/OpenGL/GL.hh> #include <ACGL/OpenGL/GL.hh>
#include <ACGL/OpenGL/Tools.hh> #include <ACGL/OpenGL/Tools.hh>
#include <tr1/memory>
namespace ACGL{ namespace ACGL{
namespace OpenGL{ namespace OpenGL{
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <tr1/memory>
#include <iostream> #include <iostream>
#include <ACGL/Base/Macros.hh> #include <ACGL/Base/Macros.hh>
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <tr1/memory>
#include <ACGL/ACGL.hh> #include <ACGL/ACGL.hh>
......
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
#include <ACGL/Math/Math.hh> #include <ACGL/Math/Math.hh>
#include <vector> #include <vector>
#include <tr1/memory>
namespace ACGL{ namespace ACGL{
namespace OpenGL{ namespace OpenGL{
......
...@@ -27,7 +27,6 @@ ...@@ -27,7 +27,6 @@
#include <ACGL/OpenGL/Objects/ShaderProgram.hh> #include <ACGL/OpenGL/Objects/ShaderProgram.hh>
#include <ACGL/OpenGL/Objects/Uniform.hh> #include <ACGL/OpenGL/Objects/Uniform.hh>
#include <tr1/memory>
namespace ACGL{ namespace ACGL{
namespace OpenGL{ namespace OpenGL{
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <ACGL/Math/Math.hh> #include <ACGL/Math/Math.hh>
#include <vector> #include <vector>
#include <tr1/memory>
namespace ACGL{ namespace ACGL{
namespace OpenGL{ namespace OpenGL{
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include <ACGL/Math/Math.hh> #include <ACGL/Math/Math.hh>
#include <ACGL/OpenGL/Objects/Texture.hh> #include <ACGL/OpenGL/Objects/Texture.hh>
#include <tr1/memory>
namespace ACGL{ namespace ACGL{
namespace OpenGL{ namespace OpenGL{
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include <ACGL/OpenGL/Objects/ShaderProgram.hh> #include <ACGL/OpenGL/Objects/ShaderProgram.hh>
#include <vector> #include <vector>
#include <tr1/memory>
namespace ACGL{ namespace ACGL{
namespace OpenGL{ namespace OpenGL{
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <ACGL/OpenGL/Objects/ElementArrayBuffer.hh> #include <ACGL/OpenGL/Objects/ElementArrayBuffer.hh>
#include <vector> #include <vector>
#include <tr1/memory>
namespace ACGL{ namespace ACGL{
namespace OpenGL{ namespace OpenGL{
......
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