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

openvrml::field_value_ptr Class Reference
[Field Values]

A reference-counting smart pointer for field_values. More...

Collaboration diagram for openvrml::field_value_ptr:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 field_value_ptr (field_value *value=0) throw (std::bad_alloc)
 Construct.

 field_value_ptr (std::auto_ptr< field_value > &value) throw (std::bad_alloc)
 Construct.

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

 ~field_value_ptr () throw ()
 Destroy.

 operator bool () const throw ()
 Automatically convert to bool.

field_value_ptroperator= (const field_value_ptr &ptr) throw ()
 Assignment operator.

field_valueoperator * () const throw ()
 Dereference.

field_valueoperator-> () const throw ()
 Delegate to the field_value.

field_valueget () const throw ()
 Get the field_value pointer.

void reset (field_value *value=0) throw (std::bad_alloc)
 Reset the field_value_ptr to a new field_value.


Private Member Functions

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


Private Attributes

field_valuevalue
 A pointer to a field_value.

size_t * count
 A pointer to the reference count.


Friends

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

Related Functions

(Note that these are not member functions.)

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


Detailed Description

A reference-counting smart pointer for field_values.

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

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


Constructor & Destructor Documentation

openvrml::field_value_ptr::field_value_ptr field_value value = 0  )  throw (std::bad_alloc) [explicit]
 

Construct.

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

openvrml::field_value_ptr::field_value_ptr std::auto_ptr< field_value > &  value  )  throw (std::bad_alloc) [explicit]
 

Construct.

Parameters:
value an auto_ptr to a field_value.
Exceptions:
std::bad_alloc if memory allocation fails.

openvrml::field_value_ptr::field_value_ptr const field_value_ptr ptr  )  throw ()
 

Construct a copy.

Parameters:
ptr the field_value_ptr to copy.

openvrml::field_value_ptr::~field_value_ptr  )  throw () [inline]
 

Destroy.

Decrement the reference count. If the reference count drops to zero, the field_value will be destroyed.


Member Function Documentation

field_value * openvrml::field_value_ptr::get  )  const throw () [inline]
 

Get the field_value pointer.

Returns:
a pointer to the field_value.

field_value & openvrml::field_value_ptr::operator *  )  const throw () [inline]
 

Dereference.

Returns:
a reference to the field_value.

field_value * openvrml::field_value_ptr::operator->  )  const throw () [inline]
 

Delegate to the field_value.

Returns:
a pointer to the field_value.

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

Assignment operator.

Parameters:
ptr 
Returns:
a reference to the field_value_ptr.

void openvrml::field_value_ptr::reset field_value value = 0  )  throw (std::bad_alloc)
 

Reset the field_value_ptr to a new field_value.

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

Friends And Related Function Documentation

bool operator!= const field_value_ptr lhs,
const field_value_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 field_values; false otherwise.