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_
static std::shared_ptr< XMLLoader > Instance()
Definition: xml_loader.h:43
std::shared_ptr< exotica::MotionSolver > MotionSolverPtr
Definition: motion_solver.h:66
static std::shared_ptr< exotica::MotionSolver > CreateSolver(const std::string &type, bool prepend=true)
Definition: setup.h:63
static std::shared_ptr< XMLLoader > instance_
Definition: xml_loader.h:91
static std::shared_ptr< exotica::MotionSolver > LoadSolverStandalone(const std::string &file_name)
Definition: xml_loader.h:75
static Initializer Load(std::string file_name, bool parsePathAsXML=false)
Definition: xml_loader.h:60
Initializer LoadXML(std::string file_name, bool parsePathAsXML=false)
Definition: xml_loader.cpp:131
static std::shared_ptr< exotica::PlanningProblem > CreateProblem(const std::string &type, bool prepend=true)
Definition: setup.h:65
static std::shared_ptr< exotica::MotionSolver > LoadSolver(const std::string &file_name)
Definition: xml_loader.h:65
std::shared_ptr< PlanningProblem > PlanningProblemPtr
~XMLLoader() noexcept
Definition: xml_loader.h:49
static std::shared_ptr< exotica::PlanningProblem > LoadProblem(const std::string &file_name)
Definition: xml_loader.h:82
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_core
Author(s): Yiming Yang, Michael Camilleri
autogenerated on Sat Apr 10 2021 02:34:49