stlab.adobe.com Adobe Systems Incorporated

copy_on_write< T, A > Class Template Reference
[ABI-Safe Utilities]

A copy-on-write wrapper for any model of Regular. More...

#include <copy_on_write.hpp>

List of all members.

Public Types

typedef A allocator_type
typedef T value_type

Public Member Functions

 copy_on_write ()
 copy_on_write (const allocator_type &a)
 copy_on_write (const copy_on_write &x)
 copy_on_write (move_from< copy_on_write > x)
 copy_on_write (T x)
allocator_type get_allocator () const
bool identity (const copy_on_write &x) const
 operator const value_type & () const
const value_typeoperator* () const
const value_typeoperator-> () const
copy_on_writeoperator= (T x)
copy_on_writeoperator= (copy_on_write x)
const value_typeread () const
bool unique_instance () const
value_typewrite ()
 ~copy_on_write ()

Friends

bool operator!= (const copy_on_write &x, const copy_on_write &y)
bool operator< (const copy_on_write &x, const copy_on_write &y)
bool operator<= (const copy_on_write &x, const copy_on_write &y)
bool operator== (const copy_on_write &x, const copy_on_write &y)
bool operator> (const copy_on_write &x, const copy_on_write &y)
bool operator>= (const copy_on_write &x, const copy_on_write &y)
void swap (copy_on_write &x, copy_on_write &y)

Detailed Description

template<typename T, typename A = adobe::capture_allocator<T>>
class adobe::version_1::copy_on_write< T, A >

Model Of:
Requirements:

Copy-on-write sematics allow for object to be lazily copied - only creating a copy when the value is modified and there is more than one reference to the value.

Note:
copy_on_write is thread safe when complier with BOOST_HAS_THREADS defined.
To get an instance with a particular allocator one would have to write:
copy_on_write<T> x(custom_allocator);
x.write() = value;

Definition at line 71 of file copy_on_write.hpp.


Member Typedef Documentation

typedef A allocator_type

The type of allocator.

Definition at line 77 of file copy_on_write.hpp.

typedef T value_type

The type of value stored.

Definition at line 75 of file copy_on_write.hpp.


Constructor & Destructor Documentation

The first call to the default constructor will construct a default instance of value_type which will be used for subsequent calls to the default constructor. The default instance will be released at exit.

Definition at line 91 of file copy_on_write.hpp.

copy_on_write ( const allocator_type a ) [explicit]

Initializes the instance with a custom allocator

Definition at line 101 of file copy_on_write.hpp.

copy_on_write ( x )

Constructs a new copy_on_write object with a value x.

Parameters:
xA default value to assign to this object
Note:
This constructor is for value types which do not support the move library.

Definition at line 116 of file copy_on_write.hpp.

copy_on_write ( const copy_on_write< T, A > &  x )

Copy construction is a non-throwing operation and simply increments the reference count on the stored object.

Definition at line 124 of file copy_on_write.hpp.

copy_on_write ( move_from< copy_on_write< T, A > >  x )

Definition at line 131 of file copy_on_write.hpp.

~copy_on_write (  )

Definition at line 137 of file copy_on_write.hpp.


Member Function Documentation

allocator_type get_allocator (  ) const

Definition at line 271 of file copy_on_write.hpp.

bool identity ( const copy_on_write< T, A > &  x ) const

identity is used to see if two copy_on_write items refer to the same instance.

Returns:
Boolean; true if the underlying object instance is shared by both objects.

Definition at line 247 of file copy_on_write.hpp.

operator const value_type & (  ) const

Obtain a const reference to the underlying object.

Returns:
A const reference to the underlying object

Definition at line 201 of file copy_on_write.hpp.

const value_type& operator* (  ) const

Obtain a const reference to the underlying object.

This is provided because you cannot override operator.(). It allows copy_on_write to be used with common transformation techniques, such as boost indirect_iterator and transform_iterator. It does not imply "pointer" semantics.

Returns:
A const reference to the underlying object

Definition at line 214 of file copy_on_write.hpp.

const value_type* operator-> (  ) const

Obtain a const pointer to the underlying object.

This is provided because you cannot override operator.(). It allows copy_on_write to be used with common transformation techniques, such as boost indirect_iterator and transform_iterator. It does not imply "pointer" semantics.

Returns:
A const pointer to the underlying object

Definition at line 227 of file copy_on_write.hpp.

copy_on_write& operator= ( copy_on_write< T, A >  x )

As with copy construction, assignment is a non-throwing operation which releases the old value and increments the reference count of the item being assigned to.

Definition at line 147 of file copy_on_write.hpp.

copy_on_write& operator= ( x )

Definition at line 151 of file copy_on_write.hpp.

const value_type& read (  ) const

Obtain a const reference to the underlying object.

Returns:
A const reference to the underlying object

Definition at line 190 of file copy_on_write.hpp.

bool unique_instance (  ) const

unique_instance returns whether or not the reference count to the object instance is one. This is useful to determine if writing will cause a copy.

Returns:
true if the ref count for the instance is one.

Definition at line 237 of file copy_on_write.hpp.

value_type& write (  )

Obtain a reference to the value the object is referencing. This will copy the underlying value (if necessary) so changes to the value do not affect other copy_on_write objects.

Note that write() does not have the same preconditions as operator=(). write() returns a reference to the underlying object's value, thus requiring that an underlying object exist. operator=() on the other hand will perform an allocation if one is necessary.

Returns:
A reference to the underlying object

Definition at line 175 of file copy_on_write.hpp.


Friends And Related Function Documentation

bool operator!= ( const copy_on_write< T, A > &  x,
const copy_on_write< T, A > &  y 
) [friend]

Definition at line 268 of file copy_on_write.hpp.

bool operator< ( const copy_on_write< T, A > &  x,
const copy_on_write< T, A > &  y 
) [friend]

Definition at line 253 of file copy_on_write.hpp.

bool operator<= ( const copy_on_write< T, A > &  x,
const copy_on_write< T, A > &  y 
) [friend]

Definition at line 259 of file copy_on_write.hpp.

bool operator== ( const copy_on_write< T, A > &  x,
const copy_on_write< T, A > &  y 
) [friend]

Definition at line 265 of file copy_on_write.hpp.

bool operator> ( const copy_on_write< T, A > &  x,
const copy_on_write< T, A > &  y 
) [friend]

Definition at line 256 of file copy_on_write.hpp.

bool operator>= ( const copy_on_write< T, A > &  x,
const copy_on_write< T, A > &  y 
) [friend]

Definition at line 262 of file copy_on_write.hpp.

void swap ( copy_on_write< T, A > &  x,
copy_on_write< T, A > &  y 
) [friend]

Definition at line 250 of file copy_on_write.hpp.

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google