Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Handle_for< RefCounted, Allocator > Class Template Reference

#include <Handle_for.h>

Public Member Functions

 Handle_for (const RefCounted &rc)
 
 Handle_for ()
 
 Handle_for (const Handle_for &h)
 
 ~Handle_for ()
 
Handle_foroperator= (const Handle_for &h)
 
void initialize_with (const RefCounted &rc)
 
void copy_on_write ()
 
bool identical (const Handle_for &h) const
 
long int id () const
 

Protected Attributes

Allocator::pointer ptr
 

Static Protected Attributes

static Allocator allocator
 

Detailed Description

template<class RefCounted, class Allocator>
class CGAL::Handle_for< RefCounted, Allocator >

Definition at line 58 of file Handle_for.h.

Constructor & Destructor Documentation

Handle_for ( const RefCounted &  rc)
inline

Definition at line 91 of file Handle_for.h.

References Handle_for< RefCounted, Allocator >::allocator, and Handle_for< RefCounted, Allocator >::ptr.

92  {
93  ptr = allocator.allocate(1);
94  allocator.construct(ptr, rc);
95  }
Allocator::pointer ptr
Definition: Handle_for.h:160
static Allocator allocator
Definition: Handle_for.h:159
Handle_for ( )
inline

Definition at line 97 of file Handle_for.h.

References Handle_for< RefCounted, Allocator >::allocator, and Handle_for< RefCounted, Allocator >::ptr.

98  {
99  ptr = allocator.allocate(1);
100  }
Allocator::pointer ptr
Definition: Handle_for.h:160
static Allocator allocator
Definition: Handle_for.h:159
Handle_for ( const Handle_for< RefCounted, Allocator > &  h)
inline

Definition at line 102 of file Handle_for.h.

References Handle_for< RefCounted, Allocator >::ptr.

103  {
104  ptr = h.ptr;
105  ptr->add_reference();
106  }
Allocator::pointer ptr
Definition: Handle_for.h:160
~Handle_for ( )
inline

Definition at line 108 of file Handle_for.h.

References Handle_for< RefCounted, Allocator >::allocator, and Handle_for< RefCounted, Allocator >::ptr.

109  {
110  ptr->remove_reference();
111  if ( !ptr->is_referenced() )
112  {
113  allocator.destroy( ptr);
114  allocator.deallocate( ptr, 1);
115  }
116  }
Allocator::pointer ptr
Definition: Handle_for.h:160
static Allocator allocator
Definition: Handle_for.h:159

Member Function Documentation

void copy_on_write ( )
inline

Definition at line 139 of file Handle_for.h.

References Handle_for< RefCounted, Allocator >::allocator, and Handle_for< RefCounted, Allocator >::ptr.

140  {
141  if ( ptr->is_shared() )
142  {
143  RefCounted* tmp_ptr = allocator.allocate(1);
144  allocator.construct( tmp_ptr, *ptr);
145  ptr->remove_reference();
146  ptr = tmp_ptr;
147  }
148  }
Allocator::pointer ptr
Definition: Handle_for.h:160
static Allocator allocator
Definition: Handle_for.h:159
long int id ( ) const
inline

Definition at line 155 of file Handle_for.h.

156  { return reinterpret_cast<long int>( &(*ptr)); }
bool identical ( const Handle_for< RefCounted, Allocator > &  h) const
inline

Definition at line 151 of file Handle_for.h.

References Handle_for< RefCounted, Allocator >::ptr.

152  { return ptr == h.ptr; }
Allocator::pointer ptr
Definition: Handle_for.h:160
void initialize_with ( const RefCounted &  rc)
inline

Definition at line 133 of file Handle_for.h.

References Handle_for< RefCounted, Allocator >::allocator, and Handle_for< RefCounted, Allocator >::ptr.

134  {
135  allocator.construct(ptr, rc);
136  }
Allocator::pointer ptr
Definition: Handle_for.h:160
static Allocator allocator
Definition: Handle_for.h:159
Handle_for& operator= ( const Handle_for< RefCounted, Allocator > &  h)
inline

Definition at line 119 of file Handle_for.h.

References Handle_for< RefCounted, Allocator >::allocator, and Handle_for< RefCounted, Allocator >::ptr.

120  {
121  h.ptr->add_reference();
122  ptr->remove_reference();
123  if ( !ptr->is_referenced() )
124  {
125  allocator.destroy( ptr);
126  allocator.deallocate( ptr, 1);
127  }
128  ptr = h.ptr;
129  return *this;
130  }
Allocator::pointer ptr
Definition: Handle_for.h:160
static Allocator allocator
Definition: Handle_for.h:159

Member Data Documentation


The documentation for this class was generated from the following file: