openvrml::mfcolor Class Reference

A color array node field value. More...

#include <openvrml/field_value.h>

Inheritance diagram for openvrml::mfcolor:

Public Types

typedef std::vector< colorvalue_type
 The type of value.
- Public Types inherited from openvrml::field_value
enum  type_id {
  invalid_type_id,
  sfbool_id,
  sfcolor_id,
  sfcolorrgba_id,
  sffloat_id,
  sfdouble_id,
  sfimage_id,
  sfint32_id,
  sfnode_id,
  sfrotation_id,
  sfstring_id,
  sftime_id,
  sfvec2f_id,
  sfvec2d_id,
  sfvec3f_id,
  sfvec3d_id,
  mfbool_id,
  mfcolor_id,
  mfcolorrgba_id,
  mffloat_id,
  mfdouble_id,
  mfimage_id,
  mfint32_id,
  mfnode_id,
  mfrotation_id,
  mfstring_id,
  mftime_id,
  mfvec2f_id,
  mfvec2d_id,
  mfvec3f_id,
  mfvec3d_id
}
 Used to identify field_value types. More...

Public Member Functions

 mfcolor (std::vector< color >::size_type n=0, const color &value=color()) throw ( std::bad_alloc )
 Construct.
 mfcolor (const value_type &value) throw ( std::bad_alloc )
 Construct.
 mfcolor (const mfcolor &mfc)
 Construct a copy.
virtual ~mfcolor () throw ()
 Destroy.
mfcoloroperator= (const mfcolor &mfc) throw ( std::bad_alloc )
 Assign.
const value_typevalue () const throw ()
 Access.
void value (const value_type &val) throw ( std::bad_alloc )
 Mutate.
void swap (mfcolor &mfc) throw ()
 Swap.
- Public Member Functions inherited from openvrml::field_value
virtual ~field_value ()=0 throw ()
 Destroy.
std::auto_ptr< field_valueclone () const throw ( std::bad_alloc )
 Polymorphically construct a copy.
field_valueassign (const field_value &value) throw ( std::bad_cast , std::bad_alloc )
 Virtual assignment.
type_id type () const throw ()
 Get the field type.
template<typename FieldValue >
void value (const typename FieldValue::value_type &val) throw ( std::bad_alloc )
 Mutate.
template<typename FieldValue >
void swap (FieldValue &val) throw ()
 Swap.

Static Public Attributes

static const type_id field_value_type_id = mfcolor_id
 field_value::type_id for this class.

Private Member Functions

virtual std::auto_ptr
< field_value
do_clone () const throw ( std::bad_alloc )
 Polymorphically construct a copy.
virtual mfcolordo_assign (const field_value &value) throw ( std::bad_cast , std::bad_alloc )
 Virtual assignment.
virtual type_id do_type () const throw ()
 Get the field_value::type_id associated with this class.
virtual void print (std::ostream &) const
 Print to an output stream.

Related Functions

(Note that these are not member functions.)

bool operator== (const mfcolor &lhs, const mfcolor &rhs) throw()
 Compare for equality.
bool operator!= (const mfcolor &lhs, const mfcolor &rhs) throw()
 Compare for inequality.
template<> void swap (openvrml::mfcolor &a, openvrml::mfcolor &b)
 Swap the values of a and b.

Additional Inherited Members

- Static Public Member Functions inherited from openvrml::field_value
static std::auto_ptr< field_valuecreate (type_id type) throw ( std::bad_alloc )
 Create a default instance of the type specified by type.
- Protected Member Functions inherited from openvrml::field_value
template<typename ValueType >
 field_value (const ValueType &value, const value_type_constructor_tag &) throw ( std::bad_alloc )
 Construct.
 field_value (const field_value &value) throw ( std::bad_alloc )
 Construct a copy.
template<typename FieldValue >
FieldValue & operator= (const FieldValue &fv) throw ( std::bad_alloc )
 Assignment operator.

Detailed Description

A color array node field value.

Model of
Field Value

Member Typedef Documentation

The type of value.

Constructor & Destructor Documentation

openvrml::mfcolor::mfcolor ( std::vector< color >::size_type  n = 0,
const color value = color() 
) throw ( std::bad_alloc )
explicit

Construct.

Creates an mfcolor with n copies of value.

Parameters
[in]nthe number elements in the mfcolor.
[in]valueused to initialize the mfcolor.
Exceptions
std::bad_allocif memory allocation fails.
Postcondition
size is n. Every element is a copy of value.
openvrml::mfcolor::mfcolor ( const value_type value) throw ( std::bad_alloc )
inlineexplicit

Construct.

Parameters
[in]valueinitial value.
Exceptions
std::bad_allocif memory allocation fails.
openvrml::mfcolor::mfcolor ( const mfcolor mfc)

Construct a copy.

Parameters
[in]mfcthe instance to copy.
openvrml::mfcolor::~mfcolor ( ) throw ()
virtual

Destroy.

Each of the mfcolor's value elements is destroyed, and memory allocated for them (if any) is deallocated.

Member Function Documentation

openvrml::mfcolor & openvrml::mfcolor::operator= ( const mfcolor mfc) throw ( std::bad_alloc )

Assign.

Parameters
[in]mfcthe value to assign.
Returns
a reference to the instance.
Exceptions
std::bad_allocif memory allocation fails.
const openvrml::mfcolor::value_type & openvrml::mfcolor::value ( ) const throw ()

Access.

Returns
the color values.

Reimplemented from openvrml::field_value.

void openvrml::mfcolor::value ( const value_type val) throw ( std::bad_alloc )

Mutate.

Parameters
[in]valthe new value.
Exceptions
std::bad_allocif memory allocation fails.
void openvrml::mfcolor::swap ( mfcolor mfc) throw ()

Swap.

Parameters
[in,out]mfcthe value to swap with this one.
std::auto_ptr< openvrml::field_value > openvrml::mfcolor::do_clone ( ) const throw ( std::bad_alloc )
privatevirtual

Polymorphically construct a copy.

Returns
a pointer to a copy of the object.
Exceptions
std::bad_allocif memory allocation fails.
openvrml::mfcolor & openvrml::mfcolor::do_assign ( const field_value value) throw ( std::bad_cast , std::bad_alloc )
privatevirtual

Virtual assignment.

Returns
a reference to the object.
Exceptions
std::bad_castif value is not an mfcolor object.
std::bad_allocif memory allocation fails.
openvrml::field_value::type_id openvrml::mfcolor::do_type ( ) const throw ()
privatevirtual

Get the field_value::type_id associated with this class.

Returns
field_value::mfcolor.
void openvrml::mfcolor::print ( std::ostream &  out) const
privatevirtual

Print to an output stream.

Parameters
[in,out]outan output stream.

Friends And Related Function Documentation

bool operator== ( const mfcolor lhs,
const mfcolor rhs 
) throw()
related

Compare for equality.

Parameters
[in]lhsleft-hand operand.
[in]rhsright-hand operand.
Returns
true if lhs and rhs have the same value; false otherwise.
bool operator!= ( const mfcolor lhs,
const mfcolor rhs 
) throw()
related

Compare for inequality.

Parameters
[in]lhsleft-hand operand.
[in]rhsright-hand operand.
Returns
true if lhs and rhs do not have the same value; false otherwise.
template<> void swap ( openvrml::mfcolor a,
openvrml::mfcolor b 
)
related

Swap the values of a and b.

Does not throw.

Parameters
[in,out]a
[in,out]b

Member Data Documentation

const openvrml::field_value::type_id openvrml::mfcolor::field_value_type_id = mfcolor_id
static

field_value::type_id for this class.