|
From: <br...@us...> - 2008-11-24 06:57:01
|
Revision: 3811
http://openvrml.svn.sourceforge.net/openvrml/?rev=3811&view=rev
Author: braden
Date: 2008-11-24 06:56:51 +0000 (Mon, 24 Nov 2008)
Log Message:
-----------
Provide access to a PROTO instance's implementation nodes.
Modified Paths:
--------------
trunk/ChangeLog
trunk/src/libopenvrml/openvrml/browser.cpp
trunk/src/libopenvrml/openvrml/local/proto.cpp
trunk/src/libopenvrml/openvrml/node.cpp
trunk/src/libopenvrml/openvrml/node.h
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2008-11-23 05:39:09 UTC (rev 3810)
+++ trunk/ChangeLog 2008-11-24 06:56:51 UTC (rev 3811)
@@ -1,3 +1,30 @@
+2008-11-24 Braden McDaniel <br...@en...>
+
+ Provide access to a PROTO instance's implementation nodes.
+
+ * src/libopenvrml/openvrml/browser.cpp
+ (openvrml::externproto_node): Override
+ openvrml::node::do_impl_nodes.
+ (openvrml::externproto_node::do_impl_nodes() const): If there is
+ an implementation, return the implementation's nodes.
+ * src/libopenvrml/openvrml/local/proto.cpp
+ (openvrml::local::proto_node): Override
+ openvrml::node::do_impl_nodes.
+ (openvrml::local::proto_node::do_impl_nodes() const): Return the
+ implementation nodes.
+ * src/libopenvrml/openvrml/node.cpp
+ (openvrml::node::impl_nodes() const): Delegate to
+ node::do_impl_nodes.
+ (openvrml::node::do_impl_nodes() const): Default implementation
+ returns an empty vector.
+ (openvrml::is_proto_instance(const node &)): Return true if a node
+ is a PROTO instance; false otherwise.
+ * src/libopenvrml/openvrml/node.h
+ (openvrml::node): Added member functions impl_nodes and
+ do_impl_nodes.
+ (openvrml::is_proto_instance(const node &)): Added; detects if a
+ node instance is a PROTO instance.
+
2008-11-23 Braden McDaniel <br...@en...>
Use trailing underscore convention for private variables in
Modified: trunk/src/libopenvrml/openvrml/browser.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/browser.cpp 2008-11-23 05:39:09 UTC (rev 3810)
+++ trunk/src/libopenvrml/openvrml/browser.cpp 2008-11-24 06:56:51 UTC (rev 3811)
@@ -277,6 +277,10 @@
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);
@@ -2965,6 +2969,15 @@
}
}
+const std::vector<boost::intrusive_ptr<openvrml::node> > &
+openvrml::externproto_node::do_impl_nodes() const OPENVRML_NOTHROW
+{
+ static const std::vector<boost::intrusive_ptr<node> > empty_vec;
+ return this->proto_node_
+ ? this->proto_node_->impl_nodes()
+ : empty_vec;
+}
+
void openvrml::externproto_node::do_initialize(const double timestamp)
OPENVRML_THROW1(std::bad_alloc)
{
Modified: trunk/src/libopenvrml/openvrml/local/proto.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/local/proto.cpp 2008-11-23 05:39:09 UTC (rev 3810)
+++ trunk/src/libopenvrml/openvrml/local/proto.cpp 2008-11-24 06:56:51 UTC (rev 3811)
@@ -155,6 +155,10 @@
virtual bool modified() const;
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);
@@ -1272,6 +1276,17 @@
}
/**
+ * @brief Get the implementation nodes.
+ *
+ * @return the implementation nodes.
+ */
+const std::vector<boost::intrusive_ptr<openvrml::node> > &
+openvrml::local::proto_node::do_impl_nodes() const OPENVRML_NOTHROW
+{
+ return this->impl_nodes_;
+}
+
+/**
* @brief Initialize.
*
* @param[in] timestamp the current time.
Modified: trunk/src/libopenvrml/openvrml/node.cpp
===================================================================
--- trunk/src/libopenvrml/openvrml/node.cpp 2008-11-23 05:39:09 UTC (rev 3810)
+++ trunk/src/libopenvrml/openvrml/node.cpp 2008-11-24 06:56:51 UTC (rev 3811)
@@ -2019,8 +2019,36 @@
return this->scene_;
}
+/**
+ * @brief Get the implementation nodes of a @c PROTO instance.
+ *
+ * If the @c node is not a @c PROTO instance, the returned @c vector is empty.
+ *
+ * This function delegates to @c #do_impl_nodes.
+ *
+ * @return the implementation nodes.
+ */
+const std::vector<boost::intrusive_ptr<openvrml::node> > &
+openvrml::node::impl_nodes() const OPENVRML_NOTHROW
+{
+ return this->do_impl_nodes();
+}
/**
+ * @brief Get the implementation nodes of a @c PROTO instance.
+ *
+ * This default implementation returns an empty @c vector.
+ *
+ * @return an empty @c vector.
+ */
+const std::vector<boost::intrusive_ptr<openvrml::node> > &
+openvrml::node::do_impl_nodes() const OPENVRML_NOTHROW
+{
+ static const std::vector<boost::intrusive_ptr<openvrml::node> > empty_vec;
+ return empty_vec;
+}
+
+/**
* @brief Initialize the node.
*
* This method works recursively, initializing any child nodes to the same
@@ -2758,6 +2786,20 @@
void openvrml::node::do_shutdown(double) OPENVRML_NOTHROW
{}
+/**
+ * @relatesalso openvrml::node
+ *
+ * @brief Check whether a @c node is a @c PROTO instance.
+ *
+ * @param[in] n a @c node.
+ *
+ * @return @c true if @p n is a @c PROTO instance; @c false otherwise.
+ */
+bool openvrml::is_proto_instance(const node & n)
+{
+ return !n.impl_nodes().empty();
+}
+
namespace {
struct OPENVRML_LOCAL add_listener {
add_listener(openvrml::event_emitter & emitter,
Modified: trunk/src/libopenvrml/openvrml/node.h
===================================================================
--- trunk/src/libopenvrml/openvrml/node.h 2008-11-23 05:39:09 UTC (rev 3810)
+++ trunk/src/libopenvrml/openvrml/node.h 2008-11-24 06:56:51 UTC (rev 3811)
@@ -513,6 +513,9 @@
openvrml::scene * scene() const OPENVRML_NOTHROW;
+ const std::vector<boost::intrusive_ptr<node> > & impl_nodes() const
+ OPENVRML_NOTHROW;
+
std::ostream & print(std::ostream & out, size_t indent) const;
void initialize(openvrml::scene & scene, double timestamp)
@@ -556,6 +559,10 @@
read_write_mutex & scene_mutex();
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 field_value & do_field(const std::string & id) const
@@ -657,6 +664,8 @@
this->do_event_emitter(id));
}
+ OPENVRML_API bool is_proto_instance(const node & n);
+
OPENVRML_API bool add_route(node & from, const std::string & eventout,
node & to, const std::string & eventin)
OPENVRML_THROW3(std::bad_alloc, unsupported_interface,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|