FrictionBase.cpp
Go to the documentation of this file.
1 /*+-------------------------------------------------------------------------+
2  | MultiVehicle simulator (libmvsim) |
3  | |
4  | Copyright (C) 2014 Jose Luis Blanco Claraco (University of Almeria) |
5  | Copyright (C) 2017 Borys Tymchenko (Odessa Polytechnic University) |
6  | Distributed under GNU General Public License version 3 |
7  | See <http://www.gnu.org/licenses/> |
8  +-------------------------------------------------------------------------+ */
9 
13 #include <mvsim/VehicleBase.h>
14 #include <rapidxml.hpp>
15 
16 using namespace mvsim;
17 
19 
20 // Explicit registration calls seem to be one (the unique?) way to assure
21 // registration takes place:
23 {
24  static bool done = false;
25  if (done)
26  return;
27  else
28  done = true;
29 
32 }
33 
35  : m_world(my_vehicle.getWorldObject()), m_my_vehicle(my_vehicle)
36 {
37 }
38 
41  VehicleBase& parent, const rapidxml::xml_node<char>* xml_node)
42 {
44 
45  using namespace std;
46  using namespace rapidxml;
47 
48  if (!xml_node || 0 != strcmp(xml_node->name(), "friction"))
49  throw runtime_error(
50  "[FrictionBase::factory] Expected XML node <friction>");
51 
52  // Parse:
53  const xml_attribute<>* frict_class = xml_node->first_attribute("class");
54  if (!frict_class || !frict_class->value())
55  throw runtime_error(
56  "[FrictionBase::factory] Missing mandatory attribute 'class' in "
57  "node <friction>");
58 
59  return classFactory_friction.create(frict_class->value(), parent, xml_node);
60 }
61 
62 void FrictionBase::setLogger(const std::weak_ptr<CSVLogger>& logger)
63 {
64  m_logger = logger;
65 }
This file contains rapidxml parser and DOM implementation.
Ch * value() const
Definition: rapidxml.hpp:692
std::weak_ptr< CSVLogger > m_logger
Definition: FrictionBase.h:67
FrictionBase(VehicleBase &my_vehicle)
static FrictionBase * factory(VehicleBase &parent, const rapidxml::xml_node< char > *xml_node)
CLASS * create(const std::string &class_name, ARG1 a1) const
Definition: ClassFactory.h:36
TClassFactory_friction classFactory_friction
Ch * name() const
Definition: rapidxml.hpp:673
#define REGISTER_FRICTION(TEXTUAL_NAME, CLASS_NAME)
Definition: FrictionBase.h:83
xml_attribute< Ch > * first_attribute(const Ch *name=0, std::size_t name_size=0, bool case_sensitive=true) const
Definition: rapidxml.hpp:1025
void setLogger(const std::weak_ptr< CSVLogger > &logger)
void register_all_friction()


mvsim
Author(s):
autogenerated on Thu Jun 6 2019 19:36:40