openvrml::field_value Class Referenceabstract

Abstract base class for the VRML field types. More...

#include <openvrml/field_value.h>

Inheritance diagram for openvrml::field_value:

Classes

class  value_type_constructor_tag
 This struct exists only to disambiguate field_value's constructor template from its copy constructor. More...
 

Public Types

Public Member Functions

virtual ~field_value ()=0 throw ()
 Destroy. More...
 
std::auto_ptr< field_valueclone () const throw ( std::bad_alloc )
 Polymorphically construct a copy. More...
 
field_valueassign (const field_value &value) throw ( std::bad_cast , std::bad_alloc )
 Virtual assignment. More...
 
type_id type () const throw ()
 Get the field type. More...
 
template<typename FieldValue >
const FieldValue::value_type & value () const throw ()
 Access. More...
 
template<typename FieldValue >
void value (const typename FieldValue::value_type &val) throw ( std::bad_alloc )
 Mutate. More...
 
template<typename FieldValue >
void swap (FieldValue &val) throw ()
 Swap. More...
 

Static Public Member Functions

static std::auto_ptr< field_valuecreate (type_id type) throw ( std::bad_alloc )
 Create a default instance of the type specified by type. More...
 

Protected Member Functions

template<typename ValueType >
 field_value (const ValueType &value, const value_type_constructor_tag &) throw ( std::bad_alloc )
 Construct. More...
 
 field_value (const field_value &value) throw ( std::bad_alloc )
 Construct a copy. More...
 
template<typename FieldValue >
FieldValue & operator= (const FieldValue &fv) throw ( std::bad_alloc )
 Assignment operator. More...
 

Private Member Functions

virtual std::auto_ptr< field_valuedo_clone () const =0 throw ( std::bad_alloc )
 Polymorphically construct a copy. More...
 
virtual field_valuedo_assign (const field_value &value)=0 throw ( std::bad_cast , std::bad_alloc )
 Virtual assignment. More...
 
virtual type_id do_type () const =0 throw ()
 Get the field type. More...
 
virtual void print (std::ostream &out) const =0
 Print to an output stream. More...
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &out, const field_value &value)
 Stream output. More...
 
std::ostream & operator<< (std::ostream &out, const field_value::type_id type_id)
 Stream output. More...
 
std::istream & operator>> (std::istream &in, field_value::type_id &type_id)
 Stream input. More...
 

Detailed Description

Abstract base class for the VRML field types.

Subclasses of field_value are models of Field Value. These subclasses have copy-on-write semantics.

Member Enumeration Documentation

Used to identify field_value types.

These tags are typically used to designate an expected type or to avoid a dynamic_cast.

Enumerator
invalid_type_id 

Zero value typically used to indicate failure.

sfbool_id 

Designates an sfbool.

sfcolor_id 

Designates an sfcolor.

sfcolorrgba_id 

Designates an sfcolorrgba.

sffloat_id 

Designates an sffloat.

sfdouble_id 

Designates an sfdouble.

sfimage_id 

Designates an sfimage.

sfint32_id 

Designates an sfint32.

sfnode_id 

Designates an sfnode.

sfrotation_id 

Designates an sfrotation.

sfstring_id 

Designates an sfstring.

sftime_id 

Designates an sftime.

sfvec2f_id 

Designates an sfvec2f.

sfvec2d_id 

Designates an sfvec2d.

sfvec3f_id 

Designates an sfvec3f.

sfvec3d_id 

Designates an sfvec3d.

mfbool_id 

Designates an mfbool.

mfcolor_id 

Designates an mfcolor.

mfcolorrgba_id 

Designates an mfcolorrgba.

mffloat_id 

Designates an mffloat.

mfdouble_id 

Designates an mfdouble.

mfimage_id 

Designates an mfimage.

mfint32_id 

Designates an mfint32.

mfnode_id 

Designates an mfnode.

mfrotation_id 

Designates an mfrotation.

