From 7f8b7b37121e06cec76b2b1cab1b56920c2c4ef4 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Fri, 22 Apr 2016 17:15:03 +0200 Subject: Fix build --- include/astra/Fourier.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/astra') diff --git a/include/astra/Fourier.h b/include/astra/Fourier.h index ff26f82..68f9f38 100644 --- a/include/astra/Fourier.h +++ b/include/astra/Fourier.h @@ -76,7 +76,7 @@ namespace astra { } . */ -void cdft(int n, int isgn, float32 *a, int *ip, float32 *w); +_AstraExport void cdft(int n, int isgn, float32 *a, int *ip, float32 *w); } -- cgit v1.2.3 From 8b67986464daae799d0171aed70a0d2cd96fd8d1 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Fri, 22 Apr 2016 17:39:59 +0200 Subject: Fix build --- include/astra/AstraObjectManager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/astra') diff --git a/include/astra/AstraObjectManager.h b/include/astra/AstraObjectManager.h index ad89c2a..9faecbe 100644 --- a/include/astra/AstraObjectManager.h +++ b/include/astra/AstraObjectManager.h @@ -60,7 +60,7 @@ public: }; -class CAstraIndexManager : public Singleton { +class _AstraExport CAstraIndexManager : public Singleton { public: CAstraIndexManager() : m_iLastIndex(0) { } -- cgit v1.2.3 From 73ad6a97531b6bc1d311eceb6ba2770fdf407b81 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 17 May 2016 11:22:17 +0200 Subject: Avoid defining singleton construction in header file That way, the call to new is always executed by code inside libastra. This avoids the situation where a singleton gets created by a copy of the constructor linked into an object file outside of libastra, such as a .mex file, which would then also cause the vtable to be outside of libastra. This situation would cause issues when .mex files are unloaded. --- include/astra/Singleton.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'include/astra') diff --git a/include/astra/Singleton.h b/include/astra/Singleton.h index a256187..1ef4bba 100644 --- a/include/astra/Singleton.h +++ b/include/astra/Singleton.h @@ -57,15 +57,17 @@ class Singleton { m_singleton = 0; } + static void construct(); + // get singleton static T& getSingleton() { if (!m_singleton) - m_singleton = new T(); + construct(); return *m_singleton; } static T* getSingletonPtr() { if (!m_singleton) - m_singleton = new T(); + construct(); return m_singleton; } @@ -76,11 +78,23 @@ class Singleton { }; -#define DEFINE_SINGLETON(T) template<> T* Singleton::m_singleton = 0 +// We specifically avoid defining construct() in the header. +// That way, the call to new is always executed by code inside libastra. +// This avoids the situation where a singleton gets created by a copy +// of the constructor linked into an object file outside of libastra, such +// as a .mex file, which would then also cause the vtable to be outside of +// libastra. This situation would cause issues when .mex files are unloaded. + +#define DEFINE_SINGLETON(T) \ +template<> void Singleton::construct() { m_singleton = new T(); } \ +template<> T* Singleton::m_singleton = 0 + // This is a hack to support statements like // DEFINE_SINGLETON2(CTemplatedClass); -#define DEFINE_SINGLETON2(A,B) template<> A,B* Singleton::m_singleton = 0 +#define DEFINE_SINGLETON2(A,B) \ +template<> void Singleton::construct() { m_singleton = new A,B(); } \ +template<> A,B* Singleton::m_singleton = 0 } // end namespace -- cgit v1.2.3 From f9b68bafd90941d9faf53e5e2771361e3ab4336a Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 17 May 2016 16:00:28 +0200 Subject: Add sanity check --- include/astra/Singleton.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/astra') diff --git a/include/astra/Singleton.h b/include/astra/Singleton.h index 1ef4bba..784c521 100644 --- a/include/astra/Singleton.h +++ b/include/astra/Singleton.h @@ -86,14 +86,14 @@ class Singleton { // libastra. This situation would cause issues when .mex files are unloaded. #define DEFINE_SINGLETON(T) \ -template<> void Singleton::construct() { m_singleton = new T(); } \ +template<> void Singleton::construct() { assert(!m_singleton); m_singleton = new T(); } \ template<> T* Singleton::m_singleton = 0 // This is a hack to support statements like // DEFINE_SINGLETON2(CTemplatedClass); #define DEFINE_SINGLETON2(A,B) \ -template<> void Singleton::construct() { m_singleton = new A,B(); } \ +template<> void Singleton::construct() { assert(!m_singleton); m_singleton = new A,B(); } \ template<> A,B* Singleton::m_singleton = 0 } // end namespace -- cgit v1.2.3 From 584fb584816aefca42518c9a6075ac2df814dac6 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Thu, 28 Jul 2016 15:32:50 +0200 Subject: Replace use of boost::split by own function --- include/astra/Utilities.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include/astra') diff --git a/include/astra/Utilities.h b/include/astra/Utilities.h index 8d7c44d..22adfe2 100644 --- a/include/astra/Utilities.h +++ b/include/astra/Utilities.h @@ -85,6 +85,9 @@ _AstraExport std::string doubleToString(double f); template _AstraExport std::string toString(T f); + +_AstraExport void splitString(std::vector &items, const std::string& s, const char *delim); + } -- cgit v1.2.3 From 53249b3ad63f0d08b9862a75602acf263d230d77 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Thu, 28 Jul 2016 16:33:37 +0200 Subject: Remove leftover code from Singleton --- include/astra/Singleton.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'include/astra') diff --git a/include/astra/Singleton.h b/include/astra/Singleton.h index 784c521..9d3c088 100644 --- a/include/astra/Singleton.h +++ b/include/astra/Singleton.h @@ -45,11 +45,7 @@ class Singleton { public: // constructor - Singleton() { - assert(!m_singleton); - int offset = (uintptr_t)(T*)1 - (uintptr_t)(Singleton*)(T*)1; - m_singleton = (T*)((uintptr_t)this + offset); - }; + Singleton() { } // destructor virtual ~Singleton() { -- cgit v1.2.3