Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r54520 - in sandbox/monotonic: boost/heterogenous libs/monotonic/test/clones
From: christian.schladetsch_at_[hidden]
Date: 2009-06-30 01:20:16


Author: cschladetsch
Date: 2009-06-30 01:20:16 EDT (Tue, 30 Jun 2009)
New Revision: 54520
URL: http://svn.boost.org/trac/boost/changeset/54520

Log:
renamed base to cloneable

Added:
   sandbox/monotonic/boost/heterogenous/cloneable.hpp
      - copied unchanged from r54519, /sandbox/monotonic/boost/heterogenous/base.hpp
Removed:
   sandbox/monotonic/boost/heterogenous/base.hpp
Text files modified:
   sandbox/monotonic/boost/heterogenous/forward_declarations.hpp | 10 ++++++++++
   sandbox/monotonic/libs/monotonic/test/clones/clones.vcproj | 2 +-
   2 files changed, 11 insertions(+), 1 deletions(-)

Deleted: sandbox/monotonic/boost/heterogenous/base.hpp
==============================================================================
--- sandbox/monotonic/boost/heterogenous/base.hpp 2009-06-30 01:20:16 EDT (Tue, 30 Jun 2009)
+++ (empty file)
@@ -1,75 +0,0 @@
-// Copyright (C) 2009 Christian Schladetsch
-//
-// Distributed under 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)
-
-#ifndef BOOST_HETEROGENOUS_BASE_HPP
-#define BOOST_HETEROGENOUS_BASE_HPP
-
-#include <boost/aligned_storage.hpp>
-#include <boost/heterogenous/detail/prefix.hpp>
-#include <boost/heterogenous/abstract_base.hpp>
-
-namespace boost
-{
- namespace heterogenous
- {
- /// base for the given derived type, using the given base class
- /// TODO: rename this - perhaps to 'cloneable'?
- template <class Derived, class Base, class AbstractBase>
- struct cloneable : AbstractBase
- {
- typedef Derived derived_type;
- typedef Base base_type;
- typedef AbstractBase abstract_base_type;
- typedef cloneable<Derived, Base, AbstractBase> this_type;
-
- private:
- static size_t alignment; ///< required alignment for allocation
- mutable derived_type *self_ptr; ///< pointer to derived object in this
-
- public:
- cloneable() : self_ptr(0) { }
-
- virtual this_type *allocate(abstract_allocator &alloc) const
- {
- abstract_allocator::pointer bytes = alloc.allocate_bytes(sizeof(derived_type), alignment);
- Derived *ptr = reinterpret_cast<Derived *>(bytes);
- ptr->this_type::self_ptr = ptr;
- return ptr;
- }
-
- void deallocate(base_type &object, abstract_allocator &alloc) const
- {
- Derived *ptr = static_cast<Derived *>(&object);
- alloc.deallocate_bytes(reinterpret_cast<abstract_allocator::pointer>(ptr), alignment);
- }
-
- virtual this_type *create_new(abstract_allocator &alloc) const
- {
- this_type *ptr = allocate(alloc);
- new (ptr->self_ptr) Derived();
- return ptr;
- }
-
- virtual this_type *copy_construct(const base_type &original, abstract_allocator &alloc) const
- {
- this_type *ptr = allocate(alloc);
- new (ptr->self_ptr) Derived(static_cast<const Derived &>(original));
- return ptr;
- }
- };
-
- /// ensure correct alignment when allocating derived instances
- template <class Derived, class Base, class AbstractBase>
- size_t cloneable<Derived, Base, AbstractBase>::alignment = aligned_storage<sizeof(Derived)>::alignment;
-
- } // namespace heterogenous
-
-} // namespace boost
-
-#include <boost/heterogenous/detail/suffix.hpp>
-
-#endif // BOOST_HETEROGENOUS_BASE_HPP
-
-//EOF

Modified: sandbox/monotonic/boost/heterogenous/forward_declarations.hpp
==============================================================================
--- sandbox/monotonic/boost/heterogenous/forward_declarations.hpp (original)
+++ sandbox/monotonic/boost/heterogenous/forward_declarations.hpp 2009-06-30 01:20:16 EDT (Tue, 30 Jun 2009)
@@ -7,6 +7,7 @@
 #define BOOST_HETEROGENOUS_FORWARD_DECLARATIONS_HPP
 
 #include <functional>
+// including monotonic/allocator.hpp is temporary; not needed after make_clone_allocator works properly
 #include <boost/monotonic/allocator.hpp>
 #include <boost/heterogenous/detail/prefix.hpp>
 
@@ -14,13 +15,20 @@
 {
         namespace heterogenous
         {
+ /// an abstract interface for an allocator that can allocate and de-allocate
+ /// byte sequences
                 struct abstract_allocator;
 
+ /// empty structure with a virtual destructor used if the user does not
+ /// wish to use a custom base type
                 struct default_base_type;
 
+ /// provides a set of pure-virtual methods for allocation, de-allocation, and cloning
                 template <class Base>
                 struct abstract_base;
 
+ /// a structure derived from this, with type Derived, is correctly
+ /// cloneable from a base pointer, given an abstract_allocator.
                 template <
                         class Derived
                         , class Base = default_base_type
@@ -37,12 +45,14 @@
                         , class AbstractBase = abstract_base<Base> >
                 struct adaptor;
 
+ /// a heterogenous vector of objects
                 template <
                         class Base = default_base_type
                         , class Alloc = monotonic::allocator<int>
                         , class AbstractBase = abstract_base<Base> >
                 struct vector;
 
+ /// a mapping of heterogenous objects to heterogenous objects
                 template <
                         class Base = default_base_type
                         , class Pred = std::less<Base>

Modified: sandbox/monotonic/libs/monotonic/test/clones/clones.vcproj
==============================================================================
--- sandbox/monotonic/libs/monotonic/test/clones/clones.vcproj (original)
+++ sandbox/monotonic/libs/monotonic/test/clones/clones.vcproj 2009-06-30 01:20:16 EDT (Tue, 30 Jun 2009)
@@ -373,7 +373,7 @@
>
                                 </File>
                                 <File
- RelativePath="..\..\..\..\boost\heterogenous\base.hpp"
+ RelativePath="..\..\..\..\boost\heterogenous\cloneable.hpp"
>
                                 </File>
                                 <File


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