parser_deprecated.hh
00001 /*********************************************************************
00002 * Software License Agreement (BSD License)
00003 * 
00004 *  Copyright (c) 2008, Willow Garage, Inc.
00005 *  All rights reserved.
00006 * 
00007 *  Redistribution and use in source and binary forms, with or without
00008 *  modification, are permitted provided that the following conditions
00009 *  are met:
00010 * 
00011 *   * Redistributions of source code must retain the above copyright
00012 *     notice, this list of conditions and the following disclaimer.
00013 *   * Redistributions in binary form must reproduce the above
00014 *     copyright notice, this list of conditions and the following
00015 *     disclaimer in the documentation and/or other materials provided
00016 *     with the distribution.
00017 *   * Neither the name of the Willow Garage nor the names of its
00018 *     contributors may be used to endorse or promote products derived
00019 *     from this software without specific prior written permission.
00020 * 
00021 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00022 *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024 *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00025 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00026 *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00027 *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00029 *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030 *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00031 *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00032 *  POSSIBILITY OF SUCH DAMAGE.
00033 *********************************************************************/
00034 
00035 /* Author: Nate Koenig, John Hsu */
00036 
00037 #ifndef URDF_PARSER_DEPRECATED_HH
00038 #define URDF_PARSER_DEPRECATED_HH
00039 
00040 #include <string>
00041 #include <map>
00042 #include <boost/shared_ptr.hpp>
00043 #include <libxml/parser.h>
00044 
00045 #include "sdf/interface/SDF.hh"
00046 #include "math/Pose.hh"
00047 
00048 namespace deprecated_sdf
00049 {
00050   bool initLight(xmlNodePtr _config, sdf::ElementPtr &_sdf);
00051   bool initSensor(xmlNodePtr _config, sdf::ElementPtr &_sdf);
00052   bool initCamera(xmlNodePtr _config, sdf::ElementPtr &_sdf);
00053   bool initRay(xmlNodePtr _config, sdf::ElementPtr &_sdf);
00054   bool initContact(xmlNodePtr _config, sdf::ElementPtr &_sdf);
00055   bool initInertial(xmlNodePtr _config, sdf::ElementPtr &_sdf);
00056   bool initCollision(xmlNodePtr _config, sdf::ElementPtr &_sdf);
00057   bool initOrigin(xmlNodePtr _config, sdf::ElementPtr &_sdf);
00058   bool initLink(xmlNodePtr _config, sdf::ElementPtr &_sdf);
00059   bool initVisual(xmlNodePtr _config, sdf::ElementPtr &_sdf);
00060   bool initJoint(xmlNodePtr _config, sdf::ElementPtr &_sdf);
00061   bool initModel(xmlNodePtr _config, sdf::ElementPtr &_sdf);
00062 
00064   bool initModelFile(const std::string &_filename, sdf::SDFPtr &_sdf);
00065 
00067   bool initModelString(const std::string &_xmlstring, sdf::SDFPtr &_sdf);
00068 
00070   bool initModelDoc(xmlDocPtr _xml, sdf::SDFPtr &_sdf);
00071 
00073   bool initModelXml(xmlNodePtr _xml, sdf::SDFPtr &_sdf);
00074 
00075 
00077   bool initWorldFile(const std::string &_filename, sdf::SDFPtr &_sdf);
00078 
00080   bool initWorldString(const std::string &_xmlstring, 
00081                        sdf::SDFPtr &_sdf);
00082 
00084   bool initWorldDoc(xmlDocPtr _xml, sdf::SDFPtr &_sdf);
00085 
00087   bool initWorld(xmlNodePtr _xml, sdf::SDFPtr &_sdf);
00088 
00090   bool initScene(xmlNodePtr _config, sdf::ElementPtr &_sdf);
00091   
00093   bool initPhysics(xmlNodePtr _config, sdf::ElementPtr &_sdf);
00094 
00096   void copyChildren(xmlNodePtr _config, sdf::ElementPtr &_sdf);
00097   bool getPlugins(xmlNodePtr pluginXml, std::map<std::string, 
00098                   sdf::ElementPtr > &_sdf);
00099 
00100   bool initAttr(xmlNodePtr _node, const std::string &_key, sdf::ParamPtr _attr);
00101 
00103   //
00104   // Some helper functions copied from old XMLConfigNode class
00105   //
00106   // Get a child based on a name. Returns null if not found
00107   xmlNodePtr firstChildElement( xmlDocPtr node, const std::string &name);
00108   xmlNodePtr firstChildElement( xmlNodePtr node, const std::string &name);
00109   xmlNodePtr nextSiblingElement( xmlNodePtr node, const std::string &name);
00110 
00112   // Get the next sibling of node according the namespace prefix
00113   xmlNodePtr getNextByNSPrefix(xmlNodePtr node, const std::string &prefix);
00115   // Get the first child with the appropriate NS prefix
00116   xmlNodePtr getChildByNSPrefix(xmlNodePtr node, const std::string &prefix );
00117 
00119   // Get a value associated with a node.
00120   std::string getNodeValue( xmlNodePtr node, const std::string &key );
00121   std::string getNodeTuple(xmlNodePtr node, const std::string &key, int index);
00122 
00124   // Get the value of this node
00125   std::string getValue(xmlNodePtr node);
00126   void PreParser(const std::string &fname, std::string &output);
00127 
00128 
00129 }
00130 
00131 #endif