|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r54521 - in sandbox/monotonic: boost/heterogenous libs/monotonic/test/clones
From: christian.schladetsch_at_[hidden]
Date: 2009-06-30 01:27:15
Author: cschladetsch
Date: 2009-06-30 01:27:14 EDT (Tue, 30 Jun 2009)
New Revision: 54521
URL: http://svn.boost.org/trac/boost/changeset/54521
Log:
renamed abstract_base to abstract_cloneable
Added:
sandbox/monotonic/boost/heterogenous/abstract_cloneable.hpp
- copied, changed from r54517, /sandbox/monotonic/boost/heterogenous/abstract_base.hpp
Removed:
sandbox/monotonic/boost/heterogenous/abstract_base.hpp
Text files modified:
sandbox/monotonic/boost/heterogenous/abstract_cloneable.hpp | 20 ++++++++++++--------
sandbox/monotonic/boost/heterogenous/adaptor.hpp | 2 +-
sandbox/monotonic/boost/heterogenous/cloneable.hpp | 1 -
sandbox/monotonic/boost/heterogenous/forward_declarations.hpp | 10 +++++-----
sandbox/monotonic/boost/heterogenous/map.hpp | 1 -
sandbox/monotonic/boost/heterogenous/vector.hpp | 2 +-
sandbox/monotonic/libs/monotonic/test/clones/clones.vcproj | 2 +-
7 files changed, 20 insertions(+), 18 deletions(-)
Deleted: sandbox/monotonic/boost/heterogenous/abstract_base.hpp
==============================================================================
--- sandbox/monotonic/boost/heterogenous/abstract_base.hpp 2009-06-30 01:27:14 EDT (Tue, 30 Jun 2009)
+++ (empty file)
@@ -1,51 +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_COMMON_BASE_HPP
-#define BOOST_HETEROGENOUS_COMMON_BASE_HPP
-
-#include <boost/heterogenous/detail/prefix.hpp>
-#include <boost/heterogenous/abstract_allocator.hpp>
-
-namespace boost
-{
- namespace heterogenous
- {
- struct default_base_type
- {
- virtual ~default_base_type() { }
- };
-
- /// common base for all base types for hierachies
- template <class Base>
- struct abstract_base : Base
- {
- typedef Base base_type;
- typedef abstract_base<Base> this_type;
-
- //virtual base_type *allocate(abstract_allocator &alloc) const /*= 0;*/ { return 0; }
- //virtual void deallocate(base_type *, abstract_allocator &alloc) const /*= 0;*/ { }
- //virtual base_type *create(abstract_allocator &alloc) const /*= 0;*/ { return 0; }
- //virtual base_type *copy_construct(const base_type &original, abstract_allocator &alloc) const /*= 0;*/ { return 0; }
-
- virtual this_type *allocate(abstract_allocator &alloc) const = 0;
- virtual void deallocate(base_type &, abstract_allocator &alloc) const = 0;
-
- virtual this_type *create_new(abstract_allocator &alloc) const = 0;
- virtual this_type *copy_construct(const base_type &original, abstract_allocator &alloc) const = 0;
-
- /// optional means to make a clone that does not use copy-construction
- virtual this_type *clone(const base_type &original, abstract_allocator &alloc) const { return 0; }
- };
-
- } // namespace heterogenous
-
-} // namespace boost
-
-#include <boost/heterogenous/detail/suffix.hpp>
-
-#endif // BOOST_HETEROGENOUS_COMMON_BASE_HPP
-
-//EOF
Copied: sandbox/monotonic/boost/heterogenous/abstract_cloneable.hpp (from r54517, /sandbox/monotonic/boost/heterogenous/abstract_base.hpp)
==============================================================================
--- /sandbox/monotonic/boost/heterogenous/abstract_base.hpp (original)
+++ sandbox/monotonic/boost/heterogenous/abstract_cloneable.hpp 2009-06-30 01:27:14 EDT (Tue, 30 Jun 2009)
@@ -18,17 +18,12 @@
virtual ~default_base_type() { }
};
- /// common base for all base types for hierachies
+ /// TODO: rename this to abstract_cloneable
template <class Base>
- struct abstract_base : Base
+ struct abstract_cloneable : Base
{
typedef Base base_type;
- typedef abstract_base<Base> this_type;
-
- //virtual base_type *allocate(abstract_allocator &alloc) const /*= 0;*/ { return 0; }
- //virtual void deallocate(base_type *, abstract_allocator &alloc) const /*= 0;*/ { }
- //virtual base_type *create(abstract_allocator &alloc) const /*= 0;*/ { return 0; }
- //virtual base_type *copy_construct(const base_type &original, abstract_allocator &alloc) const /*= 0;*/ { return 0; }
+ typedef abstract_cloneable<Base> this_type;
virtual this_type *allocate(abstract_allocator &alloc) const = 0;
virtual void deallocate(base_type &, abstract_allocator &alloc) const = 0;
@@ -38,6 +33,15 @@
/// optional means to make a clone that does not use copy-construction
virtual this_type *clone(const base_type &original, abstract_allocator &alloc) const { return 0; }
+
+ /// make a copy of the given instance. try the custom overload first, then default to using
+ /// the copy-constructor
+ this_type *make_copy(const base_type &original, abstract_allocator &alloc) const
+ {
+ if (this_type *copy = clone(original, alloc))
+ return copy;
+ return copy_construct(original, alloc);
+ }
};
} // namespace heterogenous
Modified: sandbox/monotonic/boost/heterogenous/adaptor.hpp
==============================================================================
--- sandbox/monotonic/boost/heterogenous/adaptor.hpp (original)
+++ sandbox/monotonic/boost/heterogenous/adaptor.hpp 2009-06-30 01:27:14 EDT (Tue, 30 Jun 2009)
@@ -7,7 +7,7 @@
#define BOOST_HETEROGENOUS_ADAPTOR_HPP
#include <boost/heterogenous/detail/prefix.hpp>
-#include <boost/heterogenous/base.hpp>
+#include <boost/heterogenous/cloneable.hpp>
namespace boost
{
Modified: sandbox/monotonic/boost/heterogenous/cloneable.hpp
==============================================================================
--- sandbox/monotonic/boost/heterogenous/cloneable.hpp (original)
+++ sandbox/monotonic/boost/heterogenous/cloneable.hpp 2009-06-30 01:27:14 EDT (Tue, 30 Jun 2009)
@@ -15,7 +15,6 @@
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
{
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:27:14 EDT (Tue, 30 Jun 2009)
@@ -25,14 +25,14 @@
/// provides a set of pure-virtual methods for allocation, de-allocation, and cloning
template <class Base>
- struct abstract_base;
+ struct abstract_cloneable;
/// 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
- , class AbstractBase = abstract_base<Base> >
+ , class AbstractBase = abstract_cloneable<Base> >
struct cloneable;
/// an adaptor for an existing class.
@@ -42,14 +42,14 @@
template <
class T
, class Base = default_base_type
- , class AbstractBase = abstract_base<Base> >
+ , class AbstractBase = abstract_cloneable<Base> >
struct adaptor;
/// a heterogenous vector of objects
template <
class Base = default_base_type
, class Alloc = monotonic::allocator<int>
- , class AbstractBase = abstract_base<Base> >
+ , class AbstractBase = abstract_cloneable<Base> >
struct vector;
/// a mapping of heterogenous objects to heterogenous objects
@@ -57,7 +57,7 @@
class Base = default_base_type
, class Pred = std::less<Base>
, class Alloc = monotonic::allocator<int>
- , class AbstractBase = abstract_base<Base> >
+ , class AbstractBase = abstract_cloneable<Base> >
struct map;
} // namespace heterogenous
Modified: sandbox/monotonic/boost/heterogenous/map.hpp
==============================================================================
--- sandbox/monotonic/boost/heterogenous/map.hpp (original)
+++ sandbox/monotonic/boost/heterogenous/map.hpp 2009-06-30 01:27:14 EDT (Tue, 30 Jun 2009)
@@ -10,7 +10,6 @@
#include <boost/foreach.hpp>
#include <boost/heterogenous/detail/prefix.hpp>
-#include <boost/heterogenous/base.hpp>
#include <boost/heterogenous/make_clone_allocator.hpp>
namespace boost
Modified: sandbox/monotonic/boost/heterogenous/vector.hpp
==============================================================================
--- sandbox/monotonic/boost/heterogenous/vector.hpp (original)
+++ sandbox/monotonic/boost/heterogenous/vector.hpp 2009-06-30 01:27:14 EDT (Tue, 30 Jun 2009)
@@ -11,7 +11,7 @@
#include <boost/foreach.hpp>
#include <boost/heterogenous/detail/prefix.hpp>
-#include <boost/heterogenous/base.hpp>
+#include <boost/heterogenous/cloneable.hpp>
#include <boost/heterogenous/make_clone_allocator.hpp>
#include <boost/heterogenous/detail/allocation.hpp>
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:27:14 EDT (Tue, 30 Jun 2009)
@@ -361,7 +361,7 @@
>
</File>
<File
- RelativePath="..\..\..\..\boost\heterogenous\abstract_base.hpp"
+ RelativePath="..\..\..\..\boost\heterogenous\abstract_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