From 38002c84509aef6275ff2cb803d46fc32526b03b Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Thu, 31 Jan 2013 01:03:40 -0500 Subject: [PATCH] had to dumb this down a bit so that it compiles with GCC 4.2.1/OSX --- include/mitsuba/render/scenehandler.h | 9 ++++----- src/librender/scenehandler.cpp | 2 +- src/shapes/serialized.cpp | 23 ++++++++++++++++------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/include/mitsuba/render/scenehandler.h b/include/mitsuba/render/scenehandler.h index 268967f8..d878f93a 100644 --- a/include/mitsuba/render/scenehandler.h +++ b/include/mitsuba/render/scenehandler.h @@ -68,6 +68,9 @@ private: # pragma warning( pop ) #endif +/// Push a cleanup handler to be executed after loading the scene is done +extern MTS_EXPORT_RENDER void pushSceneCleanupHandler(void (*cleanup)()); + /** * \brief XML parser for Mitsuba scene files. To be used with the * SAX interface of Xerces-C++. @@ -101,9 +104,6 @@ public: /// Free the memory taken up by staticInitialization() static void staticShutdown(); - /// Push a cleanup handler to be executed after loading the scene is done - static void pushCleanupHandler(void (*cleanup)()); - // ----------------------------------------------------------------------- // Implementation of the SAX DocumentHandler interface // ----------------------------------------------------------------------- @@ -136,8 +136,7 @@ protected: private: struct ParseContext { inline ParseContext(ParseContext *_parent) - : parent(_parent) { - } + : parent(_parent) { } ParseContext *parent; Properties properties; diff --git a/src/librender/scenehandler.cpp b/src/librender/scenehandler.cpp index 7c77e75b..947421d8 100644 --- a/src/librender/scenehandler.cpp +++ b/src/librender/scenehandler.cpp @@ -274,7 +274,7 @@ void SceneHandler::startElement(const XMLCh* const xmlName, m_context.push(context); } -void SceneHandler::pushCleanupHandler(void (*cleanup)()) { +void pushSceneCleanupHandler(void (*cleanup)()) { __cleanup_tls.get().insert(cleanup); } diff --git a/src/shapes/serialized.cpp b/src/shapes/serialized.cpp index 6b8cb68a..8ab416f0 100644 --- a/src/shapes/serialized.cpp +++ b/src/shapes/serialized.cpp @@ -17,7 +17,6 @@ */ #include -#include #include #include #include @@ -31,6 +30,9 @@ MTS_NAMESPACE_BEGIN +/* Avoid having to include scenehandler.h */ +extern MTS_EXPORT_RENDER void pushSceneCleanupHandler(void (*cleanup)()); + /*!\plugin{serialized}{Serialized mesh loader} * \order{7} * \parameters{ @@ -251,16 +253,23 @@ private: ref m_fstream; }; - struct FileStreamCache : LRUCache, - boost::shared_ptr > { + typedef LRUCache, + boost::shared_ptr > MeshLoaderCache; + class FileStreamCache : MeshLoaderCache { + public: inline boost::shared_ptr get(const fs::path& path) { bool dummy; - return LRUCache::get(path, dummy); + return MeshLoaderCache::get(path, dummy); } - FileStreamCache() : LRUCache(MTS_SERIALIZED_CACHE_SIZE, - &boost::make_shared) {} + FileStreamCache() : MeshLoaderCache(MTS_SERIALIZED_CACHE_SIZE, + &FileStreamCache::create) { } + + private: + inline static boost::shared_ptr create(const fs::path &path) { + return boost::make_shared(path); + } }; /// Release all currently held offset caches / file streams @@ -280,7 +289,7 @@ private: if (EXPECT_NOT_TAKEN(cache == NULL)) { cache = new FileStreamCache(); m_cache.set(cache); - SceneHandler::pushCleanupHandler(&SerializedMesh::flushCache); + mitsuba::pushSceneCleanupHandler(&SerializedMesh::flushCache); } boost::shared_ptr meshLoader = cache->get(filePath);