$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r77998 - trunk/tools/quickbook/src
From: dnljms_at_[hidden]
Date: 2012-04-15 16:02:33
Author: danieljames
Date: 2012-04-15 16:02:32 EDT (Sun, 15 Apr 2012)
New Revision: 77998
URL: http://svn.boost.org/trac/boost/changeset/77998
Log:
Quickbook: Remove intrusive_base. Refs #6794.
Removed:
   trunk/tools/quickbook/src/intrusive_base.hpp
Text files modified: 
   trunk/tools/quickbook/src/files.hpp      |    22 +++++++++--                             
   trunk/tools/quickbook/src/id_manager.cpp |    70 ++++++++++++++++++++------------------- 
   2 files changed, 53 insertions(+), 39 deletions(-)
Modified: trunk/tools/quickbook/src/files.hpp
==============================================================================
--- trunk/tools/quickbook/src/files.hpp	(original)
+++ trunk/tools/quickbook/src/files.hpp	2012-04-15 16:02:32 EDT (Sun, 15 Apr 2012)
@@ -16,7 +16,6 @@
 #include <boost/intrusive_ptr.hpp>
 #include <stdexcept>
 #include <cassert>
-#include "intrusive_base.hpp"
 
 namespace quickbook {
 
@@ -34,27 +33,35 @@
         int column;
     };
 
-    struct file : intrusive_base<file>
+    struct file
     {
+    private:
+        // Non copyable
+        file& operator=(file const&);
+        file(file const&);
+    public:
         fs::path const path;
         std::string source;
         bool is_code_snippets;
     private:
         unsigned qbk_version;
+        unsigned ref_count;
     public:
 
         file(fs::path const& path, std::string const& source,
                 unsigned qbk_version) :
             path(path), source(source), is_code_snippets(false),
-            qbk_version(qbk_version)
+            qbk_version(qbk_version), ref_count(0)
         {}
 
         file(file const& f, std::string const& source) :
             path(f.path), source(source), is_code_snippets(f.is_code_snippets),
-            qbk_version(f.qbk_version)
+            qbk_version(f.qbk_version), ref_count(0)
         {}
 
-        virtual ~file() {}
+        virtual ~file() {
+            assert(!ref_count);
+        }
 
         unsigned version() const {
             assert(qbk_version);
@@ -70,6 +77,11 @@
         }
 
         virtual file_position position_of(std::string::const_iterator) const;
+
+        friend void intrusive_ptr_add_ref(file* ptr) { ++ptr->ref_count; }
+
+        friend void intrusive_ptr_release(file* ptr)
+            { if(--ptr->ref_count == 0) delete ptr; }
     };
 
     // If version isn't supplied then it must be set later.
Modified: trunk/tools/quickbook/src/id_manager.cpp
==============================================================================
--- trunk/tools/quickbook/src/id_manager.cpp	(original)
+++ trunk/tools/quickbook/src/id_manager.cpp	2012-04-15 16:02:32 EDT (Sun, 15 Apr 2012)
@@ -9,8 +9,7 @@
 #include "id_manager.hpp"
 #include "utils.hpp"
 #include "string_ref.hpp"
-#include "intrusive_base.hpp"
-#include <boost/intrusive_ptr.hpp>
+#include <boost/make_shared.hpp>
 #include <boost/unordered_map.hpp>
 #include <boost/lexical_cast.hpp>
 #include <boost/range/algorithm.hpp>
@@ -113,7 +112,7 @@
 
     struct id_state
     {
-        boost::intrusive_ptr<file_info> current_file;
+        boost::shared_ptr<file_info> current_file;
         std::deque<id_placeholder> placeholders;
 
         // Placeholder methods
@@ -149,25 +148,25 @@
         id_placeholder* add_id_to_section(
                 std::string const& id,
                 id_category category,
-                boost::intrusive_ptr<section_info> const& section);
+                boost::shared_ptr<section_info> const& section);
         id_placeholder* create_new_section(
                 std::string const& id,
                 id_category category);
 
         void switch_section(id_placeholder*);
