|
From: <br...@us...> - 2009-11-25 08:39:16
|
Revision: 4051
http://openvrml.svn.sourceforge.net/openvrml/?rev=4051&view=rev
Author: braden
Date: 2009-11-25 08:39:02 +0000 (Wed, 25 Nov 2009)
Log Message:
-----------
Generate openvrml::node_type::do_create_type implementations using the Boost.Preprocessor library.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/libopenvrml/openvrml/node_impl_util.cpp
trunk/src/libopenvrml/openvrml/node_impl_util.h
trunk/src/node/vrml97/anchor.cpp
trunk/src/node/vrml97/appearance.cpp
trunk/src/node/vrml97/audio_clip.cpp
trunk/src/node/vrml97/background.cpp
trunk/src/node/vrml97/billboard.cpp
trunk/src/node/vrml97/box.cpp
trunk/src/node/vrml97/cad_assembly.cpp
trunk/src/node/vrml97/cad_layer.cpp
trunk/src/node/vrml97/collision.cpp
trunk/src/node/vrml97/color.cpp
trunk/src/node/vrml97/color_interpolator.cpp
trunk/src/node/vrml97/cone.cpp
trunk/src/node/vrml97/coordinate.cpp
trunk/src/node/vrml97/coordinate_interpolator.cpp
trunk/src/node/vrml97/cylinder.cpp
trunk/src/node/vrml97/cylinder_sensor.cpp
trunk/src/node/vrml97/directional_light.cpp
trunk/src/node/vrml97/elevation_grid.cpp
trunk/src/node/vrml97/extrusion.cpp
trunk/src/node/vrml97/fog.cpp
trunk/src/node/vrml97/font_style.cpp
trunk/src/node/vrml97/group.cpp
trunk/src/node/vrml97/image_texture.cpp
trunk/src/node/vrml97/indexed_face_set.cpp
trunk/src/node/vrml97/indexed_line_set.cpp
trunk/src/node/vrml97/inline.cpp
trunk/src/node/vrml97/lod.cpp
trunk/src/node/vrml97/material.cpp
trunk/src/node/vrml97/navigation_info.cpp
trunk/src/node/vrml97/normal.cpp
trunk/src/node/vrml97/normal_interpolator.cpp
trunk/src/node/vrml97/orientation_interpolator.cpp
trunk/src/node/vrml97/pixel_texture.cpp
trunk/src/node/vrml97/plane_sensor.cpp
trunk/src/node/vrml97/point_light.cpp
trunk/src/node/vrml97/point_set.cpp
trunk/src/node/vrml97/position_interpolator.cpp
trunk/src/node/vrml97/proximity_sensor.cpp
trunk/src/node/vrml97/scalar_interpolator.cpp
trunk/src/node/vrml97/shape.cpp
trunk/src/node/vrml97/sound.cpp
trunk/src/node/vrml97/sphere.cpp
trunk/src/node/vrml97/sphere_sensor.cpp
trunk/src/node/vrml97/spot_light.cpp
trunk/src/node/vrml97/switch.cpp
trunk/src/node/vrml97/text.cpp
trunk/src/node/vrml97/texture_coordinate.cpp
trunk/src/node/vrml97/texture_transform.cpp
trunk/src/node/vrml97/touch_sensor.cpp
trunk/src/node/vrml97/transform.cpp
trunk/src/node/vrml97/viewpoint.cpp
trunk/src/node/vrml97/visibility_sensor.cpp
trunk/src/node/vrml97/world_info.cpp
trunk/src/node/x3d-cad-geometry/cad_face.cpp
trunk/src/node/x3d-cad-geometry/indexed_quad_set.cpp
trunk/src/node/x3d-core/metadata_double.cpp
trunk/src/node/x3d-core/metadata_float.cpp
trunk/src/node/x3d-core/metadata_integer.cpp
trunk/src/node/x3d-core/metadata_set.cpp
trunk/src/node/x3d-core/metadata_string.cpp
trunk/src/node/x3d-dis/espdu_transform.cpp
trunk/src/node/x3d-dis/receiver_pdu.cpp
trunk/src/node/x3d-dis/signal_pdu.cpp
trunk/src/node/x3d-dis/transmitter_pdu.cpp
trunk/src/node/x3d-environmental-effects/texture_background.cpp
trunk/src/node/x3d-event-utilities/boolean_filter.cpp
trunk/src/node/x3d-event-utilities/boolean_sequencer.cpp
trunk/src/node/x3d-event-utilities/boolean_toggle.cpp
trunk/src/node/x3d-event-utilities/boolean_trigger.cpp
trunk/src/node/x3d-event-utilities/integer_sequencer.cpp
trunk/src/node/x3d-event-utilities/integer_trigger.cpp
trunk/src/node/x3d-event-utilities/time_trigger.cpp
trunk/src/node/x3d-geometry2d/arc2d.cpp
trunk/src/node/x3d-geometry2d/arc_close2d.cpp
trunk/src/node/x3d-geometry2d/circle2d.cpp
trunk/src/node/x3d-geometry2d/disk2d.cpp
trunk/src/node/x3d-geometry2d/polyline2d.cpp
trunk/src/node/x3d-geometry2d/polypoint2d.cpp
trunk/src/node/x3d-geometry2d/rectangle2d.cpp
trunk/src/node/x3d-geometry2d/triangle_set2d.cpp
trunk/src/node/x3d-geospatial/geo_coordinate.cpp
trunk/src/node/x3d-geospatial/geo_elevation_grid.cpp
trunk/src/node/x3d-geospatial/geo_location.cpp
trunk/src/node/x3d-geospatial/geo_lod.cpp
trunk/src/node/x3d-geospatial/geo_metadata.cpp
trunk/src/node/x3d-geospatial/geo_origin.cpp
trunk/src/node/x3d-geospatial/geo_position_interpolator.cpp
trunk/src/node/x3d-geospatial/geo_touch_sensor.cpp
trunk/src/node/x3d-geospatial/geo_viewpoint.cpp
trunk/src/node/x3d-grouping/static_group.cpp
trunk/src/node/x3d-h-anim/h_anim_displacer.cpp
trunk/src/node/x3d-h-anim/h_anim_humanoid.cpp
trunk/src/node/x3d-h-anim/h_anim_joint.cpp
trunk/src/node/x3d-h-anim/h_anim_segment.cpp
trunk/src/node/x3d-h-anim/h_anim_site.cpp
trunk/src/node/x3d-interpolation/coordinate_interpolator2d.cpp
trunk/src/node/x3d-interpolation/position_interpolator2d.cpp
trunk/src/node/x3d-key-device-sensor/key_sensor.cpp
trunk/src/node/x3d-key-device-sensor/string_sensor.cpp
trunk/src/node/x3d-networking/load_sensor.cpp
trunk/src/node/x3d-nurbs/contour2d.cpp
trunk/src/node/x3d-nurbs/contour_polyline2d.cpp
trunk/src/node/x3d-nurbs/coordinate_double.cpp
trunk/src/node/x3d-nurbs/nurbs_curve.cpp
trunk/src/node/x3d-nurbs/nurbs_curve2d.cpp
trunk/src/node/x3d-nurbs/nurbs_orientation_interpolator.cpp
trunk/src/node/x3d-nurbs/nurbs_patch_surface.cpp
trunk/src/node/x3d-nurbs/nurbs_position_interpolator.cpp
trunk/src/node/x3d-nurbs/nurbs_set.cpp
trunk/src/node/x3d-nurbs/nurbs_surface_interpolator.cpp
trunk/src/node/x3d-nurbs/nurbs_swept_surface.cpp
trunk/src/node/x3d-nurbs/nurbs_swung_surface.cpp
trunk/src/node/x3d-nurbs/nurbs_texture_coordinate.cpp
trunk/src/node/x3d-nurbs/nurbs_trimmed_surface.cpp
trunk/src/node/x3d-rendering/color_rgba.cpp
trunk/src/node/x3d-rendering/indexed_triangle_fan_set.cpp
trunk/src/node/x3d-rendering/indexed_triangle_set.cpp
trunk/src/node/x3d-rendering/indexed_triangle_strip_set.cpp
trunk/src/node/x3d-rendering/triangle_fan_set.cpp
trunk/src/node/x3d-rendering/triangle_set.cpp
trunk/src/node/x3d-rendering/triangle_strip_set.cpp
trunk/src/node/x3d-shape/fill_properties.cpp
trunk/src/node/x3d-shape/line_properties.cpp
trunk/src/node/x3d-texturing/multi_texture.cpp
trunk/src/node/x3d-texturing/multi_texture_coordinate.cpp
trunk/src/node/x3d-texturing/multi_texture_transform.cpp
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-11-24 23:46:54 UTC (rev 4050)
+++ trunk/ChangeLog 2009-11-25 08:39:02 UTC (rev 4051)
@@ -1,3 +1,140 @@
+2009-11-25 Braden McDaniel <br...@en...>
+
+ Generate openvrml::node_type::do_create_type implementations using
+ the Boost.Preprocessor library.
+
+ * src/libopenvrml/openvrml/node_impl_util.cpp: Added doc-comment
+ for OPENVRML_NODE_IMPL_UTIL_DEFINE_DO_CREATE_TYPE.
+ * src/libopenvrml/openvrml/node_impl_util.h: Added
+ OPENVRML_NODE_IMPL_UTIL_DEFINE_DO_CREATE_TYPE and supporting
+ macros.
+ * src/node/vrml97/anchor.cpp
+ * src/node/vrml97/appearance.cpp
+ * src/node/vrml97/audio_clip.cpp
+ * src/node/vrml97/background.cpp
+ * src/node/vrml97/billboard.cpp
+ * src/node/vrml97/box.cpp
+ * src/node/vrml97/cad_assembly.cpp
+ * src/node/vrml97/cad_layer.cpp
+ * src/node/vrml97/collision.cpp
+ * src/node/vrml97/color.cpp
+ * src/node/vrml97/color_interpolator.cpp
+ * src/node/vrml97/cone.cpp
+ * src/node/vrml97/coordinate.cpp
+ * src/node/vrml97/coordinate_interpolator.cpp
+ * src/node/vrml97/cylinder.cpp
+ * src/node/vrml97/cylinder_sensor.cpp
+ * src/node/vrml97/directional_light.cpp
+ * src/node/vrml97/elevation_grid.cpp
+ * src/node/vrml97/extrusion.cpp
+ * src/node/vrml97/fog.cpp
+ * src/node/vrml97/font_style.cpp
+ * src/node/vrml97/group.cpp
+ * src/node/vrml97/image_texture.cpp
+ * src/node/vrml97/indexed_face_set.cpp
+ * src/node/vrml97/indexed_line_set.cpp
+ * src/node/vrml97/inline.cpp
+ * src/node/vrml97/lod.cpp
+ * src/node/vrml97/material.cpp
+ * src/node/vrml97/navigation_info.cpp
+ * src/node/vrml97/normal.cpp
+ * src/node/vrml97/normal_interpolator.cpp
+ * src/node/vrml97/orientation_interpolator.cpp
+ * src/node/vrml97/pixel_texture.cpp
+ * src/node/vrml97/plane_sensor.cpp
+ * src/node/vrml97/point_light.cpp
+ * src/node/vrml97/point_set.cpp
+ * src/node/vrml97/position_interpolator.cpp
+ * src/node/vrml97/proximity_sensor.cpp
+ * src/node/vrml97/scalar_interpolator.cpp
+ * src/node/vrml97/shape.cpp
+ * src/node/vrml97/sound.cpp
+ * src/node/vrml97/sphere.cpp
+ * src/node/vrml97/sphere_sensor.cpp
+ * src/node/vrml97/spot_light.cpp
+ * src/node/vrml97/switch.cpp
+ * src/node/vrml97/text.cpp
+ * src/node/vrml97/texture_coordinate.cpp
+ * src/node/vrml97/texture_transform.cpp
+ * src/node/vrml97/touch_sensor.cpp
+ * src/node/vrml97/transform.cpp
+ * src/node/vrml97/visibility_sensor.cpp
+ * src/node/vrml97/world_info.cpp
+ * src/node/vrml97/viewpoint.cpp
+ * src/node/x3d-cad-geometry/cad_face.cpp
+ * src/node/x3d-cad-geometry/indexed_quad_set.cpp
+ * src/node/x3d-core/metadata_double.cpp
+ * src/node/x3d-core/metadata_float.cpp
+ * src/node/x3d-core/metadata_integer.cpp
+ * src/node/x3d-core/metadata_set.cpp
+ * src/node/x3d-core/metadata_string.cpp
+ * src/node/x3d-dis/espdu_transform.cpp
+ * src/node/x3d-dis/receiver_pdu.cpp
+ * src/node/x3d-dis/signal_pdu.cpp
+ * src/node/x3d-dis/transmitter_pdu.cpp
+ * src/node/x3d-environmental-effects/texture_background.cpp
+ * src/node/x3d-event-utilities/boolean_filter.cpp
+ * src/node/x3d-event-utilities/boolean_sequencer.cpp
+ * src/node/x3d-event-utilities/boolean_toggle.cpp
+ * src/node/x3d-event-utilities/boolean_trigger.cpp
+ * src/node/x3d-event-utilities/integer_sequencer.cpp
+ * src/node/x3d-event-utilities/integer_trigger.cpp
+ * src/node/x3d-event-utilities/time_trigger.cpp
+ * src/node/x3d-geometry2d/arc_close2d.cpp
+ * src/node/x3d-geometry2d/arc2d.cpp
+ * src/node/x3d-geometry2d/circle2d.cpp
+ * src/node/x3d-geometry2d/disk2d.cpp
+ * src/node/x3d-geometry2d/polyline2d.cpp
+ * src/node/x3d-geometry2d/polypoint2d.cpp
+ * src/node/x3d-geometry2d/rectangle2d.cpp
+ * src/node/x3d-geometry2d/triangle_set2d.cpp
+ * src/node/x3d-geospatial/geo_coordinate.cpp
+ * src/node/x3d-geospatial/geo_elevation_grid.cpp
+ * src/node/x3d-geospatial/geo_location.cpp
+ * src/node/x3d-geospatial/geo_lod.cpp
+ * src/node/x3d-geospatial/geo_metadata.cpp
+ * src/node/x3d-geospatial/geo_origin.cpp
+ * src/node/x3d-geospatial/geo_position_interpolator.cpp
+ * src/node/x3d-geospatial/geo_touch_sensor.cpp
+ * src/node/x3d-geospatial/geo_viewpoint.cpp
+ * src/node/x3d-grouping/static_group.cpp
+ * src/node/x3d-h-anim/h_anim_displacer.cpp
+ * src/node/x3d-h-anim/h_anim_humanoid.cpp
+ * src/node/x3d-h-anim/h_anim_joint.cpp
+ * src/node/x3d-h-anim/h_anim_segment.cpp
+ * src/node/x3d-h-anim/h_anim_site.cpp
+ * src/node/x3d-interpolation/coordinate_interpolator2d.cpp
+ * src/node/x3d-interpolation/position_interpolator2d.cpp
+ * src/node/x3d-key-device-sensor/key_sensor.cpp
+ * src/node/x3d-key-device-sensor/string_sensor.cpp
+ * src/node/x3d-networking/load_sensor.cpp
+ * src/node/x3d-nurbs/contour_polyline2d.cpp
+ * src/node/x3d-nurbs/contour2d.cpp
+ * src/node/x3d-nurbs/coordinate_double.cpp
+ * src/node/x3d-nurbs/nurbs_curve.cpp
+ * src/node/x3d-nurbs/nurbs_curve2d.cpp
+ * src/node/x3d-nurbs/nurbs_orientation_interpolator.cpp
+ * src/node/x3d-nurbs/nurbs_patch_surface.cpp
+ * src/node/x3d-nurbs/nurbs_position_interpolator.cpp
+ * src/node/x3d-nurbs/nurbs_set.cpp
+ * src/node/x3d-nurbs/nurbs_surface_interpolator.cpp
+ * src/node/x3d-nurbs/nurbs_swept_surface.cpp
+ * src/node/x3d-nurbs/nurbs_swung_surface.cpp
+ * src/node/x3d-nurbs/nurbs_texture_coordinate.cpp
+ * src/node/x3d-nurbs/nurbs_trimmed_surface.cpp
+ * src/node/x3d-rendering/color_rgba.cpp
+ * src/node/x3d-rendering/indexed_triangle_fan_set.cpp
+ * src/node/x3d-rendering/indexed_triangle_set.cpp
+ * src/node/x3d-rendering/indexed_triangle_strip_set.cpp
+ * src/node/x3d-rendering/triangle_fan_set.cpp
+ * src/node/x3d-rendering/triangle_set.cpp
+ * src/node/x3d-rendering/triangle_strip_set.cpp
+ * src/node/x3d-shape/fill_properties.cpp
+ * src/node/x3d-shape/line_properties.cpp
+ * src/node/x3d-texturing/multi_texture.cpp
+ * src/node/x3d-texturing/multi_texture_coordinate.cpp
+ * src/node/x3d-texturing/multi_texture_transform.cpp
+
2009-11-24 Braden McDaniel <br...@en...>
* src/libopenvrml/openvrml/node.h
Modified: trunk/src/libopenvrml/openvrml/node_impl_util.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/node_impl_util.cpp 2009-11-24 23:46:54 UTC (rev 4050)
+++ trunk/src/libopenvrml/openvrml/node_impl_util.cpp 2009-11-25 08:39:02 UTC (rev 4051)
@@ -27,6 +27,54 @@
*/
/**
+ * @def OPENVRML_NODE_IMPL_UTIL_DEFINE_DO_CREATE_TYPE(namespace_scope, node_metatype_type, node_instance_type, interface_seq)
+ *
+ * @param namespace_scope the namespace scope where @p node_instance_type
+ * is defined.
+ * @param node_metatype_type the name of the concrete
+ * @c openvrml::node_metatype type for the node
+ * implementation.
+ * @param node_instance_type the name of the concrete @c openvrml::node type
+ * for the node implementation.
+ * @param interface_seq a <a href="http://www.boost.org/doc/libs/release/libs/preprocessor/doc/data/sequences.html">
+ * Boost.Preprocessor sequence</a> of
+ * <a href="http://www.boost.org/doc/libs/release/libs/preprocessor/doc/data/tuples.html">tuples</a>
+ * defining the supported interfaces for the node
+ * implementation and the @p node_instance_type
+ * member that implements them.
+ *
+ * @p interface_seq consists of tuples of the following form:
+ * <pre>
+ * (@e interface-type, @e value-type, @e interface-id, @e handler)
+ * </pre>
+ *
+ * @e interface-type and @e value-type are both all lower-case; @e
+ * interface-id is a string literal; and @e handler is the identifier of the
+ * member of @p node_instance_type that implements the interface. For
+ * example:
+ *
+ * @code
+ * # define MY_NODE_INTERFACE_SEQ \
+ * ((eventin, sfbool, "set_wiggly", set_wiggly_listener)) \
+ * ((field, sfbool, "wiggly", wiggly)) \
+ * ((exposedfield, mffloat, "heightField", height_field))
+ * @endcode
+ *
+ * @c MY_NODE_INTERFACE_SEQ is then used to instantiate
+ * @c OPENVRML_NODE_IMPL_UTIL_DEFINE_DO_CREATE_TYPE:
+ *
+ * @code
+ * OPENVRML_NODE_IMPL_UTIL_DEFINE_DO_CREATE_TYPE(my_namespace,
+ * my_node_metatype,
+ * my_node,
+ * MY_NODE_INTERFACE_SEQ)
+ * @endcode
+ *
+ * In this example, @c set_wiggly_listener, @c wiggly, and @c height_field are
+ * all members of the @c my_node class.
+ */
+
+/**
* @namespace openvrml::node_impl_util
*
* @brief Utility classes to facilitate node implementations.
Modified: trunk/src/libopenvrml/openvrml/node_impl_util.h
===================================================================
--- trunk/src/libopenvrml/openvrml/node_impl_util.h 2009-11-24 23:46:54 UTC (rev 4050)
+++ trunk/src/libopenvrml/openvrml/node_impl_util.h 2009-11-25 08:39:02 UTC (rev 4051)
@@ -2,7 +2,7 @@
//
// OpenVRML
//
-// Copyright 2005, 2006, 2007, 2008 Braden McDaniel
+// Copyright 2005, 2006, 2007, 2008, 2009 Braden McDaniel
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
@@ -21,9 +21,86 @@
# ifndef OPENVRML_NODE_IMPL_UTIL
# define OPENVRML_NODE_IMPL_UTIL
+# include <openvrml/exposedfield.h>
+# include <boost/preprocessor/cat.hpp>
+# include <boost/preprocessor/punctuation/comma_if.hpp>
+# include <boost/preprocessor/seq/for_each.hpp>
+# include <boost/preprocessor/seq/for_each_i.hpp>
+# include <boost/preprocessor/seq/size.hpp>
+# include <boost/preprocessor/tuple/elem.hpp>
# include <stack>
-# include <openvrml/exposedfield.h>
+# define OPENVRML_NODE_INTERFACE_TUPLE_ELEM(index, tuple) \
+ BOOST_PP_TUPLE_ELEM(4, index, tuple)
+
+# define OPENVRML_DEFINE_NODE_INTERFACE(interface_tuple) \
+ openvrml::node_interface(openvrml::node_interface::BOOST_PP_CAT(OPENVRML_NODE_INTERFACE_TUPLE_ELEM(0, interface_tuple), _id), \
+ openvrml::field_value::BOOST_PP_CAT(OPENVRML_NODE_INTERFACE_TUPLE_ELEM(1, interface_tuple), _id), \
+ OPENVRML_NODE_INTERFACE_TUPLE_ELEM(2, interface_tuple))
+
+# define OPENVRML_DEFINE_SUPPORTED_INTERFACES_ELEM(r, data, i, elem) \
+ BOOST_PP_COMMA_IF(i) OPENVRML_DEFINE_NODE_INTERFACE(elem)
+
+# define OPENVRML_SUPPORTED_INTERFACES_TYPE(interface_seq) \
+ boost::array<openvrml::node_interface, BOOST_PP_SEQ_SIZE(interface_seq)>
+
+# define OPENVRML_ADD_INTERFACE(node_type_obj, interface_type, supported_interface, node, handler) \
+ node_type_obj.BOOST_PP_CAT(add_, interface_type)(supported_interface->field_type, \
+ supported_interface->id, \
+ &node::handler)
+
+# define OPENVRML_ADD_INTERFACE_TUPLE(node_type_obj, node_instance_type, node_interface, interface_tuple) \
+ OPENVRML_ADD_INTERFACE(node_type_obj, \
+ OPENVRML_NODE_INTERFACE_TUPLE_ELEM(0, interface_tuple), \
+ node_interface, \
+ node_instance_type, \
+ OPENVRML_NODE_INTERFACE_TUPLE_ELEM(3, interface_tuple))
+
+# define OPENVRML_ADD_INTERFACE_ALTERNATIVE(r, data, elem) \
+ if (*BOOST_PP_TUPLE_ELEM(4, 0, data) == *++BOOST_PP_TUPLE_ELEM(4, 1, data)) { \
+ OPENVRML_ADD_INTERFACE_TUPLE(BOOST_PP_TUPLE_ELEM(4, 2, data), \
+ BOOST_PP_TUPLE_ELEM(4, 3, data), \
+ BOOST_PP_TUPLE_ELEM(4, 1, data), \
+ elem); \
+ } else
+
+# define OPENVRML_NODE_IMPL_UTIL_DEFINE_DO_CREATE_TYPE(namespace_scope, node_metatype_type, node_instance_type, interface_seq) \
+ const boost::shared_ptr<openvrml::node_type> \
+ namespace_scope::node_metatype_type:: \
+ do_create_type(const std::string & id, \
+ const openvrml::node_interface_set & interfaces) const \
+ OPENVRML_THROW2(openvrml::unsupported_interface, std::bad_alloc) \
+ { \
+ typedef OPENVRML_SUPPORTED_INTERFACES_TYPE(interface_seq) \
+ supported_interfaces_t; \
+ static const supported_interfaces_t supported_interfaces = { \
+ BOOST_PP_SEQ_FOR_EACH_I( \
+ OPENVRML_DEFINE_SUPPORTED_INTERFACES_ELEM, \
+ ~, \
+ interface_seq) \
+ }; \
+ typedef openvrml::node_impl_util::node_type_impl<node_instance_type> \
+ node_type_t; \
+ const boost::shared_ptr<openvrml::node_type> \
+ type(new node_type_t(*this, id)); \
+ node_type_t & node_type = static_cast<node_type_t &>(*type); \
+ for (openvrml::node_interface_set::const_iterator interface_ = \
+ interfaces.begin(); \
+ interface_ != interfaces.end(); \
+ ++interface_) { \
+ supported_interfaces_t::const_iterator supported_interface = \
+ supported_interfaces.begin() - 1; \
+ BOOST_PP_SEQ_FOR_EACH( \
+ OPENVRML_ADD_INTERFACE_ALTERNATIVE, \
+ (interface_, supported_interface, node_type, node_instance_type), \
+ interface_seq) \
+ { \
+ throw openvrml::unsupported_interface(*interface_); \
+ } \
+ } \
+ return type; \
+ }
+
namespace openvrml {
namespace node_impl_util {
Modified: trunk/src/node/vrml97/anchor.cpp
===================================================================
--- trunk/src/node/vrml97/anchor.cpp 2009-11-24 23:46:54 UTC (rev 4050)
+++ trunk/src/node/vrml97/anchor.cpp 2009-11-25 08:39:02 UTC (rev 4051)
@@ -3,7 +3,7 @@
// OpenVRML
//
// Copyright 1998 Chris Morley
-// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007 Braden McDaniel
+// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Braden McDaniel
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
@@ -174,106 +174,18 @@
openvrml_node_vrml97::anchor_metatype::~anchor_metatype() OPENVRML_NOTHROW
{}
-/**
- * @brief Create a node_type.
- *
- * @param id the name for the new node_type.
- * @param interfaces the interfaces for the new node_type.
- *
- * @return a node_type_ptr to a node_type capable of creating Anchor nodes.
- *
- * @exception openvrml::unsupported_interface if @p interfaces includes an interface
- * not supported by anchor_metatype.
- * @exception std::bad_alloc if memory allocation fails.
- */
-const boost::shared_ptr<openvrml::node_type>
-openvrml_node_vrml97::anchor_metatype::
-do_create_type(const std::string & id,
- const openvrml::node_interface_set & interfaces) const
- OPENVRML_THROW2(openvrml::unsupported_interface, std::bad_alloc)
-{
- using namespace openvrml;
- using namespace openvrml::node_impl_util;
+# define ANCHOR_INTERFACE_SEQ \
+ ((eventin, mfnode, "addChildren", add_children_listener_)) \
+ ((eventin, mfnode, "removeChildren", remove_children_listener_)) \
+ ((exposedfield, mfnode, "children", children_)) \
+ ((exposedfield, sfstring, "description", description_)) \
+ ((exposedfield, mfstring, "parameter", parameter_)) \
+ ((exposedfield, mfstring, "url", url_)) \
+ ((field, sfvec3f, "bboxCenter", bbox_center_)) \
+ ((field, sfvec3f, "bboxSize", bbox_size_)) \
+ ((exposedfield, sfnode, "metadata", metadata))
- typedef boost::array<node_interface, 9> supported_interfaces_t;
- static const supported_interfaces_t supported_interfaces = {
- node_interface(node_interface::eventin_id,
- field_value::mfnode_id,
- "addChildren"),
- node_interface(node_interface::eventin_id,
- field_value::mfnode_id,
- "removeChildren"),
- node_interface(node_interface::exposedfield_id,
- field_value::mfnode_id,
- "children"),
- node_interface(node_interface::exposedfield_id,
- field_value::sfstring_id,
- "description"),
- node_interface(node_interface::exposedfield_id,
- field_value::mfstring_id,
- "parameter"),
- node_interface(node_interface::exposedfield_id,
- field_value::mfstring_id,
- "url"),
- node_interface(node_interface::field_id,
- field_value::sfvec3f_id,
- "bboxCenter"),
- node_interface(node_interface::field_id,
- field_value::sfvec3f_id,
- "bboxSize"),
- node_interface(node_interface::exposedfield_id,
- field_value::sfnode_id,
- "metadata")
- };
-
- typedef node_impl_util::node_type_impl<anchor_node> node_type_t;
-
- const boost::shared_ptr<node_type> type(new node_type_t(*this, id));
- node_type_t & anchorNodeType = static_cast<node_type_t &>(*type);
- for (node_interface_set::const_iterator interface_ = interfaces.begin();
- interface_ != interfaces.end();
- ++interface_) {
- supported_interfaces_t::const_iterator supported_interface =
- supported_interfaces.begin() - 1;
- if (*interface_ == *++supported_interface) {
- anchorNodeType.add_eventin(supported_interface->field_type,
- supported_interface->id,
- &anchor_node::add_children_listener_);
- } else if (*interface_ == *++supported_interface) {
- anchorNodeType.add_eventin(supported_interface->field_type,
- supported_interface->id,
- &anchor_node::remove_children_listener_);
- } else if (*interface_ == *++supported_interface) {
- anchorNodeType.add_exposedfield(supported_interface->field_type,
- supported_interface->id,
- &anchor_node::children_);
- } else if (*interface_ == *++supported_interface) {
- anchorNodeType.add_exposedfield(supported_interface->field_type,
- supported_interface->id,
- &anchor_node::description_);
- } else if (*interface_ == *++supported_interface) {
- anchorNodeType.add_exposedfield(supported_interface->field_type,
- supported_interface->id,
- &anchor_node::parameter_);
- } else if (*interface_ == *++supported_interface) {
- anchorNodeType.add_exposedfield(supported_interface->field_type,
- supported_interface->id,
- &anchor_node::url_);
- } else if (*interface_ == *++supported_interface) {
- anchorNodeType.add_field(supported_interface->field_type,
- supported_interface->id,
- &anchor_node::bbox_center_);
- } else if (*interface_ == *++supported_interface) {
- anchorNodeType.add_field(supported_interface->field_type,
- supported_interface->id,
- &anchor_node::bbox_size_);
- } else if (*interface_ == *++supported_interface) {
- anchorNodeType.add_exposedfield(supported_interface->field_type,
- supported_interface->id,
- &anchor_node::metadata);
- } else {
- throw unsupported_interface(*interface_);
- }
- }
- return type;
-}
+OPENVRML_NODE_IMPL_UTIL_DEFINE_DO_CREATE_TYPE(openvrml_node_vrml97,
+ anchor_metatype,
+ anchor_node,
+ ANCHOR_INTERFACE_SEQ)
Modified: trunk/src/node/vrml97/appearance.cpp
===================================================================
--- trunk/src/node/vrml97/appearance.cpp 2009-11-24 23:46:54 UTC (rev 4050)
+++ trunk/src/node/vrml97/appearance.cpp 2009-11-25 08:39:02 UTC (rev 4051)
@@ -3,7 +3,7 @@
// OpenVRML
//
// Copyright 1998 Chris Morley
-// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007 Braden McDaniel
+// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Braden McDaniel
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
@@ -269,94 +269,15 @@
OPENVRML_NOTHROW
{}
-/**
- * @brief Create a node_type.
- *
- * @param id the name for the new node_type.
- * @param interfaces the interfaces for the new node_type.
- *
- * @return a boost::shared_ptr<node_type> to a node_type capable of
- * creating Appearance nodes.
- *
- * @exception openvrml::unsupported_interface if @p interfaces includes an interface
- * not supported by appearance_metatype.
- * @exception std::bad_alloc if memory allocation fails.
- */
-const boost::shared_ptr<openvrml::node_type>
-openvrml_node_vrml97::appearance_metatype::
-do_create_type(const std::string & id,
- const openvrml::node_interface_set & interfaces) const
- OPENVRML_THROW2(openvrml::unsupported_interface, std::bad_alloc)
-{
- using openvrml::node_interface;
- using openvrml::node_interface_set;
- using openvrml::node_type;
- using openvrml::field_value;
- using openvrml::sfnode;
- using openvrml::unsupported_interface;
- using namespace openvrml::node_impl_util;
+# define APPEARANCE_INTERFACE_SEQ \
+ ((exposedfield, sfnode, "material", material_)) \
+ ((exposedfield, sfnode, "texture", texture_)) \
+ ((exposedfield, sfnode, "textureTransform", texture_transform_)) \
+ ((exposedfield, sfnode, "metadata", metadata)) \
+ ((exposedfield, sfnode, "fillProperties", fill_properties_)) \
+ ((exposedfield, sfnode, "lineProperties", line_properties_))
- typedef boost::array<node_interface, 6> supported_interfaces_t;
- static const supported_interfaces_t supported_interfaces = {
- node_interface(node_interface::exposedfield_id,
- field_value::sfnode_id,
- "material"),
- node_interface(node_interface::exposedfield_id,
- field_value::sfnode_id,
- "texture"),
- node_interface(node_interface::exposedfield_id,
- field_value::sfnode_id,
- "textureTransform"),
- node_interface(node_interface::exposedfield_id,
- field_value::sfnode_id,
- "metadata"),
- node_interface(node_interface::exposedfield_id,
- field_value::sfnode_id,
- "fillProperties"),
- node_interface(node_interface::exposedfield_id,
- field_value::sfnode_id,
- "lineProperties")
- };
-
- typedef node_type_impl<appearance_node> node_type_t;
-
- const boost::shared_ptr<node_type> type(new node_type_t(*this, id));
- node_type_t & appearanceNodeType = static_cast<node_type_t &>(*type);
- for (node_interface_set::const_iterator interface_ = interfaces.begin();
- interface_ != interfaces.end();
- ++interface_) {
- supported_interfaces_t::const_iterator supported_interface =
- supported_interfaces.begin() - 1;
- if (*interface_ == *++supported_interface) {
- appearanceNodeType.add_exposedfield(supported_interface->field_type,
- supported_interface->id,
- &appearance_node::material_);
- } else if (*interface_ == *++supported_interface) {
- appearanceNodeType.add_exposedfield(supported_interface->field_type,
- supported_interface->id,
- &appearance_node::texture_);
- } else if (*interface_ == *++supported_interface) {
- appearanceNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &appearance_node::texture_transform_);
- } else if (*interface_ == *++supported_interface) {
- appearanceNodeType.add_exposedfield(supported_interface->field_type,
- supported_interface->id,
- &appearance_node::metadata);
- } else if (*interface_ == *++supported_interface) {
- appearanceNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &appearance_node::fill_properties_);
- } else if (*interface_ == *++supported_interface) {
- appearanceNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &appearance_node::line_properties_);
- } else {
- throw unsupported_interface(*interface_);
- }
- }
- return type;
-}
+OPENVRML_NODE_IMPL_UTIL_DEFINE_DO_CREATE_TYPE(openvrml_node_vrml97,
+ appearance_metatype,
+ appearance_node,
+ APPEARANCE_INTERFACE_SEQ)
Modified: trunk/src/node/vrml97/audio_clip.cpp
===================================================================
--- trunk/src/node/vrml97/audio_clip.cpp 2009-11-24 23:46:54 UTC (rev 4050)
+++ trunk/src/node/vrml97/audio_clip.cpp 2009-11-25 08:39:02 UTC (rev 4051)
@@ -3,7 +3,7 @@
// OpenVRML
//
// Copyright 1998 Chris Morley
-// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007 Braden McDaniel
+// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Braden McDaniel
// Copyright 2002 S. K. Bose
//
// This library is free software; you can redistribute it and/or modify it
@@ -236,148 +236,22 @@
OPENVRML_NOTHROW
{}
-/**
- * @brief Create a node_type.
- *
- * @param id the name for the new node_type.
- * @param interfaces the interfaces for the new node_type.
- *
- * @return a boost::shared_ptr<node_type> to a node_type capable of
- * creating AudioClip nodes.
- *
- * @exception openvrml::unsupported_interface if @p interfaces includes an interface
- * not supported by audio_clip_metatype.
- * @exception std::bad_alloc if memory allocation fails.
- */
-const boost::shared_ptr<openvrml::node_type>
-openvrml_node_vrml97::audio_clip_metatype::
-do_create_type(const std::string & id,
- const openvrml::node_interface_set & interfaces) const
- OPENVRML_THROW2(openvrml::unsupported_interface, std::bad_alloc)
-{
- using namespace openvrml;
- using namespace openvrml::node_impl_util;
+# define AUDIO_CLIP_INTERFACE_SEQ \
+ ((exposedfield, sfstring, "description", description_)) \
+ ((exposedfield, sfbool, "loop", loop_)) \
+ ((exposedfield, sffloat, "pitch", pitch_)) \
+ ((exposedfield, sftime, "startTime", start_time_)) \
+ ((exposedfield, sftime, "stopTime", stop_time_)) \
+ ((exposedfield, mfstring, "url", url_)) \
+ ((eventout, sftime, "duration_changed", duration_changed_emitter_)) \
+ ((eventout, sfbool, "isActive", is_active_emitter_)) \
+ ((exposedfield, sfnode, "metadata", metadata)) \
+ ((exposedfield, sftime, "pauseTime", pause_time_)) \
+ ((exposedfield, sftime, "resumeTime", resume_time_)) \
+ ((eventout, sftime, "elapsedTime", elapsed_time_emitter_)) \
+ ((eventout, sfbool, "isPaused", is_paused_emitter_))
- typedef boost::array<node_interface, 13> supported_interfaces_t;
- static const supported_interfaces_t supported_interfaces = {
- node_interface(node_interface::exposedfield_id,
- field_value::sfstring_id,
- "description"),
- node_interface(node_interface::exposedfield_id,
- field_value::sfbool_id,
- "loop"),
- node_interface(node_interface::exposedfield_id,
- field_value::sffloat_id,
- "pitch"),
- node_interface(node_interface::exposedfield_id,
- field_value::sftime_id,
- "startTime"),
- node_interface(node_interface::exposedfield_id,
- field_value::sftime_id,
- "stopTime"),
- node_interface(node_interface::exposedfield_id,
- field_value::mfstring_id,
- "url"),
- node_interface(node_interface::eventout_id,
- field_value::sftime_id,
- "duration_changed"),
- node_interface(node_interface::eventout_id,
- field_value::sfbool_id,
- "isActive"),
- node_interface(node_interface::exposedfield_id,
- field_value::sfnode_id,
- "metadata"),
- node_interface(node_interface::exposedfield_id,
- field_value::sftime_id,
- "pauseTime"),
- node_interface(node_interface::exposedfield_id,
- field_value::sftime_id,
- "resumeTime"),
- node_interface(node_interface::eventout_id,
- field_value::sftime_id,
- "elapsedTime"),
- node_interface(node_interface::eventout_id,
- field_value::sfbool_id,
- "isPaused")
- };
-
- typedef node_impl_util::node_type_impl<audio_clip_node> node_type_t;
-
- const boost::shared_ptr<node_type> type(new node_type_t(*this, id));
- node_type_t & audioClipNodeType = static_cast<node_type_t &>(*type);
- for (node_interface_set::const_iterator interface_ = interfaces.begin();
- interface_ != interfaces.end();
- ++interface_) {
- supported_interfaces_t::const_iterator supported_interface =
- supported_interfaces.begin() - 1;
- if (*interface_ == *++supported_interface) {
- audioClipNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &audio_clip_node::description_);
- } else if (*interface_ == *++supported_interface) {
- audioClipNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &audio_clip_node::loop_);
- } else if (*interface_ == *++supported_interface) {
- audioClipNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &audio_clip_node::pitch_);
- } else if (*interface_ == *++supported_interface) {
- audioClipNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &audio_clip_node::start_time_);
- } else if (*interface_ == *++supported_interface) {
- audioClipNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &audio_clip_node::stop_time_);
- } else if (*interface_ == *++supported_interface) {
- audioClipNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &audio_clip_node::url_);
- } else if (*interface_ == *++supported_interface) {
- audioClipNodeType.add_eventout(
- supported_interface->field_type,
- supported_interface->id,
- &audio_clip_node::duration_changed_emitter_);
- } else if (*interface_ == *++supported_interface) {
- audioClipNodeType.add_eventout(
- supported_interface->field_type,
- supported_interface->id,
- &audio_clip_node::is_active_emitter_);
- } else if (*interface_ == *++supported_interface) {
- audioClipNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &audio_clip_node::metadata);
- } else if (*interface_ == *++supported_interface) {
- audioClipNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &audio_clip_node::pause_time_);
- } else if (*interface_ == *++supported_interface) {
- audioClipNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &audio_clip_node::resume_time_);
- } else if (*interface_ == *++supported_interface) {
- audioClipNodeType.add_eventout(
- supported_interface->field_type,
- supported_interface->id,
- &audio_clip_node::elapsed_time_emitter_);
- } else if (*interface_ == *++supported_interface) {
- audioClipNodeType.add_eventout(
- supported_interface->field_type,
- supported_interface->id,
- &audio_clip_node::is_paused_emitter_);
- } else {
- throw unsupported_interface(*interface_);
- }
- }
- return type;
-}
+OPENVRML_NODE_IMPL_UTIL_DEFINE_DO_CREATE_TYPE(openvrml_node_vrml97,
+ audio_clip_metatype,
+ audio_clip_node,
+ AUDIO_CLIP_INTERFACE_SEQ)
Modified: trunk/src/node/vrml97/background.cpp
===================================================================
--- trunk/src/node/vrml97/background.cpp 2009-11-24 23:46:54 UTC (rev 4050)
+++ trunk/src/node/vrml97/background.cpp 2009-11-25 08:39:02 UTC (rev 4051)
@@ -3,7 +3,7 @@
// OpenVRML
//
// Copyright 1998 Chris Morley
-// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007 Braden McDaniel
+// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Braden McDaniel
// Copyright 2002 S. K. Bose
//
// This library is free software; you can redistribute it and/or modify it
@@ -244,160 +244,27 @@
}
}
-/**
- * @brief Create a node_type.
- *
- * @param id the name for the new @c node_type.
- * @param interfaces the interfaces for the new @c node_type.
- *
- * @return a @c boost::shared_ptr<node_type> to a @c node_type capable of
- * creating Background nodes.
- *
- * @exception openvrml::unsupported_interface if @p interfaces includes an interface
- * not supported by @c background_metatype.
- * @exception std::bad_alloc if memory allocation fails.
- */
-const boost::shared_ptr<openvrml::node_type>
-openvrml_node_vrml97::background_metatype::
-do_create_type(const std::string & id,
- const openvrml::node_interface_set & interfaces) const
- OPENVRML_THROW2(openvrml::unsupported_interface, std::bad_alloc)
-{
- using namespace openvrml;
- using namespace openvrml::node_impl_util;
+# define BACKGROUND_INTERFACE_SEQ \
+ ((eventin, sfbool, "set_bind", set_bind_listener_)) \
+ ((exposedfield, mffloat, "groundAngle", ground_angle_)) \
+ ((exposedfield, mfcolor, "groundColor", ground_color_)) \
+ ((exposedfield, mfstring, "backUrl", back_url_)) \
+ ((exposedfield, mfstring, "bottomUrl", bottom_url_)) \
+ ((exposedfield, mfstring, "frontUrl", front_url_)) \
+ ((exposedfield, mfstring, "leftUrl", left_url_)) \
+ ((exposedfield, mfstring, "rightUrl", right_url_)) \
+ ((exposedfield, mfstring, "topUrl", top_url_)) \
+ ((exposedfield, mffloat, "skyAngle", sky_angle_)) \
+ ((exposedfield, mfcolor, "skyColor", sky_color_)) \
+ ((eventout, sfbool, "isBound", is_bound_emitter_)) \
+ ((exposedfield, sfnode, "metadata", metadata)) \
+ ((eventout, sftime, "bindTime", bind_time_emitter_))
- typedef boost::array<node_interface, 14> supported_interfaces_t;
- static const supported_interfaces_t supported_interfaces = {
- node_interface(node_interface::eventin_id,
- field_value::sfbool_id,
- "set_bind"),
- node_interface(node_interface::exposedfield_id,
- field_value::mffloat_id,
- "groundAngle"),
- node_interface(node_interface::exposedfield_id,
- field_value::mfcolor_id,
- "groundColor"),
- node_interface(node_interface::exposedfield_id,
- field_value::mfstring_id,
- "backUrl"),
- node_interface(node_interface::exposedfield_id,
- field_value::mfstring_id,
- "bottomUrl"),
- node_interface(node_interface::exposedfield_id,
- field_value::mfstring_id,
- "frontUrl"),
- node_interface(node_interface::exposedfield_id,
- field_value::mfstring_id,
- "leftUrl"),
- node_interface(node_interface::exposedfield_id,
- field_value::mfstring_id,
- "rightUrl"),
- node_interface(node_interface::exposedfield_id,
- field_value::mfstring_id,
- "topUrl"),
- node_interface(node_interface::exposedfield_id,
- field_value::mffloat_id,
- "skyAngle"),
- node_interface(node_interface::exposedfield_id,
- field_value::mfcolor_id,
- "skyColor"),
- node_interface(node_interface::eventout_id,
- field_value::sfbool_id,
- "isBound"),
- node_interface(node_interface::exposedfield_id,
- field_value::sfnode_id,
- "metadata"),
- node_interface(node_interface::eventout_id,
- field_value::sftime_id,
- "bindTime")
- };
+OPENVRML_NODE_IMPL_UTIL_DEFINE_DO_CREATE_TYPE(openvrml_node_vrml97,
+ background_metatype,
+ background_node,
+ BACKGROUND_INTERFACE_SEQ)
- typedef node_impl_util::node_type_impl<background_node> node_type_t;
-
- const boost::shared_ptr<node_type> type(new node_type_t(*this, id));
- node_type_t & backgroundNodeType = static_cast<node_type_t &>(*type);
- for (node_interface_set::const_iterator interface_(interfaces.begin());
- interface_ != interfaces.end();
- ++interface_) {
- supported_interfaces_t::const_iterator supported_interface =
- supported_interfaces.begin() - 1;
- if (*interface_ == *++supported_interface) {
- backgroundNodeType.add_eventin(
- supported_interface->field_type,
- supported_interface->id,
- &background_node::set_bind_listener_);
- } else if (*interface_ == *++supported_interface) {
- backgroundNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &background_node::ground_angle_);
- } else if (*interface_ == *++supported_interface) {
- backgroundNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &background_node::ground_color_);
- } else if (*interface_ == *++supported_interface) {
- backgroundNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &background_node::back_url_);
- } else if (*interface_ == *++supported_interface) {
- backgroundNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &background_node::bottom_url_);
- } else if (*interface_ == *++supported_interface) {
- backgroundNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &background_node::front_url_);
- } else if (*interface_ == *++supported_interface) {
- backgroundNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &background_node::left_url_);
- } else if (*interface_ == *++supported_interface) {
- backgroundNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &background_node::right_url_);
- } else if (*interface_ == *++supported_interface) {
- backgroundNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &background_node::top_url_);
- } else if (*interface_ == *++supported_interface) {
- backgroundNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &background_node::sky_angle_);
- } else if (*interface_ == *++supported_interface) {
- backgroundNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &background_node::sky_color_);
- } else if (*interface_ == *++supported_interface) {
- backgroundNodeType.add_eventout(
- supported_interface->field_type,
- supported_interface->id,
- &background_node::is_bound_emitter_);
- } else if (*interface_ == *++supported_interface) {
- backgroundNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &background_node::metadata);
- } else if (*interface_ == *++supported_interface) {
- backgroundNodeType.add_eventout(
- supported_interface->field_type,
- supported_interface->id,
- &background_node::bind_time_emitter_);
- } else {
- throw unsupported_interface(*interface_);
- }
- }
- return type;
-}
-
/**
* @class openvrml_node_vrml97::background_node
*
Modified: trunk/src/node/vrml97/billboard.cpp
===================================================================
--- trunk/src/node/vrml97/billboard.cpp 2009-11-24 23:46:54 UTC (rev 4050)
+++ trunk/src/node/vrml97/billboard.cpp 2009-11-25 08:39:02 UTC (rev 4051)
@@ -3,7 +3,7 @@
// OpenVRML
//
// Copyright 1998 Chris Morley
-// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007 Braden McDaniel
+// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Braden McDaniel
// Copyright 2002 S. K. Bose
//
// This library is free software; you can redistribute it and/or modify it
@@ -240,97 +240,16 @@
OPENVRML_NOTHROW
{}
-/**
- * @brief Create a node_type.
- *
- * @param id the name for the new node_type.
- * @param interfaces the interfaces for the new node_type.
- *
- * @return a boost::shared_ptr<node_type> to a node_type capable of
- * creating Billboard nodes.
- *
- * @exception openvrml::unsupported_interface if @p interfaces includes an
- * interface not supported by
- * @c billboard_metatype.
- * @exception std::bad_alloc if memory allocation fails.
- */
-const boost::shared_ptr<openvrml::node_type>
-openvrml_node_vrml97::billboard_metatype::
-do_create_type(const std::string & id,
- const openvrml::node_interface_set & interfaces) const
- OPENVRML_THROW2(openvrml::unsupported_interface, std::bad_alloc)
-{
- using namespace openvrml;
- using namespace openvrml::node_impl_util;
+# define BILLBOARD_INTERFACE_SEQ \
+ ((eventin, mfnode, "addChildren", add_children_listener_)) \
+ ((eventin, mfnode, "removeChildren", remove_children_listener_)) \
+ ((exposedfield, sfvec3f, "axisOfRotation", axis_of_rotation_)) \
+ ((exposedfield, mfnode, "children", children_)) \
+ ((field, sfvec3f, "bboxCenter", bbox_center_)) \
+ ((field, sfvec3f, "bboxSize", bbox_size_)) \
+ ((exposedfield, sfnode, "metadata", metadata))
- typedef boost::array<node_interface, 7> supported_interfaces_t;
- static const supported_interfaces_t supported_interfaces = {
- node_interface(node_interface::eventin_id,
- field_value::mfnode_id,
- "addChildren"),
- node_interface(node_interface::eventin_id,
- field_value::mfnode_id,
- "removeChildren"),
- node_interface(node_interface::exposedfield_id,
- field_value::sfvec3f_id,
- "axisOfRotation"),
- node_interface(node_interface::exposedfield_id,
- field_value::mfnode_id,
- "children"),
- node_interface(node_interface::field_id,
- field_value::sfvec3f_id,
- "bboxCenter"),
- node_interface(node_interface::field_id,
- field_value::sfvec3f_id,
- "bboxSize"),
- node_interface(node_interface::exposedfield_id,
- field_value::sfnode_id,
- "metadata")
- };
-
- typedef node_impl_util::node_type_impl<billboard_node> node_type_t;
-
- const boost::shared_ptr<node_type> type(new node_type_t(*this, id));
- node_type_t & billboardNodeType = static_cast<node_type_t &>(*type);
- for (node_interface_set::const_iterator interface_(interfaces.begin());
- interface_ != interfaces.end();
- ++interface_) {
- supported_interfaces_t::const_iterator supported_interface =
- supported_interfaces.begin() - 1;
- if (*interface_ == *++supported_interface) {
- billboardNodeType.add_eventin(
- supported_interface->field_type,
- supported_interface->id,
- &billboard_node::add_children_listener_);
- } else if (*interface_ == *++supported_interface) {
- billboardNodeType.add_eventin(
- supported_interface->field_type,
- supported_interface->id,
- &billboard_node::remove_children_listener_);
- } else if (*interface_ == *++supported_interface) {
- billboardNodeType.add_exposedfield(
- supported_interface->field_type,
- supported_interface->id,
- &billboard_node::axis_of_rotation_);
- } else if (*interface_ == *++supported_interface) {
- billboardNodeType.add_exposedfield(supported_interface->field_type,
- supported_interface->id,
- &billboard_node::children_);
- } else if (*interface_ == *++supported_interface) {
- billboardNodeType.add_field(supported_interface->field_type,
- supported_interface->id,
- &billboard_node::bbox_center_);
- } else if (*interface_ == *++supported_interface) {
- billboardNodeType.add_field(supported_interface->field_type,
- supported_interface->id,
- &billboard_node::bbox_size_);
- } else if (*interface_ == *++supported_interface) {
- billboardNodeType.add_exposedfield(supported_interface->field_type,
- supported_interface->id,
- &billboard_node::metadata);
- } else {
- throw unsupported_interface(*interface_);
- }
- }
- return type;
-}
+OPENVRML_NODE_IMPL_UTIL_DEFINE_DO_CREATE_TYPE(openvrml_node_vrml97,
+ billboard_metatype,
+ billboard_node,
+ BILLBOARD_INTERFACE_SEQ)
Modified: trunk/src/node/vrml97/box.cpp
===================================================================
--- trunk/src/node/vrml97/box.cpp 2009-11-24 23:46:54 UTC (rev 4050)
+++ trunk/src/node/vrml97/box.cpp 2009-11-25 08:39:02 UTC (rev 4051)
@@ -3,7 +3,7 @@
// OpenVRML
//
// Copyright 1998 Chris Morley
-// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007 Braden McDaniel
+// Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2009 Braden McDaniel
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by
@@ -154,66 +154,12 @@
openvrml_node_vrml97::box_metatype::~box_metatype() OPENVRML_NOTHROW
{}
-/**
- * @brief Create a node_type.
- *
- * @param id the name for the new node_type.
- * @param interfaces the interfaces for the new node_type.
- *
- * @return a boost::shared_ptr<node_type> to a node_type capable of
- * creating Box nodes.
- *
- * @exception openvrml::unsupported_interface if @p interfaces includes an
- * interface not supported by
- * @c box_metatype.
- * @exception std::bad_alloc if memory allocation fails.
- */
-const boost::shared_ptr<openvrml::node_type>
-openvrml_node_vrml97::box_metatype::
-do_create_type(const std::string & id,
- const openvrml::node_interface_set & interfaces) const
- OPENVRML_THROW2(openvrml::unsupported_interface, std::bad_alloc)
-{
- using namespace openvrml;
- using namespace openvrml::node_impl_util;
+# define BOX_INTERFACE_SEQ \
+ ((field, sfvec3f, "size", size)) \
+ ((exposedfield, sfnode, "metadata", metadata)) \
+ ((field, sfbool, "solid", solid_))
- typedef boost::array<node_interface, 3> supported_interfaces_t;
- static const supported_interfaces_t supported_interfaces = {
- node_interface(node_interface::field_id,
- field_value::sfvec3f_id,
- "size"),
- node_interface(node_interface::exposedfield_id,
- field_value::sfnode_id,
- "metadata"),
- node_interface(node_interface::field_id,
- field_value::sfbool_id,
- "solid")
- };
-
- typedef node_impl_util::node_type_impl<box_node> node_type_t;
-
- const boost::shared_ptr<node_type> type(new node_type_t(*this, id));
- node_type_t & boxNodeType = static_cast<node_type_t &>(*type);
- for (node_interface_set::const_iterator interface_(interfaces.begin...
[truncated message content] |