copy_on_write Class Template Reference
[copy_on_write]

#include <copy_on_write.hpp>

List of all members.


Detailed Description

template<typename T>
class adobe::copy_on_write< T >

Model Of:

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.

Definition at line 57 of file copy_on_write.hpp.


Public Types

typedef T value_type

Public Member Functions

 copy_on_write (move_from< copy_on_write > x)
 copy_on_write (const copy_on_write &x)
template<typename U>
 copy_on_write (const U &x, typename copy_sink< U, T >::type=0)
template<typename U>
 copy_on_write (U x, typename move_sink< U, T >::type=0)
 copy_on_write ()
bool identity (const copy_on_write &x) const
 operator const value_type & () const
const value_typeoperator* () const
const value_typeoperator-> () const
template<typename U>
copy_sink< U, T, copy_on_write & >
::type 
operator= (const U &x)
template<typename U>
move_sink< U, T, copy_on_write & >
::type 
operator= (U 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)
void swap (copy_on_write &x, copy_on_write &y)

Member Typedef Documentation

typedef T value_type

The type of value stored.

Definition at line 63 of file copy_on_write.hpp.


Constructor & Destructor Documentation

copy_on_write (  ) 

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 70 of file copy_on_write.hpp.

copy_on_write ( x,
typename move_sink< U, T >::type  = 0 
) [explicit]

Constructs a new copy_on_write object with a value x.

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

Definition at line 86 of file copy_on_write.hpp.

copy_on_write ( const U &  x,
typename copy_sink< U, T >::type  = 0 
) [explicit]

Constructs a new copy_on_write object with a value x.

Parameters:
\c x A default value to assign to this object
Note:
This constructor is for value types which do support the move library.

Definition at line 99 of file copy_on_write.hpp.

copy_on_write ( const copy_on_write< T > &  x  ) 

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

Definition at line 108 of file copy_on_write.hpp.

copy_on_write ( move_from< copy_on_write< T > >  x  ) 

Definition at line 114 of file copy_on_write.hpp.

~copy_on_write (  ) 

Definition at line 120 of file copy_on_write.hpp.


Member Function Documentation

bool identity ( const copy_on_write< T > &  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 265 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 206 of file copy_on_write.hpp.

const value_type& operator* (  )  const

Obtain a const reference to the underlying object.

Returns:
A const reference to the underlying object
Obtain a 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 pointer to the underlying object

Definition at line 228 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 245 of file copy_on_write.hpp.

copy_sink<U, T, copy_on_write&>::type operator= ( const U &  x  ) 

Definition at line 153 of file copy_on_write.hpp.

move_sink<U, T, copy_on_write&>::type operator= ( x  ) 

Assign a value which is convertible to value_type directly to a copy_on_write object.

Definition at line 138 of file copy_on_write.hpp.

copy_on_write& operator= ( copy_on_write< T >  x  ) 

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

Definition at line 130 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 194 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 258 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.

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 > &  x,
const copy_on_write< T > &  y 
) [friend]

Definition at line 270 of file copy_on_write.hpp.

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

Definition at line 273 of file copy_on_write.hpp.

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

Definition at line 267 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