From d651ce4762734d784a4d36e9228ac0a9cb60b081 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Tue, 9 Sep 2008 06:16:42 +0200 Subject: [PATCH 1/2] clean up the mess with the inclusion of defsregistry.hpp, caused by the definition of DefsRegistry not being visible for DefsManager's dtor. --- src/common/singletonfactory.hpp | 2 +- src/proc/mobject/session/defsmanager.cpp | 7 +++++++ src/proc/mobject/session/defsmanager.hpp | 11 +++++++---- src/proc/mobject/session/session.cpp | 3 +-- src/proc/mobject/session/sessionimpl.hpp | 2 ++ src/proc/mobject/session/sessmanagerimpl.cpp | 2 +- 6 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/common/singletonfactory.hpp b/src/common/singletonfactory.hpp index 0065227df..0f6a12755 100644 --- a/src/common/singletonfactory.hpp +++ b/src/common/singletonfactory.hpp @@ -35,7 +35,7 @@ This code is heavily inspired by #define LUMIERA_SINGLETONFACTORY_H -#include "common/singletonpolicies.hpp" ///< several Policies usable together with SingletonFactory +#include "common/singletonpolicies.hpp" // several Policies usable together with SingletonFactory #include "common/util.hpp" #include "proc/nobugcfg.hpp" diff --git a/src/proc/mobject/session/defsmanager.cpp b/src/proc/mobject/session/defsmanager.cpp index b60e38064..383b1f60f 100644 --- a/src/proc/mobject/session/defsmanager.cpp +++ b/src/proc/mobject/session/defsmanager.cpp @@ -51,6 +51,13 @@ namespace mobject } + + /** @internal causes boost::checked_delete from \c scoped_ptr + * to be placed here, where the declaration of DefsRegistry is available.*/ + DefsManager::~DefsManager() {} + + + template P DefsManager::search (const Query& capabilities) diff --git a/src/proc/mobject/session/defsmanager.hpp b/src/proc/mobject/session/defsmanager.hpp index eb2ca1502..12bc039f8 100644 --- a/src/proc/mobject/session/defsmanager.hpp +++ b/src/proc/mobject/session/defsmanager.hpp @@ -33,14 +33,15 @@ -namespace mobject - { - namespace session - { +namespace mobject { + namespace session { + + using lumiera::P; using boost::scoped_ptr; class DefsRegistry; + class SessManagerImpl; /** @@ -63,6 +64,8 @@ namespace mobject friend class SessManagerImpl; public: + ~DefsManager (); + /** common access point: retrieve the default object fulfilling * some given conditions. May silently trigger object creation. * @throw error::Config in case no solution is possible, which diff --git a/src/proc/mobject/session/session.cpp b/src/proc/mobject/session/session.cpp index 5c4bb8592..d8d20ed4c 100644 --- a/src/proc/mobject/session/session.cpp +++ b/src/proc/mobject/session/session.cpp @@ -32,9 +32,8 @@ #include "proc/mobject/session.hpp" -#include "proc/mobject/session/sessionimpl.hpp" #include "proc/mobject/session/defsmanager.hpp" -#include "proc/mobject/session/defsregistry.hpp" +#include "proc/mobject/session/sessionimpl.hpp" #include "common/singleton.hpp" diff --git a/src/proc/mobject/session/sessionimpl.hpp b/src/proc/mobject/session/sessionimpl.hpp index 89e3c020a..a56fdb217 100644 --- a/src/proc/mobject/session/sessionimpl.hpp +++ b/src/proc/mobject/session/sessionimpl.hpp @@ -94,6 +94,8 @@ namespace mobject friend class lumiera::singleton::StaticCreate; public: + virtual ~SessManagerImpl() {} + virtual void clear () ; virtual void reset () ; virtual void load () ; diff --git a/src/proc/mobject/session/sessmanagerimpl.cpp b/src/proc/mobject/session/sessmanagerimpl.cpp index 8195e4fbe..7ac96bee4 100644 --- a/src/proc/mobject/session/sessmanagerimpl.cpp +++ b/src/proc/mobject/session/sessmanagerimpl.cpp @@ -39,7 +39,7 @@ #include "proc/mobject/session.hpp" #include "proc/mobject/session/sessionimpl.hpp" #include "proc/mobject/session/defsmanager.hpp" -#include "proc/mobject/session/defsregistry.hpp" +//#include "proc/mobject/session/defsregistry.hpp" #include "common/error.hpp" using boost::scoped_ptr; From a4f4496481b128483c103d2a1c2ce5ace95b76d5 Mon Sep 17 00:00:00 2001 From: Ichthyostega Date: Wed, 10 Sep 2008 04:42:09 +0200 Subject: [PATCH 2/2] placed DefsRegistry into an impl namespace --- src/proc/mobject/session/defsmanager.cpp | 7 ++-- src/proc/mobject/session/defsmanager.hpp | 5 +-- src/proc/mobject/session/defsregistry.hpp | 48 +++++++++++++++++------ 3 files changed, 40 insertions(+), 20 deletions(-) diff --git a/src/proc/mobject/session/defsmanager.cpp b/src/proc/mobject/session/defsmanager.cpp index 383b1f60f..538e8c9a8 100644 --- a/src/proc/mobject/session/defsmanager.cpp +++ b/src/proc/mobject/session/defsmanager.cpp @@ -35,10 +35,9 @@ using lumiera::query::QueryHandler; using lumiera::query::LUMIERA_ERROR_CAPABILITY_QUERY; -namespace mobject - { - namespace session - { +namespace mobject { + namespace session { + using lumiera::P; diff --git a/src/proc/mobject/session/defsmanager.hpp b/src/proc/mobject/session/defsmanager.hpp index 12bc039f8..276ed4c88 100644 --- a/src/proc/mobject/session/defsmanager.hpp +++ b/src/proc/mobject/session/defsmanager.hpp @@ -40,8 +40,7 @@ namespace mobject { using lumiera::P; using boost::scoped_ptr; - class DefsRegistry; - class SessManagerImpl; + namespace impl { class DefsRegistry; } /** @@ -56,7 +55,7 @@ namespace mobject { */ class DefsManager : private boost::noncopyable { - scoped_ptr defsRegistry; + scoped_ptr defsRegistry; protected: diff --git a/src/proc/mobject/session/defsregistry.hpp b/src/proc/mobject/session/defsregistry.hpp index 73925e11a..75068ec92 100644 --- a/src/proc/mobject/session/defsregistry.hpp +++ b/src/proc/mobject/session/defsregistry.hpp @@ -21,6 +21,21 @@ */ +/** @file defsregistry.hpp + ** A piece of implementation code factored out into a separate header (include). + ** Only used in defsmanager.cpp and for the unit tests. We can't place it into + ** a separate compilation unit, because defsmanager.cpp defines some explicit + ** template instantiaton, which cause the different Slots of the DefsrRegistry#table_ + ** to be filled with data and defaults for the specific Types. + ** + ** @see mobject::session::DefsManager + ** @see defsregistryimpltest.cpp + ** + */ + + + + #ifndef MOBJECT_SESSION_DEFSREGISTRY_H #define MOBJECT_SESSION_DEFSREGISTRY_H @@ -52,9 +67,14 @@ namespace mobject using boost::lambda::_1; using boost::lambda::var; - namespace // Implementation details //////////////////TODO better a named implementation namespace (avoids warnings on gcc 4.3) -//////////////////////////////////////////////////////////FIXME this is a *real* problem, because this namespace create storage, which it shouldn't - { + namespace impl { + + namespace { + uint maxSlots (0); ///< number of different registered Types + format dumpRecord ("%2i| %64s --> %s\n"); + } + + struct TableEntry { virtual ~TableEntry() {}; @@ -64,9 +84,6 @@ namespace mobject * for every participating kind of objects */ typedef std::vector< P > Table; - uint maxSlots (0); ///< number of different registered Types - - format dumpRecord ("%2i| %64s --> %s\n"); /** * holding a single "default object" entry @@ -83,13 +100,13 @@ namespace mobject query (q), objRef (obj) { } - + struct Search ///< Functor searching for a specific object { Search (const P& obj) : obj_(obj) { } - + const P& obj_; bool @@ -160,9 +177,9 @@ namespace mobject template size_t Slot::index (0); - } // (End) impl namespace - - + + + /** * @internal Helper for organizing preconfigured default objects. * Maintaines a collection of objects known or encountered as "default" @@ -315,9 +332,14 @@ namespace mobject return res; } }; - - + + + } // (End) impl namespace + + using impl::DefsRegistry; + + } // namespace mobject::session } // namespace mobject