|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r54522 - sandbox/monotonic/boost/heterogenous
From: christian.schladetsch_at_[hidden]
Date: 2009-06-30 01:33:39
Author: cschladetsch
Date: 2009-06-30 01:33:38 EDT (Tue, 30 Jun 2009)
New Revision: 54522
URL: http://svn.boost.org/trac/boost/changeset/54522
Log:
added some comments
Text files modified:
sandbox/monotonic/boost/heterogenous/abstract_cloneable.hpp | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
Modified: sandbox/monotonic/boost/heterogenous/abstract_cloneable.hpp
==============================================================================
--- sandbox/monotonic/boost/heterogenous/abstract_cloneable.hpp (original)
+++ sandbox/monotonic/boost/heterogenous/abstract_cloneable.hpp 2009-06-30 01:33:38 EDT (Tue, 30 Jun 2009)
@@ -13,29 +13,40 @@
{
namespace heterogenous
{
+ /// default base type used for object hierarchies to be stored in a given
+ /// container or containers. the user can supply their own when using
+ /// cloneable<Derived, Base> this will be used by default.
struct default_base_type
{
virtual ~default_base_type() { }
};
- /// TODO: rename this to abstract_cloneable
+ /// root structure for the heterogenous object system
template <class Base>
struct abstract_cloneable : Base
{
typedef Base base_type;
typedef abstract_cloneable<Base> this_type;
+ /// make storage for a new instance, but do not invoke any constructor
virtual this_type *allocate(abstract_allocator &alloc) const = 0;
+
+ /// free memory associated with the given instance
virtual void deallocate(base_type &, abstract_allocator &alloc) const = 0;
+ /// create a new object of the derived type
virtual this_type *create_new(abstract_allocator &alloc) const = 0;
+
+ /// create a clone using copy-constructor. this is implemented in cloneable<>, but can
+ /// be overriden by the user in the derived type if required.
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
+ /// optional means to make a clone that does not use copy-construction.
+ /// user can overload this in their derived type to provide custom clone implementation.
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
+ /// make a copy of the given instance. try the custom clone method first,
+ /// then default to using the copy-constructor method
this_type *make_copy(const base_type &original, abstract_allocator &alloc) const
{
if (this_type *copy = clone(original, alloc))
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