|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r54624 - in sandbox/cloneable: boost/cloneable boost/cloneable/detail libs/cloneable/test
From: christian.schladetsch_at_[hidden]
Date: 2009-07-03 21:49:22
Author: cschladetsch
Date: 2009-07-03 21:49:21 EDT (Fri, 03 Jul 2009)
New Revision: 54624
URL: http://svn.boost.org/trac/boost/changeset/54624
Log:
renamed detail::is_derived to detail::mixin
Added:
sandbox/cloneable/boost/cloneable/detail/mixin.hpp
- copied, changed from r54623, /sandbox/cloneable/boost/cloneable/detail/is_derived.hpp
Removed:
sandbox/cloneable/boost/cloneable/detail/is_derived.hpp
Text files modified:
sandbox/cloneable/boost/cloneable/base.hpp | 4 ++--
sandbox/cloneable/boost/cloneable/detail/mixin.hpp | 12 ++++++------
sandbox/cloneable/boost/cloneable/instance.hpp | 2 +-
sandbox/cloneable/libs/cloneable/test/cloneable.vcproj | 4 ++--
4 files changed, 11 insertions(+), 11 deletions(-)
Modified: sandbox/cloneable/boost/cloneable/base.hpp
==============================================================================
--- sandbox/cloneable/boost/cloneable/base.hpp (original)
+++ sandbox/cloneable/boost/cloneable/base.hpp 2009-07-03 21:49:21 EDT (Fri, 03 Jul 2009)
@@ -8,7 +8,7 @@
#include <boost/aligned_storage.hpp>
#include <boost/cloneable/detail/prefix.hpp>
-#include <boost/cloneable/detail/is_derived.hpp>
+#include <boost/cloneable/detail/mixin.hpp>
#include <boost/cloneable/detail/create_new.hpp>
namespace boost
@@ -23,7 +23,7 @@
template <class Derived, class Base, class DefaultCtorTag>
struct base
- : detail::is_derived<Derived, Base>
+ : detail::mixin<Derived, Base>
, virtual is_cloneable_tag
, virtual DefaultCtorTag
{
Deleted: sandbox/cloneable/boost/cloneable/detail/is_derived.hpp
==============================================================================
--- sandbox/cloneable/boost/cloneable/detail/is_derived.hpp 2009-07-03 21:49:21 EDT (Fri, 03 Jul 2009)
+++ (empty file)
@@ -1,121 +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_CLONEABLE_IS_DERIVED_HPP
-#define BOOST_CLONEABLE_IS_DERIVED_HPP
-
-#include <boost/aligned_storage.hpp>
-#include <boost/cloneable/detail/prefix.hpp>
-#include <boost/cloneable/abstract_base.hpp>
-
-namespace boost
-{
- namespace cloneable
- {
- namespace detail
- {
- // mixin structure between base<> and abstract_base<> that supplies
- // an interface to allow casting, cloning and creation of sub-objects
- // of different types and default-constructableness
- template <class Derived, class Base>
- struct is_derived
- : abstract_base<Base>
- {
- typedef Derived derived_type;
- typedef Base base_type;
- typedef abstract_base<base_type> abstract_base_type;
- typedef is_derived<derived_type, base_type> this_type;
-
- mutable Derived *self_ptr; ///< pointer to derived object in this
- static const size_t alignment; ///< required alignment for allocation
-
- is_derived()
- {
- self_ptr = static_cast<derived_type *>(this);
- }
-
- const std::type_info &get_type() const
- {
- return typeid(derived_type);
- }
-
- 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(abstract_allocator &alloc)
- {
- Derived *ptr = self_ptr;
- alloc.deallocate_bytes(reinterpret_cast<abstract_allocator::pointer>(ptr), alignment);
- }
-
- virtual this_type *copy_construct(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;
- new (ptr->this_type::self_ptr) Derived(static_cast<const Derived &>(*this));
- return ptr;
- }
- /// for use with types that use multiple inheritance - select which sub-object to clone.
- /// can also be used when there is just one cloneable sub-object to avoid having to
- /// dynamic cast the result.
- template <class Ty>
- Ty *clone_as(abstract_allocator &alloc) const
- {
- const is_derived<Ty,Base> *ptr = dynamic_cast<const is_derived<Ty,Base> *>(this);
- if (ptr == 0)
- throw std::bad_cast();
- abstract_base_type *cloned = ptr->clone(alloc);
- return dynamic_cast<Ty *>(cloned);
- }
-
- /// make a copy of this instance using default allocator,
- /// selecting sub-object to clone
- template <class Ty>
- Ty *clone_as() const
- {
- make_clone_allocator<default_allocator>::type alloc;
- return clone_as<Ty>(alloc);
- }
-
- template <class Ty>
- Ty *create_as(abstract_allocator &alloc) const
- {
- typedef is_derived<Ty, Base> Embedded;
- const Embedded *cross_cast = dynamic_cast<const Embedded *>(this);
- if (cross_cast == 0)
- throw std::bad_cast();
- abstract_base_type *base = cross_cast->create_new(alloc);
- return static_cast<Ty *>(static_cast<Embedded *>(base));
- }
-
- template <class Ty>
- Ty *create_as() const
- {
- make_clone_allocator<default_allocator>::type alloc;
- return create_as<Ty>(alloc);
- }
- };
-
- /// ensure correct alignment when allocating derived instances
- template <class Derived, class Base>
- const size_t is_derived<Derived, Base>::alignment = aligned_storage<sizeof(Derived)>::alignment;
-
- } // namespace detail
-
- } // namespace cloneable
-
-} // namespace boost
-
-#include <boost/cloneable/detail/suffix.hpp>
-
-#endif // BOOST_CLONEABLE_IS_DERIVED_HPP
-
-//EOF
Copied: sandbox/cloneable/boost/cloneable/detail/mixin.hpp (from r54623, /sandbox/cloneable/boost/cloneable/detail/is_derived.hpp)
==============================================================================
--- /sandbox/cloneable/boost/cloneable/detail/is_derived.hpp (original)
+++ sandbox/cloneable/boost/cloneable/detail/mixin.hpp 2009-07-03 21:49:21 EDT (Fri, 03 Jul 2009)
@@ -20,18 +20,18 @@
// an interface to allow casting, cloning and creation of sub-objects
// of different types and default-constructableness
template <class Derived, class Base>
- struct is_derived
+ struct mixin
: abstract_base<Base>
{
typedef Derived derived_type;
typedef Base base_type;
typedef abstract_base<base_type> abstract_base_type;
- typedef is_derived<derived_type, base_type> this_type;
+ typedef mixin<derived_type, base_type> this_type;
mutable Derived *self_ptr; ///< pointer to derived object in this
static const size_t alignment; ///< required alignment for allocation
- is_derived()
+ mixin()
{
self_ptr = static_cast<derived_type *>(this);
}
@@ -69,7 +69,7 @@
template <class Ty>
Ty *clone_as(abstract_allocator &alloc) const
{
- const is_derived<Ty,Base> *ptr = dynamic_cast<const is_derived<Ty,Base> *>(this);
+ const mixin<Ty,Base> *ptr = dynamic_cast<const mixin<Ty,Base> *>(this);
if (ptr == 0)
throw std::bad_cast();
abstract_base_type *cloned = ptr->clone(alloc);
@@ -88,7 +88,7 @@
template <class Ty>
Ty *create_as(abstract_allocator &alloc) const
{
- typedef is_derived<Ty, Base> Embedded;
+ typedef mixin<Ty, Base> Embedded;
const Embedded *cross_cast = dynamic_cast<const Embedded *>(this);
if (cross_cast == 0)
throw std::bad_cast();
@@ -106,7 +106,7 @@
/// ensure correct alignment when allocating derived instances
template <class Derived, class Base>
- const size_t is_derived<Derived, Base>::alignment = aligned_storage<sizeof(Derived)>::alignment;
+ const size_t mixin<Derived, Base>::alignment = aligned_storage<sizeof(Derived)>::alignment;
} // namespace detail
Modified: sandbox/cloneable/boost/cloneable/instance.hpp
==============================================================================
--- sandbox/cloneable/boost/cloneable/instance.hpp (original)
+++ sandbox/cloneable/boost/cloneable/instance.hpp 2009-07-03 21:49:21 EDT (Fri, 03 Jul 2009)
@@ -58,7 +58,7 @@
typedef Abstract abstract_type;
typedef Derived derived_type;
- typedef detail::is_derived<derived_type, base_type> is_derived_type;
+ typedef detail::mixin<derived_type, base_type> is_derived_type;
protected:
derived_type *ptr;
Modified: sandbox/cloneable/libs/cloneable/test/cloneable.vcproj
==============================================================================
--- sandbox/cloneable/libs/cloneable/test/cloneable.vcproj (original)
+++ sandbox/cloneable/libs/cloneable/test/cloneable.vcproj 2009-07-03 21:49:21 EDT (Fri, 03 Jul 2009)
@@ -300,11 +300,11 @@
>
</File>
<File
- RelativePath="..\..\..\boost\cloneable\detail\is_derived.hpp"
+ RelativePath="..\..\..\boost\cloneable\detail\make_clone_allocator.hpp"
>
</File>
<File
- RelativePath="..\..\..\boost\cloneable\detail\make_clone_allocator.hpp"
+ RelativePath="..\..\..\boost\cloneable\detail\mixin.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