pinocchio  2.4.4
A fast and flexible implementation of Rigid Body Dynamics algorithms and their analytical derivatives
serializable.hpp
1 //
2 // Copyright (c) 2017-2019 CNRS INRIA
3 //
4 
5 #ifndef __pinocchio_serialization_serializable_hpp__
6 #define __pinocchio_serialization_serializable_hpp__
7 
8 #include "pinocchio/serialization/archive.hpp"
9 
10 namespace pinocchio
11 {
12  namespace serialization
13  {
14 
15  template<class Derived>
16  struct Serializable
17  {
18  private:
19 
20  Derived & derived() { return *static_cast<Derived*>(this); }
21  const Derived & derived() const { return *static_cast<const Derived*>(this); }
22 
23  public:
24 
26  void loadFromText(const std::string & filename)
27  {
28  pinocchio::serialization::loadFromText(derived(),filename);
29  }
30 
32  void saveToText(const std::string & filename) const
33  {
34  pinocchio::serialization::saveToText(derived(),filename);
35  }
36 
38  void loadFromStringStream(std::istringstream & is)
39  {
40  pinocchio::serialization::loadFromStringStream(derived(),is);
41  }
42 
44  void saveToStringStream(std::stringstream & ss) const
45  {
46  pinocchio::serialization::saveToStringStream(derived(),ss);
47  }
48 
50  void loadFromString(const std::string & str)
51  {
52  pinocchio::serialization::loadFromString(derived(),str);
53  }
54 
56  std::string saveToString() const
57  {
58  return pinocchio::serialization::saveToString(derived());
59  }
60 
62  void loadFromXML(const std::string & filename,
63  const std::string & tag_name)
64  {
65  pinocchio::serialization::loadFromXML(derived(),filename,tag_name);
66  }
67 
69  void saveToXML(const std::string & filename,
70  const std::string & tag_name) const
71  {
72  pinocchio::serialization::saveToXML(derived(),filename,tag_name);
73  }
74 
76  void loadFromBinary(const std::string & filename)
77  {
78  pinocchio::serialization::loadFromBinary(derived(),filename);
79  }
80 
82  void saveToBinary(const std::string & filename) const
83  {
84  pinocchio::serialization::saveToBinary(derived(),filename);
85  }
86  };
87 
88  }
89 } // namespace pinocchio
90 
91 #endif // ifndef __pinocchio_serialization_serializable_hpp__
92 
void saveToBinary(const std::string &filename) const
Saves a Derived object as an binary file.
void loadFromXML(const std::string &filename, const std::string &tag_name)
Loads a Derived object from an XML file.
void loadFromString(const std::string &str)
Loads a Derived object from a string.
void loadFromBinary(const std::string &filename)
Loads a Derived object from an binary file.
std::string saveToString() const
Saves a Derived object to a string.
void loadFromStringStream(std::istringstream &is)
Loads a Derived object from a stream string.
void saveToXML(const std::string &filename, const std::string &tag_name) const
Saves a Derived object as an XML file.
void saveToText(const std::string &filename) const
Saves a Derived object as a text file.
Main pinocchio namespace.
Definition: treeview.dox:24
void saveToStringStream(std::stringstream &ss) const
Saves a Derived object to a string stream.
void loadFromText(const std::string &filename)
Loads a Derived object from a text file.