Main Page | Modules | Namespace List | Class Hierarchy | Class List | Namespace Members | Class Members | Related Pages

openvrml::scope_ptr Class Reference

scope_ptr is a reference-counting smart pointer for scopes. More...

Collaboration diagram for openvrml::scope_ptr:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 scope_ptr (openvrml::scope *scope=0) throw (std::bad_alloc)
 Construct.

 scope_ptr (const scope_ptr &ptr) throw ()
 Construct a copy.

 operator bool () const throw ()
 Automatic conversion to bool.

scope_ptroperator= (const scope_ptr &ptr) throw ()
 Assignment operator.

scopeoperator * () const throw ()
 Dereference.

scopeoperator-> () const throw ()
 Delegate to the scope.

scopeget () const throw ()
 Get the scope pointer.

void reset (openvrml::scope *scope=0) throw (std::bad_alloc)
 Reset the scope_ptr to a new scope.


Private Member Functions

void dispose () throw ()
 Decrement the reference count; destroy the scope if the count drops to zero.


Private Attributes

scopescope_
 Pointer to a scope.

size_t * count_
 Pointer to the reference count.


Friends

bool operator== (const scope_ptr &lhs, const scope_ptr &rhs) throw ()

Related Functions

(Note that these are not member functions.)

bool operator!= (const scope_ptr &lhs, const scope_ptr &rhs) throw()
 Compare for inequality.


Detailed Description

scope_ptr is a reference-counting smart pointer for scopes.

scope_ptr is patterned after the Boost shared_ptr, and it works basically the same way. A scope_ptr should be constructed or reset with a scope created with new (or 0).

See also:
http://boost.org/libs/smart_ptr/shared_ptr.htm


Constructor & Destructor Documentation

openvrml::scope_ptr::scope_ptr openvrml::scope scope = 0  )  throw (std::bad_alloc) [explicit]
 

Construct.

Parameters:
scope a pointer to a scope constructed with new.
Exceptions:
std::bad_alloc if memory allocation fails.

openvrml::scope_ptr::scope_ptr const scope_ptr ptr  )  throw ()
 

Construct a copy.

Parameters:
ptr the scope_ptr to copy.

Member Function Documentation

scope * openvrml::scope_ptr::get  )  const throw () [inline]
 

Get the scope pointer.

Returns:
a pointer to the scope.

scope & openvrml::scope_ptr::operator *  )  const throw () [inline]
 

Dereference.

Returns:
a reference to the scope.

openvrml::scope_ptr::operator bool  )  const throw () [inline]
 

Automatic conversion to bool.

Returns:
true if the scope_ptr is non-null; false otherwise.

scope * openvrml::scope_ptr::operator->  )  const throw () [inline]
 

Delegate to the scope.

Returns:
a pointer to the scope.

scope_ptr & openvrml::scope_ptr::operator= const scope_ptr ptr  )  throw ()
 

Assignment operator.

Parameters:
ptr 

void openvrml::scope_ptr::reset openvrml::scope scope = 0  )  throw (std::bad_alloc)
 

Reset the scope_ptr to a new scope.

Parameters:
scope a pointer to a scope constructed with new.
Exceptions:
std::bad_alloc if memory allocation fails.

Friends And Related Function Documentation

bool operator!= const scope_ptr lhs,
const scope_ptr rhs
throw() [related]
 

Compare for inequality.

Parameters:
lhs left-hand operand.
rhs right-hand operand.
Returns:
true if lhs and rhs point to different scopes; false otherwise.