diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-08-03 12:10:57 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-08-03 12:10:57 (GMT) |
commit | 6e1a4a67d5b17e92135cd3f5daf51bf044d76e40 (patch) | |
tree | 63d8de9a5ba99dbcd16c6bd867241a7e7466c559 /src/uscxml/plugins/invoker | |
parent | 37f8735a66aadd0e3f019f5edbb9356cf4a7b974 (diff) | |
download | uscxml-6e1a4a67d5b17e92135cd3f5daf51bf044d76e40.zip uscxml-6e1a4a67d5b17e92135cd3f5daf51bf044d76e40.tar.gz uscxml-6e1a4a67d5b17e92135cd3f5daf51bf044d76e40.tar.bz2 |
Got rid of more dynamic_casts
Diffstat (limited to 'src/uscxml/plugins/invoker')
3 files changed, 45 insertions, 43 deletions
diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp index 9e435d2..dac4f99 100644 --- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp +++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.cpp @@ -66,9 +66,9 @@ bool pluginConnect(pluma::Host& host) { #endif #define OSG_TAG_HANDLE(tagName, procFunc) \ -} else if (iequals(LOCALNAME(childs.item(i)), tagName) && \ +} else if (iequals(LOCALNAME(childElem), tagName) && \ validChildren.find(tagName) != validChildren.end()) { \ - procFunc(childs.item(i));\ + procFunc(childElem);\ OSGInvoker::OSGInvoker() { @@ -167,7 +167,7 @@ void OSGInvoker::handleEvent(Arabica::DOM::Events::Event<std::string>& event) { } } -void OSGInvoker::processDisplay(const Arabica::DOM::Node<std::string>& element) { +void OSGInvoker::processDisplay(const Arabica::DOM::Element<std::string>& element) { // std::cout << element << std::endl; if (_displays.find(element) == _displays.end()) { @@ -188,7 +188,7 @@ void OSGInvoker::processDisplay(const Arabica::DOM::Node<std::string>& element) } } -void OSGInvoker::processViewport(const Arabica::DOM::Node<std::string>& element) { +void OSGInvoker::processViewport(const Arabica::DOM::Element<std::string>& element) { if (_displays.find(element.getParentNode()) == _displays.end()) return; @@ -236,7 +236,7 @@ void OSGInvoker::processViewport(const Arabica::DOM::Node<std::string>& element) void OSGInvoker::processCamera(const Arabica::DOM::Node<std::string>& element) {} void OSGInvoker::updateCamera(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event) {} -void OSGInvoker::processTranslation(const Arabica::DOM::Node<std::string>& element) { +void OSGInvoker::processTranslation(const Arabica::DOM::Element<std::string>& element) { assert(_nodes.find(element.getParentNode()) != _nodes.end()); osg::ref_ptr<osg::Node> node = _nodes[element.getParentNode()]; @@ -269,7 +269,7 @@ void OSGInvoker::processTranslation(const Arabica::DOM::Node<std::string>& eleme processChildren(validChilds, element); } -void OSGInvoker::processRotation(const Arabica::DOM::Node<std::string>& element) { +void OSGInvoker::processRotation(const Arabica::DOM::Element<std::string>& element) { assert(_nodes.find(element.getParentNode()) != _nodes.end()); osg::ref_ptr<osg::Node> node = _nodes[element.getParentNode()]; @@ -296,12 +296,12 @@ void OSGInvoker::updateRotation(osg::ref_ptr<osg::Node> node, Arabica::DOM::Even osg::ref_ptr<osg::MatrixTransform> transform = static_cast<osg::MatrixTransform*>(node->asTransform()); if (false) { } else if (iequals(event.getType(), "DOMAttrModified")) { - osg::Matrix rotation = rotationFromElement(Arabica::DOM::Node<std::string>(event.getTarget())); + osg::Matrix rotation = rotationFromElement(Arabica::DOM::Element<std::string>(Arabica::DOM::Node<std::string>(event.getTarget()))); transform->setMatrix(rotation); } } -osg::Matrix OSGInvoker::rotationFromElement(const Arabica::DOM::Node<std::string>& element) { +osg::Matrix OSGInvoker::rotationFromElement(const Arabica::DOM::Element<std::string>& element) { double pitch = 0, roll = 0, yaw = 0; if (HAS_ATTR(element, "pitch")) { NumAttr pitchAttr = NumAttr(ATTR(element, "pitch")); @@ -342,7 +342,7 @@ osg::Matrix OSGInvoker::rotationFromElement(const Arabica::DOM::Node<std::string return rotation; } -void OSGInvoker::processScale(const Arabica::DOM::Node<std::string>& element) { +void OSGInvoker::processScale(const Arabica::DOM::Element<std::string>& element) { assert(_nodes.find(element.getParentNode()) != _nodes.end()); osg::ref_ptr<osg::Node> node = _nodes[element.getParentNode()]; @@ -375,7 +375,7 @@ void OSGInvoker::processScale(const Arabica::DOM::Node<std::string>& element) { processChildren(validChilds, element); } -void OSGInvoker::processNode(const Arabica::DOM::Node<std::string>& element) { +void OSGInvoker::processNode(const Arabica::DOM::Element<std::string>& element) { _nodes_t::iterator nodeIter = _nodes.find(element.getParentNode()); assert(nodeIter != _nodes.end()); @@ -407,7 +407,7 @@ void OSGInvoker::processNode(const Arabica::DOM::Node<std::string>& element) { } } -void OSGInvoker::processSphere(const Arabica::DOM::Node<std::string>& element) { +void OSGInvoker::processSphere(const Arabica::DOM::Element<std::string>& element) { assert(_nodes.find(element.getParentNode()) != _nodes.end()); osg::ref_ptr<osg::Node> parent = _nodes[element.getParentNode()]; @@ -434,7 +434,7 @@ void OSGInvoker::processSphere(const Arabica::DOM::Node<std::string>& element) { void OSGInvoker::updateSphere(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event) { } -void OSGInvoker::processBox(const Arabica::DOM::Node<std::string>& element) { +void OSGInvoker::processBox(const Arabica::DOM::Element<std::string>& element) { assert(_nodes.find(element.getParentNode()) != _nodes.end()); osg::ref_ptr<osg::Node> parent = _nodes[element.getParentNode()]; @@ -462,7 +462,7 @@ void OSGInvoker::processBox(const Arabica::DOM::Node<std::string>& element) { } void OSGInvoker::updateBox(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event) { } -void OSGInvoker::processCapsule(const Arabica::DOM::Node<std::string>& element) { +void OSGInvoker::processCapsule(const Arabica::DOM::Element<std::string>& element) { assert(_nodes.find(element.getParentNode()) != _nodes.end()); osg::ref_ptr<osg::Node> parent = _nodes[element.getParentNode()]; @@ -487,7 +487,7 @@ void OSGInvoker::processCapsule(const Arabica::DOM::Node<std::string>& element) void OSGInvoker::updateCapsule(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event) { } -void OSGInvoker::processCone(const Arabica::DOM::Node<std::string>& element) { +void OSGInvoker::processCone(const Arabica::DOM::Element<std::string>& element) { assert(_nodes.find(element.getParentNode()) != _nodes.end()); osg::ref_ptr<osg::Node> parent = _nodes[element.getParentNode()]; @@ -514,7 +514,7 @@ void OSGInvoker::processCone(const Arabica::DOM::Node<std::string>& element) { void OSGInvoker::updateCone(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event) { } -void OSGInvoker::processCylinder(const Arabica::DOM::Node<std::string>& element) { +void OSGInvoker::processCylinder(const Arabica::DOM::Element<std::string>& element) { assert(_nodes.find(element.getParentNode()) != _nodes.end()); osg::ref_ptr<osg::Node> parent = _nodes[element.getParentNode()]; @@ -541,7 +541,7 @@ void OSGInvoker::processCylinder(const Arabica::DOM::Node<std::string>& element) void OSGInvoker::updateCylinder(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event) { } -osg::Vec4 OSGInvoker::getColor(const Arabica::DOM::Node<std::string>& element, const std::string& attr, bool& valid) { +osg::Vec4 OSGInvoker::getColor(const Arabica::DOM::Element<std::string>& element, const std::string& attr, bool& valid) { if (HAS_ATTR(element, attr)) { std::string color = ATTR(element, attr); @@ -576,7 +576,7 @@ osg::Vec4 OSGInvoker::getColor(const Arabica::DOM::Node<std::string>& element, c return osg::Vec4(); } -osg::ref_ptr<osg::Material> OSGInvoker::getMaterial(const Arabica::DOM::Node<std::string>& element) { +osg::ref_ptr<osg::Material> OSGInvoker::getMaterial(const Arabica::DOM::Element<std::string>& element) { osg::ref_ptr<osg::Material> nodeMat; @@ -630,6 +630,7 @@ void OSGInvoker::processChildren(const std::set<std::string>& validChildren, con for (int i = 0; i < childs.getLength(); ++i) { if (childs.item(i).getNodeType() != Arabica::DOM::Node_base::ELEMENT_NODE) continue; + Arabica::DOM::Element<std::string> childElem = Arabica::DOM::Element<std::string>(childs.item(i)); if (false) { OSG_TAG_HANDLE("node", processNode); OSG_TAG_HANDLE("translation", processTranslation); @@ -644,12 +645,12 @@ void OSGInvoker::processChildren(const std::set<std::string>& validChildren, con OSG_TAG_HANDLE("capsule", processCapsule); OSG_TAG_HANDLE("cylinder", processCylinder); } else { - LOG(INFO) << "Unknown XML element " << TAGNAME(childs.item(i)); + LOG(INFO) << "Unknown XML element " << TAGNAME(childElem); } } } -void OSGInvoker::getViewport(const Arabica::DOM::Node<std::string>& element, +void OSGInvoker::getViewport(const Arabica::DOM::Element<std::string>& element, unsigned int& x, unsigned int& y, unsigned int& width, @@ -659,7 +660,7 @@ void OSGInvoker::getViewport(const Arabica::DOM::Node<std::string>& element, } -void OSGInvoker::getViewport(const Arabica::DOM::Node<std::string>& element, +void OSGInvoker::getViewport(const Arabica::DOM::Element<std::string>& element, unsigned int& x, unsigned int& y, unsigned int& width, @@ -674,7 +675,7 @@ void OSGInvoker::getViewport(const Arabica::DOM::Node<std::string>& element, getViewport(element, x, y, width, height, fullWidth, fullHeight); } -void OSGInvoker::getViewport(const Arabica::DOM::Node<std::string>& element, +void OSGInvoker::getViewport(const Arabica::DOM::Element<std::string>& element, unsigned int& x, unsigned int& y, unsigned int& width, diff --git a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h index af06e23..30be8ca 100644 --- a/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h +++ b/src/uscxml/plugins/invoker/graphics/openscenegraph/OSGInvoker.h @@ -61,58 +61,58 @@ public: virtual void runOnMainThread(); protected: - void processDisplay(const Arabica::DOM::Node<std::string>& element); + void processDisplay(const Arabica::DOM::Element<std::string>& element); void updateDisplay(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event); - void processViewport(const Arabica::DOM::Node<std::string>& element); + void processViewport(const Arabica::DOM::Element<std::string>& element); void updateViewport(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event); void processCamera(const Arabica::DOM::Node<std::string>& element); void updateCamera(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event); - void processTranslation(const Arabica::DOM::Node<std::string>& element); + void processTranslation(const Arabica::DOM::Element<std::string>& element); void updateTranslation(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event); - void processRotation(const Arabica::DOM::Node<std::string>& element); + void processRotation(const Arabica::DOM::Element<std::string>& element); void updateRotation(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event); - static osg::Matrix rotationFromElement(const Arabica::DOM::Node<std::string>& element); + static osg::Matrix rotationFromElement(const Arabica::DOM::Element<std::string>& element); - void processScale(const Arabica::DOM::Node<std::string>& element); + void processScale(const Arabica::DOM::Element<std::string>& element); void updateScale(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event); - void processNode(const Arabica::DOM::Node<std::string>& element); + void processNode(const Arabica::DOM::Element<std::string>& element); void updateNode(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event); - void processSphere(const Arabica::DOM::Node<std::string>& element); + void processSphere(const Arabica::DOM::Element<std::string>& element); void updateSphere(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event); - void processBox(const Arabica::DOM::Node<std::string>& element); + void processBox(const Arabica::DOM::Element<std::string>& element); void updateBox(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event); - void processCapsule(const Arabica::DOM::Node<std::string>& element); + void processCapsule(const Arabica::DOM::Element<std::string>& element); void updateCapsule(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event); - void processCone(const Arabica::DOM::Node<std::string>& element); + void processCone(const Arabica::DOM::Element<std::string>& element); void updateCone(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event); - void processCylinder(const Arabica::DOM::Node<std::string>& element); + void processCylinder(const Arabica::DOM::Element<std::string>& element); void updateCylinder(osg::ref_ptr<osg::Node> node, Arabica::DOM::Events::Event<std::string>& event); - osg::Vec4 getColor(const Arabica::DOM::Node<std::string>& element, const std::string& attr, bool& valid); - osg::ref_ptr<osg::Material> getMaterial(const Arabica::DOM::Node<std::string>& element); + osg::Vec4 getColor(const Arabica::DOM::Element<std::string>& element, const std::string& attr, bool& valid); + osg::ref_ptr<osg::Material> getMaterial(const Arabica::DOM::Element<std::string>& element); osg::Vec4 parseVec4(const std::string& coeffs, int& number); void processChildren(const std::set<std::string>& validChildren, const Arabica::DOM::Node<std::string>& element); - void getViewport(const Arabica::DOM::Node<std::string>& element, + void getViewport(const Arabica::DOM::Element<std::string>& element, unsigned int& x, unsigned int& y, unsigned int& width, unsigned int& height, int& screenId); - void getViewport(const Arabica::DOM::Node<std::string>& element, + void getViewport(const Arabica::DOM::Element<std::string>& element, unsigned int& x, unsigned int& y, unsigned int& width, unsigned int& height, CompositeDisplay* display); - void getViewport(const Arabica::DOM::Node<std::string>& element, + void getViewport(const Arabica::DOM::Element<std::string>& element, unsigned int& x, unsigned int& y, unsigned int& width, diff --git a/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp b/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp index 5b67f7c..285db72 100644 --- a/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp +++ b/src/uscxml/plugins/invoker/xhtml/XHTMLInvoker.cpp @@ -186,11 +186,12 @@ void XHTMLInvoker::reply(const SendRequest& req, const HTTPServer::Request& long std::stringstream ss; // Arabica::DOM::Node<std::string> content = req.dom.getDocumentElement(); Arabica::DOM::Node<std::string> content = req.dom; - if (content && iequals(content.getLocalName(), "content")) { - reply.headers["X-SCXML-Type"] = (HAS_ATTR(content, "type") ? ATTR(content, "type") : "replacechildren"); - reply.headers["X-SCXML-XPath"] = (HAS_ATTR(content, "xpath") ? ATTR(content, "xpath") : "/html/body"); - if (HAS_ATTR(content, "attr")) - reply.headers["X-SCXML-Attr"] = ATTR(content, "attr"); + if (content && content.getNodeType() == Arabica::DOM::Node_base::ELEMENT_NODE && iequals(content.getLocalName(), "content")) { + Arabica::DOM::Element<std::string> contentElem = Arabica::DOM::Element<std::string>(content); + reply.headers["X-SCXML-Type"] = (HAS_ATTR(contentElem, "type") ? ATTR(contentElem, "type") : "replacechildren"); + reply.headers["X-SCXML-XPath"] = (HAS_ATTR(contentElem, "xpath") ? ATTR(contentElem, "xpath") : "/html/body"); + if (HAS_ATTR(contentElem, "attr")) + reply.headers["X-SCXML-Attr"] = ATTR(contentElem, "attr"); } // ss << req.getFirstDOMElement(); ss << req.dom; |