Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52179 - sandbox/pinhole/boost/pinhole
From: jmcintyre_at_[hidden]
Date: 2009-04-04 19:30:09


Author: jared
Date: 2009-04-04 19:30:08 EDT (Sat, 04 Apr 2009)
New Revision: 52179
URL: http://svn.boost.org/trac/boost/changeset/52179

Log:
Pinhole property_manager now has a protected destructor (new workaround for gcc)
Text files modified:
   sandbox/pinhole/boost/pinhole/property_manager.hpp | 74 ++++++++++++++++++---------------------
   1 files changed, 35 insertions(+), 39 deletions(-)

Modified: sandbox/pinhole/boost/pinhole/property_manager.hpp
==============================================================================
--- sandbox/pinhole/boost/pinhole/property_manager.hpp (original)
+++ sandbox/pinhole/boost/pinhole/property_manager.hpp 2009-04-04 19:30:08 EDT (Sat, 04 Apr 2009)
@@ -46,15 +46,6 @@
             return instance.get(); // address of sole instance
         }
         
- #if defined(BOOST_MSVC)
- #pragma warning(push)
- #pragma warning( disable: 4251 )
- #endif
- boost::signal<void(property_group*)> add_event;
- boost::signal<void(property_group*)> remove_event;
- #if defined(BOOST_MSVC)
- #pragma warning(pop)
- #endif
         void raise_on_add_event( property_group *group )
         {
             add_event( group );
@@ -65,6 +56,16 @@
             remove_event( group );
         }
         
+ #if defined(BOOST_MSVC)
+ #pragma warning(push)
+ #pragma warning( disable: 4251 )
+ #endif
+ boost::signal<void(property_group*)> add_event;
+ boost::signal<void(property_group*)> remove_event;
+ #if defined(BOOST_MSVC)
+ #pragma warning(pop)
+ #endif
+
     private :
         
         event_source(){};
@@ -75,14 +76,6 @@
     {
     public:
         typedef std::tr1::shared_ptr<property_manager> instance_type;
-
- private:
- static void deleter(property_manager* manager)
- {
- delete manager;
- }
-
- public:
         typedef std::multimap<std::string, property_group*> category_to_property_group_map;
         typedef map_value_iterator<category_to_property_group_map::iterator> iterator;
         typedef map_value_iterator<category_to_property_group_map::const_iterator> const_iterator;
@@ -106,25 +99,7 @@
         {
             internal_instance().reset();
         }
-
- protected:
- property_manager(){;}
-
- // TODO: This needs to be protected so no-one will deal with it, but
- // checked_delete can't be made a friend in gcc, so I can't shared_ptr
- // to work.
- public:
- virtual ~property_manager()
- {
- category_to_property_group_map::iterator itr = m_property_group_collection.begin();
- category_to_property_group_map::iterator itr_end = m_property_group_collection.end();
- for( ; itr != itr_end; ++itr )
- {
- event_source::instance()->raise_on_remove_event((*itr).second);
- }
- }
-
- public:
+
         /**
          * Retrieves an iterator pointing to the first property group.
          */
@@ -218,11 +193,22 @@
 
     protected:
         
+ property_manager(){;}
+
+ virtual ~property_manager()
+ {
+ category_to_property_group_map::iterator itr = m_property_group_collection.begin();
+ category_to_property_group_map::iterator itr_end = m_property_group_collection.end();
+ for( ; itr != itr_end; ++itr )
+ {
+ event_source::instance()->raise_on_remove_event((*itr).second);
+ }
+ }
+
         /** Provides direct access to the shared_ptr that owns the property_manager singleton. */
         static boost::shared_ptr<boost::pinhole::property_manager>& internal_instance()
         {
- static boost::shared_ptr<boost::pinhole::property_manager>
- instance(new boost::pinhole::property_manager);
+ static boost::shared_ptr<boost::pinhole::property_manager> instance;
             
             return instance;
         }
@@ -285,8 +271,18 @@
         #if defined(BOOST_MSVC)
             #pragma warning(pop)
         #endif
+
+ private:
+
+ // This allows us make the destructor protected. I can't make checked_delete a friend
+ // in gcc, so shared_ptr couldn't access the desctructor directly.
+ static void deleter(property_manager* manager)
+ {
+ delete manager;
+ }
+
             
- friend class property_group;
+ friend class boost::pinhole::property_group;
     };
 }}
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk