xml_loader.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2018, University of Edinburgh
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of nor the names of its contributors may be used to
14 // endorse or promote products derived from this software without specific
15 // prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
21 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27 // POSSIBILITY OF SUCH DAMAGE.
28 //
29 
30 #ifndef EXOTICA_CORE_XML_LOADER_H_
31 #define EXOTICA_CORE_XML_LOADER_H_
32 
35 #include <exotica_core/property.h>
36 #include <exotica_core/setup.h>
37 
38 namespace exotica
39 {
40 class XMLLoader
41 {
42 public:
43  static std::shared_ptr<XMLLoader> Instance()
44  {
45  if (!instance_) instance_.reset(new XMLLoader);
46  return instance_;
47  }
48 
49  ~XMLLoader() noexcept
50  {
51  }
52 
53  Initializer LoadXML(std::string file_name, bool parsePathAsXML = false);
54  void LoadXML(std::string file_name, Initializer& solver, Initializer& problem, const std::string& solver_name = "", const std::string& problem_name = "", bool parsePathAsXML = false);
55  static void Load(std::string file_name, Initializer& solver, Initializer& problem, const std::string& solver_name = "", const std::string& problem_name = "", bool parsePathAsXML = false)
56  {
57  Instance()->LoadXML(file_name, solver, problem, solver_name, problem_name, parsePathAsXML);
58  }
59 
60  static Initializer Load(std::string file_name, bool parsePathAsXML = false)
61  {
62  return Instance()->LoadXML(file_name, parsePathAsXML);
63  }
64 
65  static std::shared_ptr<exotica::MotionSolver> LoadSolver(const std::string& file_name)
66  {
67  Initializer solver, problem;
68  XMLLoader::Load(file_name, solver, problem);
69  PlanningProblemPtr any_problem = Setup::CreateProblem(problem);
70  MotionSolverPtr any_solver = Setup::CreateSolver(solver);
71  any_solver->SpecifyProblem(any_problem);
72  return any_solver;
73  }
74 
75  static std::shared_ptr<exotica::MotionSolver> LoadSolverStandalone(const std::string& file_name)
76  {
77  Initializer solver = XMLLoader::Load(file_name);
78  MotionSolverPtr any_solver = Setup::CreateSolver(solver);
79  return any_solver;
80  }
81 
82  static std::shared_ptr<exotica::PlanningProblem> LoadProblem(const std::string& file_name)
83  {
84  Initializer problem = XMLLoader::Load(file_name);
85  PlanningProblemPtr any_problem = Setup::CreateProblem(problem);
86  return any_problem;
87  }
88 
89 private:
90  XMLLoader();
91  static std::shared_ptr<XMLLoader> instance_;
92 };
93 } // namespace exotica
94 
95 #endif // EXOTICA_CORE_XML_LOADER_H_
planning_problem.h
exotica::XMLLoader::LoadProblem
static std::shared_ptr< exotica::PlanningProblem > LoadProblem(const std::string &file_name)
Definition: xml_loader.h:82
property.h
exotica
Definition: collision_scene.h:46
exotica::XMLLoader::Instance
static std::shared_ptr< XMLLoader > Instance()
Definition: xml_loader.h:43
exotica::XMLLoader::LoadSolver
static std::shared_ptr< exotica::MotionSolver > LoadSolver(const std::string &file_name)
Definition: xml_loader.h:65
exotica::XMLLoader::instance_
static std::shared_ptr< XMLLoader > instance_
Definition: xml_loader.h:91
exotica::XMLLoader
Definition: xml_loader.h:40
exotica::Setup::CreateProblem
static std::shared_ptr< exotica::PlanningProblem > CreateProblem(const std::string &type, bool prepend=true)
Definition: setup.h:66
exotica::XMLLoader::Load
static void Load(std::string file_name, Initializer &solver, Initializer &problem, const std::string &solver_name="", const std::string &problem_name="", bool parsePathAsXML=false)
Definition: xml_loader.h:55
exotica::XMLLoader::LoadXML
Initializer LoadXML(std::string file_name, bool parsePathAsXML=false)
Definition: xml_loader.cpp:131
exotica::Initializer
Definition: property.h:70
motion_solver.h
exotica::PlanningProblemPtr
std::shared_ptr< PlanningProblem > PlanningProblemPtr
Definition: planning_problem.h:116
exotica::XMLLoader::XMLLoader
XMLLoader()
setup.h
exotica::XMLLoader::Load
static Initializer Load(std::string file_name, bool parsePathAsXML=false)
Definition: xml_loader.h:60
exotica::XMLLoader::LoadSolverStandalone
static std::shared_ptr< exotica::MotionSolver > LoadSolverStandalone(const std::string &file_name)
Definition: xml_loader.h:75
exotica::XMLLoader::~XMLLoader
~XMLLoader() noexcept
Definition: xml_loader.h:49
exotica::Setup::CreateSolver
static std::shared_ptr< exotica::MotionSolver > CreateSolver(const std::string &type, bool prepend=true)
Definition: setup.h:64
exotica::MotionSolverPtr
std::shared_ptr< exotica::MotionSolver > MotionSolverPtr
Definition: motion_solver.h:66


exotica_core
Author(s): Yiming Yang, Michael Camilleri
autogenerated on Fri Aug 2 2024 08:43:02