mfstring_id 

Designates an mfstring.

mftime_id 

Designates an mftime.

mfvec2f_id 

Designates an mfvec2f.

mfvec2d_id 

Designates an mfvec2d.

mfvec3f_id 

Designates an mfvec3f.

mfvec3d_id 

Designates an mfvec3d.

Constructor & Destructor Documentation

openvrml::field_value::~field_value ( )
throw (
)
pure virtual

Destroy.

template<typename ValueType >
openvrml::field_value::field_value ( const ValueType &  value,
const value_type_constructor_tag  
)
throw (std::bad_alloc
)
protected

Construct.

Template Parameters
ValueTypea Field Value value_type.
Parameters
[in]valueinitial value.
Exceptions
std::bad_allocif memory allocation fails.
openvrml::field_value::field_value ( const field_value fv)
throw (std::bad_alloc
)
protected

Construct a copy.

Parameters
[in]fvfield value to copy.
Exceptions
std::bad_allocif memory allocation fails.

Member Function Documentation

std::auto_ptr< openvrml::field_value > openvrml::field_value::create ( type_id  type)
throw (std::bad_alloc
)
static

Create a default instance of the type specified by type.

Parameters
[in]typefield value type identifier.
Returns
a default instance of the type specified by type.
Exceptions
std::bad_allocif memory allocation fails.
std::auto_ptr< openvrml::field_value > openvrml::field_value::clone ( ) const
throw (std::bad_alloc
)

Polymorphically construct a copy.

This function delegates to field_value::do_clone.

Returns
a new field_value identical to this one.
Exceptions
std::bad_allocif memory allocation fails.
openvrml::field_value & openvrml::field_value::assign ( const field_value value)
throw ( std::bad_cast ,
std::bad_alloc
)

Virtual assignment.

Thus function delegates to field_value::do_assign.

Parameters
[in]valuethe value to assign to the object.
Returns
this object.
openvrml::field_value::type_id openvrml::field_value::type ( ) const
throw (
)

Get the field type.

This function delegates to field_value::do_type.

Returns
the type_id enumerant corresponding to the field_value's type.
template<typename FieldValue >
const FieldValue::value_type & openvrml::field_value::value ( ) const
throw (
)

Access.

Template Parameters
FieldValuea Field Value.
Returns
the current value.
template<typename FieldValue >
void openvrml::field_value::value ( const typename FieldValue::value_type &  val)
throw (std::bad_alloc
)

Mutate.

Template Parameters
FieldValuea Field Value.
Parameters
[in]valnew value.
Exceptions
std::bad_allocif memory allocation fails.
template<typename FieldValue >
void openvrml::field_value::swap ( FieldValue &  val)
throw (
)

Swap.

Template Parameters
FieldValuea Field Value.
Parameters
[in,out]valthe value to swap with this one.
template<typename FieldValue >
FieldValue & openvrml::field_value::operator= ( const FieldValue &  fv)
throw (std::bad_alloc
)
protected

Assignment operator.

Template Parameters
FieldValuea Field Value.
Parameters
[in]fvfield value to assign.
openvrml::field_value & openvrml::field_value::do_assign ( const field_value value)
throw ( std::bad_cast ,
std::bad_alloc
)
privatepure virtual

Friends And Related Function Documentation

std::ostream & operator<< ( std::ostream &  out,
const field_value value 
)
related

Stream output.

Parameters
[in,out]outan output stream.
[in]valuea field value.
Returns
out.
std::ostream & operator<< ( std::ostream &  out,
const field_value::type_id  type_id 
)
related

Stream output.

If type is field_value::invalid_type, failbit is set on out.

Parameters
[in,out]outoutput stream.
[in]type_idfield_value type identifier.
Returns
out.
std::istream & operator>> ( std::istream &  in,
field_value::type_id type_id 
)
related

Stream input.

Parameters
[in,out]ininput stream.
[out]type_idfield_value type identifier.
Returns
in.