-        void reswitch_sections(boost::intrusive_ptr<section_info> const&,
-            boost::intrusive_ptr<section_info> const&);
+        void reswitch_sections(boost::shared_ptr<section_info> const&,
+            boost::shared_ptr<section_info> const&);
         void restore_section();
     };
 
-    struct file_info : intrusive_base<file_info>
+    struct file_info
     {
-        boost::intrusive_ptr<file_info> parent;
-        boost::intrusive_ptr<doc_info> document;
+        boost::shared_ptr<file_info> parent;
+        boost::shared_ptr<doc_info> document;
 
         bool document_root; // !parent || document != parent->document
         unsigned compatibility_version;
-        boost::intrusive_ptr<section_info> switched_section;
+        boost::shared_ptr<section_info> switched_section;
         id_placeholder* original_placeholder;
 
         // The 1.1-1.5 document id would actually change per file due to
@@ -175,15 +174,15 @@
         // document title instead of the id.
         std::string doc_id_1_1;
 
-        file_info(boost::intrusive_ptr<file_info> const& parent,
+        file_info(boost::shared_ptr<file_info> const& parent,
                 unsigned compatibility_version) :
             parent(parent), document(parent->document), document_root(false),
             compatibility_version(compatibility_version),
             switched_section(), original_placeholder()
         {}
 
-        file_info(boost::intrusive_ptr<file_info> const& parent,
-                boost::intrusive_ptr<doc_info> const& document,
+        file_info(boost::shared_ptr<file_info> const& parent,
+                boost::shared_ptr<doc_info> const& document,
                 unsigned compatibility_version) :
             parent(parent), document(document), document_root(true),
             compatibility_version(compatibility_version),
@@ -191,9 +190,9 @@
         {}
     };
 
-    struct doc_info : intrusive_base<doc_info>
+    struct doc_info
     {
-        boost::intrusive_ptr<section_info> current_section;
+        boost::shared_ptr<section_info> current_section;
         std::string last_title_1_1;
         std::string section_id_1_1;
 
@@ -202,15 +201,15 @@
         {}
     };
 
-    struct section_info : intrusive_base<section_info>
+    struct section_info
     {
-        boost::intrusive_ptr<section_info> parent;
+        boost::shared_ptr<section_info> parent;
         unsigned compatibility_version;
         unsigned level;
         std::string id_1_1;
         id_placeholder* placeholder_1_6;
 
-        section_info(boost::intrusive_ptr<section_info> const& parent,
+        section_info(boost::shared_ptr<section_info> const& parent,
                 unsigned compatibility_version, std::string const& id) :
             parent(parent), compatibility_version(compatibility_version),
             level(parent ? parent->level + 1 : 1),
@@ -394,11 +393,11 @@
     }
 
     void id_state::reswitch_sections(
-        boost::intrusive_ptr<section_info> const& popped_section,
-        boost::intrusive_ptr<section_info> const& parent_section)
+        boost::shared_ptr<section_info> const& popped_section,
+        boost::shared_ptr<section_info> const& parent_section)
     {
-        boost::intrusive_ptr<file_info> file = current_file;
-        boost::intrusive_ptr<file_info> first_switched_file;
+        boost::shared_ptr<file_info> file = current_file;
+        boost::shared_ptr<file_info> first_switched_file;
 
         for (;;) {
             if (file->switched_section == popped_section)
@@ -436,15 +435,16 @@
     {
         // Create new file
 
-        boost::intrusive_ptr<file_info> parent = current_file;
+        boost::shared_ptr<file_info> parent = current_file;
 
         if (document_root) {
-            current_file = new file_info(parent, new doc_info(),
+            current_file = boost::make_shared<file_info>(parent,
+                    boost::make_shared<doc_info>(),
                     compatibility_version);
         }
         else {
             current_file =
-                new file_info(parent, compatibility_version);
+                boost::make_shared<file_info>(parent, compatibility_version);
         }
 
         // Choose specified id to use. Prefer 'include_doc_id' (the id
@@ -505,7 +505,7 @@
             if (compatibility_version >= 106u && !initial_doc_id.empty()) {
                 switch_section(add_id_to_section(initial_doc_id,
                     id_category::explicit_section_id,
-                    boost::intrusive_ptr<section_info>()));
+                    boost::shared_ptr<section_info>()));
             }
 
             return 0;
@@ -529,7 +529,7 @@
     id_placeholder* id_state::add_id_to_section(
             std::string const& id,
             id_category category,
-            boost::intrusive_ptr<section_info> const& section)
+            boost::shared_ptr<section_info> const& section)
     {
         std::string id_part = id;
 
@@ -583,11 +583,12 @@
             std::string const& id,
             id_category category)
     {
-        boost::intrusive_ptr<section_info> parent =
+        boost::shared_ptr<section_info> parent =
             current_file->document->current_section;
 
-        boost::intrusive_ptr<section_info> new_section =
-            new section_info(parent, current_file->compatibility_version, id);
+        boost::shared_ptr<section_info> new_section =
+            boost::make_shared<section_info>(parent,
+                current_file->compatibility_version, id);
 
         id_placeholder* p;
 
@@ -630,7 +631,7 @@
 
     void id_state::end_section()
     {
-        boost::intrusive_ptr<section_info> popped_section =
+        boost::shared_ptr<section_info> popped_section =
             current_file->document->current_section;
         current_file->document->current_section = popped_section->parent;
 
@@ -810,7 +811,7 @@
     // Data used for generating placeholders that have duplicates.
     //
 
-    struct id_generation_data : intrusive_base<id_generation_data>
+    struct id_generation_data
     {
         id_generation_data(std::string const& src_id)
           : child_start(src_id.rfind('.') + 1),
@@ -865,7 +866,7 @@
         id_category category;   // The highest priority category of the
                                 // placeholders that want to use this id.
         bool used;              // Whether this id has been used.
-        boost::intrusive_ptr<id_generation_data> generation_data;
+        boost::shared_ptr<id_generation_data> generation_data;
                                 // If a duplicates are found, this is
                                 // created to generate new ids.
                                 //
@@ -1036,7 +1037,8 @@
 
         if (!p.data->generation_data)
         {
-            p.data->generation_data.reset(new id_generation_data(p.id));
+            p.data->generation_data =
+                boost::make_shared<id_generation_data>(p.id);
             register_generation_data(p, ids);
         }
 
Deleted: trunk/tools/quickbook/src/intrusive_base.hpp
==============================================================================
--- trunk/tools/quickbook/src/intrusive_base.hpp	2012-04-15 16:02:32 EDT (Sun, 15 Apr 2012)
+++ (empty file)
@@ -1,36 +0,0 @@
-/*=============================================================================
-    Copyright (c) 2011 Daniel James
-
-    Use, modification and distribution is subject to the Boost Software
-    License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
-    http://www.boost.org/LICENSE_1_0.txt)
-=============================================================================*/
-
-#if !defined(BOOST_QUICKBOOK_INTRUSIVE_BASE_HPP)
-#define BOOST_QUICKBOOK_INTRUSIVE_BASE_HPP
-
-namespace quickbook
-{
-    //
-    // instructive_base
-    //
-
-    template <typename T>
-    struct intrusive_base
-    {
-        intrusive_base() : ref_count_(0) {}
-        intrusive_base(intrusive_base const&) : ref_count_(0) {}
-        intrusive_base& operator=(intrusive_base const&) { return *this; }
-        ~intrusive_base() { assert(!ref_count_); }
-
-        friend void intrusive_ptr_add_ref(T* ptr)
-            { ++ptr->ref_count_; }
-
-        friend void intrusive_ptr_release(T* ptr)
-            { if(--ptr->ref_count_ == 0) delete ptr; }
-    private:
-        unsigned ref_count_;
-    };
-}
-
-#endif