Moby
XMLReader.h
1 /****************************************************************************
2  * Copyright 2005 Evan Drumwright
3  * This library is distributed under the terms of the Apache V2.0
4  * License (obtainable from http://www.apache.org/licenses/LICENSE-2.0).
5  ****************************************************************************/
6 
7 #ifndef _XML_READER_H
8 #define _XML_READER_H
9 
10 #include <Ravelin/VectorNd.h>
11 #include <Ravelin/MatrixNd.h>
12 #include <map>
13 #include <string>
14 #include <vector>
15 #include <boost/shared_ptr.hpp>
16 #include <Moby/Types.h>
17 
18 namespace Moby {
19 
20 class Simulator;
21 class RigidBody;
22 class RCArticulatedBody;
23 class MCArticulatedBody;
24 class Primitive;
25 
27 class XMLReader
28 {
29  public:
30  static std::map<std::string, BasePtr> read(const std::string& fname);
31  static std::map<std::string, BasePtr> construct_ID_map(boost::shared_ptr<XMLTree> node);
32 
33  private:
34  enum TupleType { eNone, eVectorN, eVector3, eQuat };
35  static boost::shared_ptr<const XMLTree> find_subtree(boost::shared_ptr<const XMLTree> root, const std::string& name);
36  static void process_tag(const std::string& tag, boost::shared_ptr<const XMLTree> root, void (*fn)(boost::shared_ptr<const XMLTree>, std::map<std::string, BasePtr>&), std::map<std::string, BasePtr>& id_map);
37  static void read_dissipation(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
38  static void read_heightmap(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
39  static void read_plane(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
40  static void read_torus(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
41  static void read_box(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
42  static void read_sphere(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
43  static void read_cylinder(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
44  static void read_cone(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
45  static void read_polyhedron(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
46  static void read_tetramesh(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
47  static void read_CSG(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
48  static void read_primitive_plugin(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
49  static void read_time_stepping_simulator(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
50  static void read_simulator(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
51  static void read_sdf(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
52  static void read_rigid_body(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
53  static void read_mc_abody(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
54  static void read_rc_abody(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
55  static void read_rc_abody_symbolic(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
56  static void read_osg_group(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
57  static void read_collision_geometry(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
58  static void read_coldet_plugin(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
59  static void read_joint_plugin(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
60  static void read_prismatic_joint(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
61  static void read_planar_joint(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
62  static void read_fixed_joint(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
63  static void read_gears(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
64  static void read_revolute_joint(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
65  static void read_spherical_joint(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
66  static void read_universal_joint(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
67  static void read_gravity_force(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
68  static void read_damping_force(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
69  static void read_stokes_drag_force(boost::shared_ptr<const XMLTree> node, std::map<std::string, BasePtr>& id_map);
70  static TupleType get_tuple(boost::shared_ptr<const XMLTree> node);
71 }; // end class
72 } // end namespace
73 
74 #endif
75 
Used to read the simulator state from XML.
Definition: XMLReader.h:27
static std::map< std::string, BasePtr > construct_ID_map(boost::shared_ptr< XMLTree > node)
Constructs an ID map from a tree.
Definition: XMLReader.cpp:135
static std::map< std::string, BasePtr > read(const std::string &fname)
Reads an XML file and constructs all read objects.
Definition: XMLReader.cpp:60