|
From: <br...@us...> - 2009-03-04 07:16:42
|
Revision: 3827
http://openvrml.svn.sourceforge.net/openvrml/?rev=3827&view=rev
Author: braden
Date: 2009-03-04 07:16:37 +0000 (Wed, 04 Mar 2009)
Log Message:
-----------
Moved the parser instances out of browser.cpp along with a lot of other code that implied.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/Makefile.am
trunk/src/libopenvrml/openvrml/browser.cpp
trunk/src/libopenvrml/openvrml/browser.h
trunk/src/libopenvrml/openvrml/node.h
trunk/src/libopenvrml/openvrml/scene.cpp
Added Paths:
-----------
trunk/src/libopenvrml/openvrml/local/component.cpp
trunk/src/libopenvrml/openvrml/local/component.h
trunk/src/libopenvrml/openvrml/local/externproto.cpp
trunk/src/libopenvrml/openvrml/local/externproto.h
trunk/src/libopenvrml/openvrml/local/parse_vrml.cpp
trunk/src/libopenvrml/openvrml/local/parse_vrml.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2009-03-02 06:29:53 UTC (rev 3826)
+++ trunk/ChangeLog 2009-03-04 07:16:37 UTC (rev 3827)
@@ -1,3 +1,29 @@
+2009-03-04 Braden McDaniel <br...@en...>
+
+ Moved the parser instances out of browser.cpp along with a lot of
+ other code that implied.
+
+ * src/libopenvrml/openvrml/local/component.cpp: Added file.
+ * src/libopenvrml/openvrml/local/component.h: Added file.
+ component and profile class definitions.
+ * src/libopenvrml/openvrml/local/externproto.cpp: Added file.
+ * src/libopenvrml/openvrml/local/externproto.h: Added file.
+ Definitions of externproto_node, externproto_node_type, and
+ externproto_node_metatype.
+ * src/libopenvrml/openvrml/local/parse_vrml.cpp: Added file.
+ * src/libopenvrml/openvrml/local/parse_vrml.h: Added file.
+ Declaration of parse_vrml function and definitions of the parse
+ actions classes.
+ * src/libopenvrml/openvrml/browser.cpp
+ * src/libopenvrml/openvrml/browser.h
+ * src/libopenvrml/openvrml/scene.cpp
+ * src/libopenvrml/openvrml/node.h
+ * src/Makefile.am
+ (libopenvrml_libopenvrml_la_SOURCES): Added files
+ libopenvrml/openvrml/local/parse_vrml.{cpp,h},
+ libopenvrml/openvrml/local/component.{cpp,h},
+ libopenvrml/openvrml/local/externproto.{cpp,h}.
+
2009-03-02 Braden McDaniel <br...@en...>
Updates for 0.17.11 release.
Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am 2009-03-02 06:29:53 UTC (rev 3826)
+++ trunk/src/Makefile.am 2009-03-04 07:16:37 UTC (rev 3827)
@@ -104,8 +104,14 @@
libopenvrml/openvrml/local/uri.h \
libopenvrml/openvrml/local/xml_reader.cpp \
libopenvrml/openvrml/local/xml_reader.h \
+ libopenvrml/openvrml/local/parse_vrml.cpp \
+ libopenvrml/openvrml/local/parse_vrml.h \
+ libopenvrml/openvrml/local/component.cpp \
+ libopenvrml/openvrml/local/component.h \
libopenvrml/openvrml/local/proto.cpp \
libopenvrml/openvrml/local/proto.h \
+ libopenvrml/openvrml/local/externproto.cpp \
+ libopenvrml/openvrml/local/externproto.h \
libopenvrml/openvrml/local/field_value_types.h \
libopenvrml/openvrml/local/float.h \
libopenvrml/openvrml/local/node_metatype_registry_impl.cpp \
Modified: trunk/src/libopenvrml/openvrml/browser.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/browser.cpp 2009-03-02 06:29:53 UTC (rev 3826)
+++ trunk/src/libopenvrml/openvrml/browser.cpp 2009-03-04 07:16:37 UTC (rev 3827)
@@ -22,23 +22,15 @@
# include "browser.h"
# include "scene.h"
# include "scope.h"
-# include "x3d_vrml_grammar.h"
-# include <openvrml/local/dl.h>
# include <openvrml/local/uri.h>
-# include <openvrml/local/xml_reader.h>
-# include <openvrml/local/field_value_types.h>
-# include <openvrml/local/proto.h>
# include <openvrml/local/node_metatype_registry_impl.h>
+# include <openvrml/local/component.h>
+# include <openvrml/local/parse_vrml.h>
# include <private.h>
-# include <boost/algorithm/string/predicate.hpp>
# include <boost/bind.hpp>
-# include <boost/enable_shared_from_this.hpp>
-# include <boost/filesystem.hpp>
# include <boost/functional.hpp>
# include <boost/lexical_cast.hpp>
-# include <boost/mpl/for_each.hpp>
# include <boost/multi_index/detail/scope_guard.hpp>
-# include <boost/ptr_container/ptr_map.hpp>
# include <boost/thread/thread.hpp>
# include <algorithm>
# include <functional>
@@ -95,242 +87,6 @@
};
} // namespace openvrml
-
-/**
- * @brief @c node_metatype for @c EXTERNPROTO%s.
- */
-class OPENVRML_LOCAL openvrml::browser::externproto_node_metatype :
- public boost::enable_shared_from_this<externproto_node_metatype>,
- public openvrml::node_metatype {
-
- friend class externproto_node_type;
-
- struct load_proto;
-
- mutable boost::mutex mutex_;
- boost::weak_ptr<openvrml::local::proto_node_metatype> proto_node_metatype_;
-
- typedef std::vector<boost::weak_ptr<externproto_node_type> >
- externproto_node_types;
-
- mutable externproto_node_types externproto_node_types_;
- bool externproto_node_types_cleared_;
-
- boost::thread * const load_proto_thread_;
-
-public:
- externproto_node_metatype(
- const openvrml::node_metatype_id & id,
- const openvrml::scene & scene,
- const std::vector<std::string> & uris,
- boost::thread_group & load_proto_thread_group)
- OPENVRML_THROW2(boost::thread_resource_error, std::bad_alloc);
- virtual ~externproto_node_metatype() OPENVRML_NOTHROW;
-
-private:
- virtual const boost::shared_ptr<openvrml::node_type>
- do_create_type(const std::string & id,
- const openvrml::node_interface_set & interfaces) const
- OPENVRML_THROW2(openvrml::unsupported_interface, std::bad_alloc);
-
- virtual void do_shutdown(double time) OPENVRML_NOTHROW;
-
- void set_proto_node_metatype(
- const boost::weak_ptr<openvrml::local::proto_node_metatype> & proto_node_metatype = boost::weak_ptr<openvrml::local::proto_node_metatype>())
- OPENVRML_THROW1(std::bad_alloc);
-
- void clear_externproto_node_types() OPENVRML_NOTHROW;
-};
-
-
-class OPENVRML_LOCAL openvrml::browser::externproto_node_type :
- public openvrml::node_type {
-
- const boost::shared_ptr<const externproto_node_metatype> node_metatype_;
-
- openvrml::node_interface_set interfaces_;
-
- mutable boost::mutex mutex_;
- boost::shared_ptr<openvrml::node_type> proto_node_type_;
-
- typedef std::vector<boost::intrusive_ptr<externproto_node> >
- externproto_nodes;
-
- mutable externproto_nodes externproto_nodes_;
-
-public:
- externproto_node_type(
- const boost::shared_ptr<const externproto_node_metatype> & c,
- const std::string & id,
- const openvrml::node_interface_set & interfaces)
- OPENVRML_THROW1(std::bad_alloc);
-
- virtual ~externproto_node_type() OPENVRML_NOTHROW;
-
- void set_proto_node_type(openvrml::local::proto_node_metatype & proto_node_metatype)
- OPENVRML_THROW1(std::bad_alloc);
-
- void clear_externproto_nodes() OPENVRML_NOTHROW;
-
-private:
- virtual const openvrml::node_interface_set & do_interfaces() const
- OPENVRML_NOTHROW;
-
- virtual const boost::intrusive_ptr<openvrml::node>
- do_create_node(
- const boost::shared_ptr<openvrml::scope> & scope,
- const openvrml::initial_value_map & initial_values) const
- OPENVRML_THROW3(openvrml::unsupported_interface, std::bad_cast,
- std::bad_alloc);
-};
-
-
-class OPENVRML_LOCAL openvrml::externproto_node :
- public openvrml::local::abstract_proto_node {
-
- template <typename FieldValue>
- class externproto_exposedfield : public FieldValue,
- public proto_eventin<FieldValue>,
- public proto_eventout<FieldValue> {
- public:
- explicit externproto_exposedfield(
- externproto_node & node,
- const FieldValue & initial_value = FieldValue())
- OPENVRML_NOTHROW;
- virtual ~externproto_exposedfield() OPENVRML_NOTHROW;
-
- private:
- virtual std::auto_ptr<openvrml::field_value> do_clone() const
- OPENVRML_THROW1(std::bad_alloc);
- virtual void do_process_event(const FieldValue & value,
- double timestamp)
- OPENVRML_THROW1(std::bad_alloc);
- };
-
- struct externproto_exposedfield_creator {
- externproto_exposedfield_creator(
- externproto_node & node,
- const openvrml::field_value::type_id type,
- boost::shared_ptr<openvrml::field_value> & exposedfield):
- node_(&node),
- type_(type),
- exposedfield_(&exposedfield)
- {}
-
- template <typename T>
- void operator()(T) const
- {
- if (T::field_value_type_id == this->type_) {
- this->exposedfield_->reset(
- new externproto_exposedfield<T>(*this->node_));
- }
- }
-
- private:
- externproto_node * node_;
- openvrml::field_value::type_id type_;
- boost::shared_ptr<openvrml::field_value> * exposedfield_;
- };
-
- static const boost::shared_ptr<openvrml::field_value>
- create_exposedfield(externproto_node & node,
- openvrml::field_value::type_id type)
- OPENVRML_THROW1(std::bad_alloc);
-
- typedef std::map<std::string, boost::shared_ptr<openvrml::field_value> >
- field_map;
-
- struct externproto_field_equal_to :
- std::unary_function<field_map::value_type, bool> {
-
- explicit externproto_field_equal_to(
- const openvrml::field_value & field_value):
- field_value_(&field_value)
- {}
-
- bool operator()(const field_map::value_type & arg) const
- {
- return this->field_value_ == arg.second.get();
- }
-
- private:
- const openvrml::field_value * field_value_;
- };
-
- initial_value_map initial_values_;
- std::set<openvrml::field_value *> received_event_;
- field_map field_map_;
-
- boost::intrusive_ptr<openvrml::node> proto_node_;
-
-public:
- externproto_node(const browser::externproto_node_type & type,
- const boost::shared_ptr<openvrml::scope> & scope,
- const openvrml::initial_value_map & initial_values)
- OPENVRML_THROW1(std::bad_alloc);
-
- virtual ~externproto_node() OPENVRML_NOTHROW;
-
- virtual bool modified() const;
-
- void set_proto_node(node_type & type)
- OPENVRML_THROW1(std::bad_alloc);
-
-private:
- virtual
- const std::vector<boost::intrusive_ptr<node> > & do_impl_nodes() const
- OPENVRML_NOTHROW;
-
- virtual void do_initialize(double timestamp)
- OPENVRML_THROW1(std::bad_alloc);
-
- virtual const openvrml::field_value &
- do_field(const std::string & id) const
- OPENVRML_THROW1(openvrml::unsupported_interface);
-
- virtual openvrml::event_listener &
- do_event_listener(const std::string & id)
- OPENVRML_THROW1(openvrml::unsupported_interface);
-
- virtual openvrml::event_emitter &
- do_event_emitter(const std::string & id)
- OPENVRML_THROW1(openvrml::unsupported_interface);
-
- virtual void do_shutdown(double timestamp) OPENVRML_NOTHROW;
-
- virtual openvrml::script_node * to_script() OPENVRML_NOTHROW;
- virtual openvrml::appearance_node * to_appearance() OPENVRML_NOTHROW;
- virtual openvrml::bounded_volume_node * to_bounded_volume()
- OPENVRML_NOTHROW;
- virtual openvrml::child_node * to_child() OPENVRML_NOTHROW;
- virtual openvrml::color_node * to_color() OPENVRML_NOTHROW;
- virtual openvrml::color_rgba_node * to_color_rgba() OPENVRML_NOTHROW;
- virtual openvrml::coordinate_node * to_coordinate() OPENVRML_NOTHROW;
- virtual openvrml::font_style_node * to_font_style() OPENVRML_NOTHROW ;
- virtual openvrml::geometry_node * to_geometry() OPENVRML_NOTHROW;
- virtual openvrml::grouping_node * to_grouping() OPENVRML_NOTHROW;
- virtual openvrml::light_node * to_light() OPENVRML_NOTHROW;
- virtual openvrml::material_node * to_material() OPENVRML_NOTHROW;
- virtual openvrml::navigation_info_node * to_navigation_info()
- OPENVRML_NOTHROW;
- virtual openvrml::normal_node * to_normal() OPENVRML_NOTHROW;
- virtual openvrml::pointing_device_sensor_node *
- to_pointing_device_sensor() OPENVRML_NOTHROW;
- virtual openvrml::scoped_light_node * to_scoped_light()
- OPENVRML_NOTHROW;
- virtual openvrml::sound_source_node * to_sound_source()
- OPENVRML_NOTHROW;
- virtual openvrml::texture_node * to_texture() OPENVRML_NOTHROW;
- virtual openvrml::texture_coordinate_node * to_texture_coordinate()
- OPENVRML_NOTHROW;
- virtual openvrml::texture_transform_node * to_texture_transform()
- OPENVRML_NOTHROW;
- virtual openvrml::time_dependent_node * to_time_dependent()
- OPENVRML_NOTHROW;
- virtual openvrml::transform_node * to_transform() OPENVRML_NOTHROW;
- virtual openvrml::viewpoint_node * to_viewpoint() OPENVRML_NOTHROW;
-};
-
namespace {
class OPENVRML_LOCAL default_navigation_info :
@@ -656,231 +412,8 @@
throw openvrml::unsupported_interface(this->type(), id);
return *static_cast<openvrml::event_emitter *>(0);
}
-
-
- const std::string anonymous_stream_id_prefix_ =
- "urn:X-openvrml:stream:";
-
- OPENVRML_LOCAL bool anonymous_stream_id(const openvrml::local::uri & id)
- {
- const std::string str(id);
- return str.length() > anonymous_stream_id_prefix_.length()
- && std::equal(anonymous_stream_id_prefix_.begin(),
- anonymous_stream_id_prefix_.end(),
- str.begin());
- }
-
-
- class OPENVRML_LOCAL profile {
- typedef std::map<std::string, int> map_t;
- map_t components_;
-
- protected:
- void add_component(const std::string & name, int level)
- OPENVRML_THROW1(std::bad_alloc);
-
- public:
- std::auto_ptr<openvrml::scope>
- create_root_scope(const openvrml::browser & browser,
- const std::string & uri) const
- OPENVRML_THROW1(std::bad_alloc);
- std::auto_ptr<openvrml::node_type_decls>
- create_node_type_desc_map() const
- OPENVRML_THROW1(std::bad_alloc);
- };
-
-
- class OPENVRML_LOCAL vrml97_profile : public profile {
- public:
- static const char * const id;
-
- vrml97_profile();
- };
-
-
- class OPENVRML_LOCAL x3d_core_profile : public profile {
- public:
- static const char * const id;
-
- x3d_core_profile();
- };
-
-
- class OPENVRML_LOCAL x3d_interchange_profile : public profile {
- public:
- static const char * const id;
-
- x3d_interchange_profile();
- };
-
-
- class OPENVRML_LOCAL x3d_interactive_profile : public profile {
- public:
- static const char * const id;
-
- x3d_interactive_profile();
- };
-
-
- class OPENVRML_LOCAL x3d_mpeg4_profile : public profile {
- public:
- static const char * const id;
-
- x3d_mpeg4_profile();
- };
-
-
- class OPENVRML_LOCAL x3d_immersive_profile : public profile {
- public:
- static const char * const id;
-
- x3d_immersive_profile();
- };
-
-
- class OPENVRML_LOCAL x3d_full_profile : public profile {
- public:
- static const char * const id;
-
- x3d_full_profile();
- };
}
-namespace {
-
- class OPENVRML_LOCAL component {
- struct node_type_decl {
- openvrml::node_interface_set interfaces;
- std::string metatype_id;
- };
-
- class xml_reader;
-
- class level : std::map<std::string, node_type_decl> {
- friend class xml_reader;
-
- public:
- typedef std::map<std::string, size_t> dependencies_t;
-
- private:
- dependencies_t dependencies_;
-
- public:
- typedef std::map<std::string, node_type_decl> base_t;
- using base_t::value_type;
- using base_t::iterator;
- using base_t::const_iterator;
- using base_t::begin;
- using base_t::end;
- using base_t::find;
- using base_t::insert;
-
- const dependencies_t & requires() const;
- };
-
- class xml_reader : boost::noncopyable {
- enum parse_state {
- none,
- component,
- level,
- requires,
- node,
- field
- };
-
- ::component & component_;
- parse_state state_;
- std::vector<component::level>::value_type * current_level_;
- level::value_type * current_node_;
-
- public:
- explicit xml_reader(::component & c);
-
- void read(const std::string & filename)
- OPENVRML_THROW1(std::runtime_error);
-
- private:
- void process_node(openvrml::local::xml_reader & reader);
- void start_element(openvrml::local::xml_reader & reader);
- void end_element(openvrml::local::xml_reader & reader);
- };
-
- std::string id_;
- std::vector<level> levels_;
-
- public:
- explicit component(const std::string & filename)
- OPENVRML_THROW1(std::runtime_error);
-
- const std::string & id() const OPENVRML_NOTHROW;
- size_t support_level() const OPENVRML_NOTHROW;
- void add_to_scope(const openvrml::browser & b,
- openvrml::scope & scope,
- size_t level) const
- OPENVRML_THROW2(std::invalid_argument, std::bad_alloc);
- void add_to_node_type_desc_map(openvrml::node_type_decls & type_descs,
- size_t level) const
- OPENVRML_THROW2(std::invalid_argument, std::bad_alloc);
-
- private:
- static bool
- add_type_desc(openvrml::node_type_decls & type_descs,
- const std::string & node_type_id,
- const openvrml::node_interface_set & interfaces)
- OPENVRML_THROW1(std::bad_alloc);
-
- void add_scope_entry(
- const openvrml::browser & b,
- const char * node_name,
- const openvrml::node_interface_set & interface_set,
- const char * urn,
- openvrml::scope & scope) const
- OPENVRML_THROW2(openvrml::unsupported_interface, std::bad_alloc);
- };
-
- const class OPENVRML_LOCAL profile_registry : boost::ptr_map<std::string,
- profile> {
- public:
- profile_registry();
-
- using boost::ptr_map<std::string, profile>::at;
- } profile_registry_;
-
- profile_registry::profile_registry()
- {
- std::string key;
- bool succeeded;
-
- key = vrml97_profile::id;
- succeeded = this->insert(key, new vrml97_profile).second;
- assert(succeeded);
-
- key = x3d_core_profile::id;
- succeeded = this->insert(key, new x3d_core_profile).second;
- assert(succeeded);
-
- key = x3d_interchange_profile::id;
- succeeded = this->insert(key, new x3d_interchange_profile).second;
- assert(succeeded);
-
- key = x3d_interactive_profile::id;
- succeeded = this->insert(key, new x3d_interactive_profile).second;
- assert(succeeded);
-
- key = x3d_mpeg4_profile::id;
- succeeded = this->insert(key, new x3d_mpeg4_profile).second;
- assert(succeeded);
-
- key = x3d_immersive_profile::id;
- succeeded = this->insert(key, new x3d_immersive_profile).second;
- assert(succeeded);
-
- key = x3d_full_profile::id;
- succeeded = this->insert(key, new x3d_full_profile).second;
- assert(succeeded);
- }
-}
-
/**
* @brief Get a @c node_type_decls map corresponding to a particular profile.
*
@@ -897,26 +430,14 @@
OPENVRML_THROW2(std::invalid_argument, std::bad_alloc)
{
try {
- return ::profile_registry_.at(profile_id).create_node_type_desc_map();
+ return local::profile_registry_.at(profile_id)
+ .create_node_type_desc_map();
} catch (boost::bad_ptr_container_operation &) {
throw std::invalid_argument("unknown profile identifier \""
+ profile_id + '"');
}
}
-namespace {
-
- const class OPENVRML_LOCAL component_registry : boost::ptr_map<std::string,
- component> {
- public:
- component_registry()
- OPENVRML_THROW2(boost::filesystem::filesystem_error,
- std::bad_alloc);
-
- using boost::ptr_map<std::string, component>::at;
- } component_registry_;
-}
-
/**
* @brief Add the nodes corresponding to a component level to a
* @c node_type_decls map.
@@ -937,7 +458,8 @@
OPENVRML_THROW2(std::invalid_argument, std::bad_alloc)
{
try {
- const component & comp = ::component_registry_.at(component_id);
+ const local::component & comp =
+ local::component_registry_.at(component_id);
comp.add_to_node_type_desc_map(node_types, level);
} catch (boost::bad_ptr_container_operation &) {
throw std::invalid_argument("unknown component identifier \""
@@ -946,2392 +468,6 @@
}
-struct OPENVRML_LOCAL openvrml::browser::vrml97_parse_actions {
- vrml97_parse_actions(
- const std::string & uri,
- const openvrml::scene & scene,
- std::vector<boost::intrusive_ptr<openvrml::node> > & nodes):
- on_scene_start(*this),
- on_scene_finish(*this),
- on_externproto(*this),
- on_proto_start(*this),
- on_proto_interface(*this),
- on_proto_default_value_start(*this),
- on_proto_default_value_finish(*this),
- on_proto_body_start(*this),
- on_proto_finish(*this),
- on_node_start(*this),
- on_node_finish(*this),
- on_script_interface_decl(*this),
- on_route(*this),
- on_use(*this),
- on_is_mapping(*this),
- on_field_start(*this),
- on_sfnode(*this),
- on_mfnode(*this),
- on_sfbool(*this),
- on_sfcolor(*this),
- on_mfcolor(*this),
- on_sffloat(*this),
- on_mffloat(*this),
- on_sfimage(*this),
- on_sfint32(*this),
- on_mfint32(*this),
- on_sfrotation(*this),
- on_mfrotation(*this),
- on_sfstring(*this),
- on_mfstring(*this),
- on_sftime(*this),
- on_mftime(*this),
- on_sfvec2f(*this),
- on_mfvec2f(*this),
- on_sfvec3f(*this),
- on_mfvec3f(*this),
- uri_(uri),
- scene_(scene),
- nodes_(nodes)
- {}
-
- struct on_scene_start_t {
- explicit on_scene_start_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()() const
- {
- using std::vector;
- using boost::intrusive_ptr;
-
- this->actions_.ps.push(parse_scope());
-
- const ::profile & p = ::profile_registry_.at(vrml97_profile::id);
- std::auto_ptr<scope>
- root_scope(p.create_root_scope(this->actions_.scene_.browser(),
- this->actions_.uri_));
- this->actions_.ps.top().scope = root_scope;
- this->actions_.ps.top().children.push(
- parse_scope::children_t());
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_scene_start;
-
- struct on_scene_finish_t {
- explicit on_scene_finish_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()() const
- {
- using std::vector;
-
- assert(this->actions_.ps.top().children.size() == 1);
- this->actions_.nodes_ =
- this->actions_.ps.top().children.top();
- this->actions_.ps.top().children.pop();
-
- assert(this->actions_.ps.size() == 1);
-
- parse_scope & ps = this->actions_.ps.top();
-
- for (vector<route>::const_iterator r = ps.routes.begin();
- r != ps.routes.end();
- ++r) {
- node * const from = ps.scope->find_node(r->from);
- assert(from);
- node * const to = ps.scope->find_node(r->to);
- assert(to);
- //
- // Redundant routing is ignored (4.10.2), so we don't care if
- // add_route returns false.
- //
- add_route(*from, r->eventout, *to, r->eventin);
- }
- this->actions_.ps.pop();
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_scene_finish;
-
- struct on_externproto_t {
- explicit on_externproto_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const std::string & node_type_id,
- const node_interface_set & interfaces,
- const std::vector<std::string> & uri_list) const
- {
- using std::string;
- using std::vector;
- using boost::shared_ptr;
- using local::uri;
-
- //
- // If we are parsing an "anonymous" stream--that is, one passed to
- // browser::create_vrml_from_stream--we cannot use the URI
- // associated with the stream to resolve relative URIs. So in
- // this instance, we get the base URI from browser::world_url. If
- // browser::world_url is an empty string, we call create_file_url
- // with an empty (relative) uri.
- //
- const uri base_uri =
- anonymous_stream_id(uri(this->actions_.uri_))
- ? this->actions_.scene_.browser().world_url().empty()
- ? create_file_url(uri())
- : uri(this->actions_.scene_.browser().world_url())
- : uri(this->actions_.uri_);
-
- shared_ptr<node_type> node_type;
- for (vector<string>::const_iterator resource_id = uri_list.begin();
- resource_id != uri_list.end();
- ++resource_id) {
- const uri absolute_uri = relative(uri(*resource_id))
- ? resolve_against(uri(*resource_id), base_uri)
- : uri(*resource_id);
- const shared_ptr<openvrml::node_metatype> node_metatype =
- this->actions_.scene_.browser().node_metatype(
- node_metatype_id(absolute_uri));
- if (node_metatype) {
- node_type = node_metatype->create_type(node_type_id,
- interfaces);
- break;
- }
- }
-
- if (!node_type) {
- const std::string metatype_id =
- path(*this->actions_.ps.top().scope) + '#'
- + node_type_id;
- const shared_ptr<openvrml::node_metatype>
- externproto_class(
- new externproto_node_metatype(
- metatype_id,
- this->actions_.scene_,
- uri_list,
- this->actions_.scene_.browser()
- .load_proto_thread_group_));
-
- this->actions_.scene_.browser().add_node_metatype(
- externproto_class->id(),
- externproto_class);
- for (vector<string>::const_iterator resource_id =
- uri_list.begin();
- resource_id != uri_list.end();
- ++resource_id) {
- const uri absolute_uri = relative(uri(*resource_id))
- ? resolve_against(uri(*resource_id), base_uri)
- : uri(*resource_id);
- this->actions_.scene_.browser()
- .add_node_metatype(node_metatype_id(absolute_uri),
- externproto_class);
- }
-
- node_type = externproto_class->create_type(node_type_id,
- interfaces);
- }
-
- assert(node_type);
-
- const bool succeeded =
- this->actions_.ps.top().scope->add_type(node_type)
- .second;
- assert(succeeded);
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_externproto;
-
- struct on_proto_start_t {
- explicit on_proto_start_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const std::string & node_type_id) const
- {
- const boost::shared_ptr<scope> outer_scope =
- this->actions_.ps.top().scope;
- assert(outer_scope);
-
- this->actions_.ps.push(parse_scope());
-
- parse_scope & ps = this->actions_.ps.top();
-
- ps.proto_node_type_id = node_type_id;
-
- //
- // We don't want to create the new scope until we start the PROTO
- // body. So, for now we set the parse_scope::scope to the outer
- // scope.
- //
- ps.scope = outer_scope;
-
- //
- // We push a node_data onto the stack to hold any field default
- // values.
- //
- ps.node_data_.push(node_data());
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_proto_start;
-
- struct on_proto_interface_t {
- explicit on_proto_interface_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const node_interface & interface_) const
- {
- parse_scope & ps = this->actions_.ps.top();
-
- const bool succeeded =
- ps.proto_interfaces.insert(interface_).second;
- assert(succeeded);
-
- assert(!ps.node_data_.empty());
- node_data & nd = ps.node_data_.top();
-
- if (interface_.type == node_interface::field_id
- || interface_.type == node_interface::exposedfield_id) {
- using std::auto_ptr;
- using std::pair;
- auto_ptr<field_value> value =
- field_value::create(interface_.field_type);
- pair<initial_value_map::iterator, bool> insert_result =
- nd.initial_values.insert(
- make_pair(interface_.id,
- boost::shared_ptr<field_value>(value)));
- assert(insert_result.second);
- nd.current_field_value = &(*insert_result.first);
- }
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_proto_interface;
-
- struct on_proto_default_value_start_t {
- explicit on_proto_default_value_start_t(
- vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()() const
- {
- parse_scope & ps = this->actions_.ps.top();
-
- boost::shared_ptr<scope> outer_scope = ps.scope;
- const std::string & proto_node_type_id = ps.proto_node_type_id;
- assert(!proto_node_type_id.empty());
- const std::string & field_id =
- ps.node_data_.top().current_field_value->first;
- const field_value::type_id field_type =
- ps.node_data_.top().current_field_value->second->type();
-
- if (field_type == field_value::sfnode_id
- || field_type == field_value::mfnode_id) {
- using std::vector;
- using boost::intrusive_ptr;
-
- const node_data old_nd = ps.node_data_.top();
-
- const std::string scope_id =
- proto_node_type_id + '.' + field_id;
- actions_.ps.push(parse_scope());
-
- parse_scope & new_ps = this->actions_.ps.top();
-
- new_ps.scope.reset(new scope(scope_id, outer_scope));
- new_ps.node_data_.push(old_nd);
- new_ps.children.push(parse_scope::children_t());
- }
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_proto_default_value_start;
-
- struct on_proto_default_value_finish_t {
- explicit on_proto_default_value_finish_t(
- vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()() const
- {
- assert(!actions_.ps.empty());
-
- parse_scope & ps = this->actions_.ps.top();
-
- const field_value::type_id field_type =
- ps.node_data_.top().current_field_value->second->type();
-
- if (field_type == field_value::sfnode_id
- || field_type == field_value::mfnode_id) {
- using std::vector;
-
- assert(actions_.ps.size() > 1);
-
- for (vector<route>::const_iterator r = ps.routes.begin();
- r != ps.routes.end();
- ++r) {
- node * const from = ps.scope->find_node(r->from);
- assert(from);
- node * const to = ps.scope->find_node(r->to);
- assert(to);
- //
- // Redundant routing is ignored (4.10.2), so we don't care
- // if add_route returns false.
- //
- add_route(*from, r->eventout, *to, r->eventin);
- }
-
- parse_scope old_ps = ps;
- this->actions_.ps.pop();
- parse_scope & new_ps = this->actions_.ps.top();
- new_ps.node_data_.top().current_field_value->second->assign(
- *old_ps.node_data_.top().current_field_value->second);
- }
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_proto_default_value_finish;
-
- struct on_proto_body_start_t {
- explicit on_proto_body_start_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()() const
- {
- assert(!actions_.ps.empty());
- const boost::shared_ptr<scope> parent =
- actions_.ps.top().scope;
- actions_.ps.top().scope
- .reset(new scope(actions_.ps.top().proto_node_type_id,
- parent));
- actions_.ps.top().proto_default_values =
- actions_.ps.top().node_data_.top().initial_values;
- actions_.ps.top().node_data_.pop();
- assert(actions_.ps.top().children.empty());
- actions_.ps.top().children.push(
- parse_scope::children_t());
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_proto_body_start;
-
- struct on_proto_finish_t {
- explicit on_proto_finish_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()() const
- {
- using std::vector;
- using boost::shared_ptr;
- using boost::dynamic_pointer_cast;
- using local::proto_node_metatype;
- parse_scope & ps = this->actions_.ps.top();
- assert(ps.children.size() == 1);
- assert(ps.node_data_.empty());
- proto_node_metatype::routes_t proto_routes;
- for (vector<route>::const_iterator r = ps.routes.begin();
- r != ps.routes.end();
- ++r) {
- node * const from = ps.scope->find_node(r->from);
- assert(from);
- node * const to = ps.scope->find_node(r->to);
- assert(to);
- proto_routes.push_back(
- proto_node_metatype::route(*from, r->eventout,
- *to, r->eventin));
- }
- const shared_ptr<openvrml::node_metatype> node_metatype(
- new proto_node_metatype(
- path(*ps.scope),
- this->actions_.scene_.browser(),
- ps.proto_interfaces,
- ps.proto_default_values,
- ps.children.top(),
- ps.proto_is_map,
- proto_routes));
-
- //
- // Add the new node_metatype (prototype definition) to the
- // browser's node_metatype_registry.
- //
- this->actions_.scene_.browser()
- .add_node_metatype(node_metatype->id(), node_metatype);
-
- if (!dynamic_pointer_cast<proto_node_metatype>(
- this->actions_.scene_.browser().node_metatype(
- node_metatype_id(this->actions_.uri_)))) {
- this->actions_.scene_.browser()
- .add_node_metatype(node_metatype_id(this->actions_.uri_),
- node_metatype);
- }
-
- //
- // PROTOs implicitly introduce a new node type as well.
- //
- const shared_ptr<node_type> node_type =
- node_metatype->create_type(
- ps.proto_node_type_id,
- this->actions_.ps.top().proto_interfaces);
- assert(node_type);
-
- //
- // We want to add the type to the PROTO's enclosing scope, so pop
- // off the current scope.
- //
- assert(this->actions_.ps.size() > 1);
- this->actions_.ps.pop();
-
- const bool succeeded =
- this->actions_.ps.top().scope->add_type(node_type)
- .second;
- assert(succeeded);
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_proto_finish;
-
- struct on_node_start_t {
- explicit on_node_start_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const std::string & node_name_id,
- const std::string & node_type_id) const
- {
- parse_scope & ps = this->actions_.ps.top();
-
- ps.node_data_.push(node_data());
- ps.node_data_.top().node_name_id = node_name_id;
-
- assert(ps.scope);
- if (node_type_id != "Script") {
- ps.node_data_.top().type = ps.scope->find_type(node_type_id);
- assert(ps.node_data_.top().type);
- }
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_node_start;
-
- struct on_node_finish_t {
- explicit on_node_finish_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()() const
- {
- using boost::intrusive_ptr;
-
- parse_scope & ps = this->actions_.ps.top();
-
- assert(!ps.children.empty());
- assert(!ps.node_data_.empty());
-
- const node_data & nd = ps.node_data_.top();
-
- const intrusive_ptr<node> n = nd.type
- ? nd.type->create_node(ps.scope, nd.initial_values)
- : intrusive_ptr<node>(
- new script_node(
- this->actions_.scene_.browser().script_node_metatype_,
- ps.scope,
- nd.script_interfaces,
- nd.initial_values));
-
- if (!nd.node_name_id.empty()) { n->id(nd.node_name_id); }
-
- for (node_data::is_map_t::const_iterator entry = nd.is_map.begin();
- entry != nd.is_map.end();
- ++entry) {
- ps.proto_is_map.insert(
- make_pair(entry->second,
- local::proto_node_metatype::is_target(
- *n, entry->first)));
- }
-
- ps.children.top().push_back(n);
- ps.node_data_.pop();
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_node_finish;
-
- struct on_script_interface_decl_t {
- explicit on_script_interface_decl_t(
- vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const node_interface & interface_) const
- {
- parse_scope & ps = this->actions_.ps.top();
-
- assert(!ps.node_data_.empty());
-
- node_data & nd = ps.node_data_.top();
-
- const bool succeeded =
- nd.script_interfaces.insert(interface_).second;
- assert(succeeded);
-
- this->actions_.on_field_start(interface_.id, interface_.field_type);
- if ((interface_.type == node_interface::eventin_id
- || interface_.type == node_interface::eventout_id)
- && (interface_.field_type == field_value::sfnode_id
- || interface_.field_type == field_value::mfnode_id)) {
- ps.children.pop();
- }
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_script_interface_decl;
-
- struct on_route_t {
- explicit on_route_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const std::string & from_node_name_id,
- const node_interface & from_node_interface,
- const std::string & to_node_name_id,
- const node_interface & to_node_interface) const
- {
- parse_scope & ps = this->actions_.ps.top();
- const route r(from_node_name_id, from_node_interface.id,
- to_node_name_id, to_node_interface.id);
- ps.routes.push_back(r);
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_route;
-
- struct on_use_t {
- explicit on_use_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const std::string & node_name_id) const
- {
- using boost::intrusive_ptr;
- parse_scope & ps = this->actions_.ps.top();
- node_data & nd = ps.node_data_.top();
-
- //
- // Check for self-reference. This is legitimate in Script nodes.
- //
- node * const n = (node_name_id == nd.node_name_id)
- ? node::self_tag.get()
- : ps.scope->find_node(node_name_id);
- assert(n);
- assert(!ps.children.empty());
- ps.children.top().push_back(intrusive_ptr<node>(n));
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_use;
-
- struct on_is_mapping_t {
- explicit on_is_mapping_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const std::string & proto_interface_id) const
- {
- node_data & nd =
- this->actions_.ps.top().node_data_.top();
- assert(nd.current_field_value);
- nd.is_map.insert(make_pair(nd.current_field_value->first,
- proto_interface_id));
-
- const field_value::type_id field_type =
- nd.current_field_value->second->type();
- if (field_type == field_value::sfnode_id
- || field_type == field_value::mfnode_id) {
- this->actions_.ps.top().children.pop();
- }
-
- //
- // We need to leave this around for Script nodes.
- //
- if (nd.type) {
- const initial_value_map::size_type erased =
- nd.initial_values.erase(nd.current_field_value->first);
- assert(erased != 0);
- }
- nd.current_field_value = 0;
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_is_mapping;
-
- struct on_field_start_t {
- explicit on_field_start_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const std::string & field_name_id,
- const field_value::type_id field_type) const
- {
- parse_scope & ps = this->actions_.ps.top();
- node_data & nd = ps.node_data_.top();
-
- using boost::shared_ptr;
- using std::pair;
- std::auto_ptr<field_value> value = field_value::create(field_type);
- pair<initial_value_map::iterator, bool> insert_result =
- nd.initial_values.insert(
- make_pair(field_name_id, shared_ptr<field_value>(value)));
- assert(insert_result.second);
- nd.current_field_value = &(*insert_result.first);
-
- if (field_type == field_value::sfnode_id
- || field_type == field_value::mfnode_id) {
- ps.children.push(parse_scope::children_t());
- }
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_field_start;
-
- struct on_sfnode_t {
- explicit on_sfnode_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(bool null) const
- {
- assert(!actions_.ps.empty());
- parse_scope & ps = this->actions_.ps.top();
-
- if (!null) {
- assert(!ps.node_data_.empty());
- assert(!ps.children.top().empty());
- ps.node_data_.top()
- .current_field_value->second->assign(
- sfnode(ps.children.top().front()));
- }
- actions_.ps.top().children.pop();
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_sfnode;
-
- struct on_mfnode_t {
- explicit on_mfnode_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()() const
- {
- assert(!this->actions_.ps.empty());
- assert(!this->actions_.ps.top().node_data_.empty());
- assert(!this->actions_.ps.top().children.empty());
- this->actions_.ps.top().node_data_.top()
- .current_field_value->second
- ->assign(mfnode(this->actions_.ps.top().children.top()));
- this->actions_.ps.top().children.pop();
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_mfnode;
-
- struct on_sfbool_t {
- explicit on_sfbool_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const bool val) const
- {
- assert(!actions_.ps.empty());
- assert(!actions_.ps.top().node_data_.empty());
- actions_.ps.top().node_data_.top()
- .current_field_value->second->assign(sfbool(val));
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_sfbool;
-
- struct on_sfcolor_t {
- explicit on_sfcolor_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const color & val) const
- {
- assert(!actions_.ps.empty());
- assert(!actions_.ps.top().node_data_.empty());
- actions_.ps.top().node_data_.top()
- .current_field_value->second->assign(sfcolor(val));
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_sfcolor;
-
- struct on_mfcolor_t {
- explicit on_mfcolor_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const std::vector<color> & val) const
- {
- assert(!actions_.ps.empty());
- assert(!actions_.ps.top().node_data_.empty());
- actions_.ps.top().node_data_.top()
- .current_field_value->second->assign(mfcolor(val));
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_mfcolor;
-
- struct on_sffloat_t {
- explicit on_sffloat_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const float val) const
- {
- assert(!actions_.ps.empty());
- assert(!actions_.ps.top().node_data_.empty());
- actions_.ps.top().node_data_.top()
- .current_field_value->second->assign(sffloat(val));
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_sffloat;
-
- struct on_mffloat_t {
- explicit on_mffloat_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const std::vector<float> & val) const
- {
- assert(!actions_.ps.empty());
- assert(!actions_.ps.top().node_data_.empty());
- actions_.ps.top().node_data_.top()
- .current_field_value->second->assign(mffloat(val));
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_mffloat;
-
- struct on_sfimage_t {
- explicit on_sfimage_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const image & val) const
- {
- assert(!actions_.ps.empty());
- assert(!actions_.ps.top().node_data_.empty());
- actions_.ps.top().node_data_.top()
- .current_field_value->second->assign(sfimage(val));
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_sfimage;
-
- struct on_sfint32_t {
- explicit on_sfint32_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const int32 val) const
- {
- assert(!actions_.ps.empty());
- assert(!actions_.ps.top().node_data_.empty());
- actions_.ps.top().node_data_.top()
- .current_field_value->second->assign(sfint32(val));
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_sfint32;
-
- struct on_mfint32_t {
- explicit on_mfint32_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const std::vector<int32> & val) const
- {
- assert(!actions_.ps.empty());
- assert(!actions_.ps.top().node_data_.empty());
- actions_.ps.top().node_data_.top()
- .current_field_value->second->assign(mfint32(val));
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_mfint32;
-
- struct on_sfrotation_t {
- explicit on_sfrotation_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const rotation & val) const
- {
- assert(!actions_.ps.empty());
- assert(!actions_.ps.top().node_data_.empty());
- actions_.ps.top().node_data_.top()
- .current_field_value->second->assign(sfrotation(val));
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_sfrotation;
-
- struct on_mfrotation_t {
- explicit on_mfrotation_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const std::vector<rotation> & val) const
- {
- assert(!actions_.ps.empty());
- assert(!actions_.ps.top().node_data_.empty());
- actions_.ps.top().node_data_.top()
- .current_field_value->second->assign(mfrotation(val));
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_mfrotation;
-
- struct on_sfstring_t {
- explicit on_sfstring_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const std::string & val) const
- {
- assert(!actions_.ps.empty());
- assert(!actions_.ps.top().node_data_.empty());
- actions_.ps.top().node_data_.top()
- .current_field_value->second->assign(sfstring(val));
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_sfstring;
-
- struct on_mfstring_t {
- explicit on_mfstring_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const std::vector<std::string> & val) const
- {
- assert(!actions_.ps.empty());
- assert(!actions_.ps.top().node_data_.empty());
- actions_.ps.top().node_data_.top()
- .current_field_value->second->assign(mfstring(val));
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_mfstring;
-
- struct on_sftime_t {
- explicit on_sftime_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const double val) const
- {
- assert(!actions_.ps.empty());
- assert(!actions_.ps.top().node_data_.empty());
- actions_.ps.top().node_data_.top()
- .current_field_value->second->assign(sftime(val));
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_sftime;
-
- struct on_mftime_t {
- explicit on_mftime_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const std::vector<double> & val) const
- {
- assert(!actions_.ps.empty());
- assert(!actions_.ps.top().node_data_.empty());
- actions_.ps.top().node_data_.top()
- .current_field_value->second->assign(mftime(val));
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_mftime;
-
- struct on_sfvec2f_t {
- explicit on_sfvec2f_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const vec2f & val) const
- {
- assert(!actions_.ps.empty());
- assert(!actions_.ps.top().node_data_.empty());
- actions_.ps.top().node_data_.top()
- .current_field_value->second->assign(sfvec2f(val));
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_sfvec2f;
-
- struct on_mfvec2f_t {
- explicit on_mfvec2f_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const std::vector<vec2f> & val) const
- {
- assert(!actions_.ps.empty());
- assert(!actions_.ps.top().node_data_.empty());
- actions_.ps.top().node_data_.top()
- .current_field_value->second->assign(mfvec2f(val));
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_mfvec2f;
-
- struct on_sfvec3f_t {
- explicit on_sfvec3f_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const vec3f & val) const
- {
- assert(!actions_.ps.empty());
- assert(!actions_.ps.top().node_data_.empty());
- actions_.ps.top().node_data_.top()
- .current_field_value->second->assign(sfvec3f(val));
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_sfvec3f;
-
- struct on_mfvec3f_t {
- explicit on_mfvec3f_t(vrml97_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(const std::vector<vec3f> & val) const
- {
- assert(!actions_.ps.empty());
- assert(!actions_.ps.top().node_data_.empty());
- actions_.ps.top().node_data_.top()
- .current_field_value->second->assign(mfvec3f(val));
- }
-
- private:
- vrml97_parse_actions & actions_;
- } on_mfvec3f;
-
- struct route {
- std::string from;
- std::string eventout;
- std::string to;
- std::string eventin;
-
- route(const std::string & from, const std::string & eventout,
- const std::string & to, const std::string & eventin):
- from(from),
- eventout(eventout),
- to(to),
- eventin(eventin)
- {}
- };
-
- struct node_data {
- //
- // This is a multimap because an exposedField might have multiple
- // entries (i.e., for the corresponding eventIn, field, and eventOut).
- //
- typedef std::multimap<std::string, std::string> is_map_t;
-
- boost::shared_ptr<node_type> type;
- std::string node_name_id;
- initial_value_map initial_values;
- initial_value_map::value_type * current_field_value;
- node_interface_set script_interfaces;
- is_map_t is_map;
-
- node_data():
- current_field_value(0)
- {}
-
- node_data(const node_data & nd):
- type(nd.type),
- node_name_id(nd.node_name_id),
- initial_values(nd.initial_values),
- current_field_value(0),
- script_interfaces(nd.script_interfaces),
- is_map(nd.is_map)
- {
- if (nd.current_field_value) {
- initial_value_map::iterator pos =
- this->initial_values.find(nd.current_field_value->first);
- assert(pos != this->initial_values.end());
- this->current_field_value = &(*pos);
- }
- }
-
- node_data & operator=(const node_data & nd)
- {
- node_data temp(nd);
- this->swap(temp);
- return *this;
- }
-
- void swap(node_data & nd) OPENVRML_NOTHROW
- {
- this->type.swap(nd.type);
- this->node_name_id.swap(nd.node_name_id);
- this->initial_values.swap(nd.initial_values);
- std::swap(this->current_field_value, nd.current_field_value);
- this->script_interfaces.swap(nd.script_interfaces);
- this->is_map.swap(nd.is_map);
- }
- };
-
- struct parse_scope {
- typedef std::vector<boost::intrusive_ptr<node> > children_t;
-
- std::string proto_node_type_id;
- boost::shared_ptr<openvrml::scope> scope;
- node_interface_set proto_interfaces;
- local::proto_node_metatype::default_value_map_t proto_default_values;
- local::proto_node_metatype::is_map_t proto_is_map;
- std::vector<route> routes;
- std::stack<children_t> children;
- std::stack<node_data> node_data_;
- };
-
- //
- // We push a parse_scope onto the stack
- // * at the scene root
- std::stack<parse_scope> ps;
-
-private:
- const std::string uri_;
- const openvrml::scene & scene_;
- std::vector<boost::intrusive_ptr<openvrml::node> > & nodes_;
-};
-
-struct OPENVRML_LOCAL openvrml::browser::x3d_vrml_parse_actions :
- openvrml::browser::vrml97_parse_actions {
-
- x3d_vrml_parse_actions(
- const std::string & uri,
- const openvrml::scene & scene,
- std::vector<boost::intrusive_ptr<openvrml::node> > & nodes,
- std::map<std::string, std::string> & meta):
- openvrml::browser::vrml97_parse_actions(uri, scene, nodes),
- on_profile_statement(*this),
- on_component_statement(*this),
- on_meta_statement(*this),
- on_sfcolorrgba(*this),
- on_sfdouble(*this),
- on_sfvec2d(*this),
- on_sfvec3d(*this),
- on_mfbool(*this),
- on_mfcolorrgba(*this),
- on_mfimage(*this),
- on_mfvec2d(*this),
- on_mfvec3d(*this),
- meta_(meta)
- {}
-
- struct on_profile_statement_t {
- explicit on_profile_statement_t(x3d_vrml_parse_actions & actions):
- actions_(actions)
- {}
-
- void operator()(cons...
[truncated message content] |