Program Listing for File serializable.hpp
↰ Return to documentation for file (include/pinocchio/serialization/serializable.hpp
)
//
// Copyright (c) 2017-2021 CNRS INRIA
//
#ifndef __pinocchio_serialization_serializable_hpp__
#define __pinocchio_serialization_serializable_hpp__
#include "pinocchio/serialization/archive.hpp"
namespace pinocchio
{
namespace serialization
{
template<class Derived>
struct Serializable
{
private:
Derived & derived() { return *static_cast<Derived*>(this); }
const Derived & derived() const { return *static_cast<const Derived*>(this); }
public:
void loadFromText(const std::string & filename)
{
pinocchio::serialization::loadFromText(derived(),filename);
}
void saveToText(const std::string & filename) const
{
pinocchio::serialization::saveToText(derived(),filename);
}
void loadFromStringStream(std::istringstream & is)
{
pinocchio::serialization::loadFromStringStream(derived(),is);
}
void saveToStringStream(std::stringstream & ss) const
{
pinocchio::serialization::saveToStringStream(derived(),ss);
}
void loadFromString(const std::string & str)
{
pinocchio::serialization::loadFromString(derived(),str);
}
std::string saveToString() const
{
return pinocchio::serialization::saveToString(derived());
}
void loadFromXML(const std::string & filename,
const std::string & tag_name)
{
pinocchio::serialization::loadFromXML(derived(),filename,tag_name);
}
void saveToXML(const std::string & filename,
const std::string & tag_name) const
{
pinocchio::serialization::saveToXML(derived(),filename,tag_name);
}
void loadFromBinary(const std::string & filename)
{
pinocchio::serialization::loadFromBinary(derived(),filename);
}
void saveToBinary(const std::string & filename) const
{
pinocchio::serialization::saveToBinary(derived(),filename);
}
void loadFromBinary(boost::asio::streambuf & container)
{
pinocchio::serialization::loadFromBinary(derived(),container);
}
void saveToBinary(boost::asio::streambuf & container) const
{
pinocchio::serialization::saveToBinary(derived(),container);
}
void loadFromBinary(StaticBuffer & container)
{
pinocchio::serialization::loadFromBinary(derived(),container);
}
void saveToBinary(StaticBuffer & container) const
{
pinocchio::serialization::saveToBinary(derived(),container);
}
};
}
} // namespace pinocchio
#endif // ifndef __pinocchio_serialization_serializable_hpp__