Go to the documentation of this file.
34 #ifndef FUSE_CORE_LOSS_H
35 #define FUSE_CORE_LOSS_H
40 #include <boost/serialization/access.hpp>
41 #include <boost/type_index/stl_type_index.hpp>
42 #include <ceres/loss_function.h>
61 #define FUSE_LOSS_CLONE_DEFINITION(...) \
62 fuse_core::Loss::UniquePtr clone() const override \
64 return __VA_ARGS__::make_unique(*this); \
80 #define FUSE_LOSS_SERIALIZE_DEFINITION(...) \
81 void serialize(fuse_core::BinaryOutputArchive& archive) const override \
85 void serialize(fuse_core::TextOutputArchive& archive) const override \
89 void deserialize(fuse_core::BinaryInputArchive& archive) override \
93 void deserialize(fuse_core::TextInputArchive& archive) override \
113 #define FUSE_LOSS_TYPE_DEFINITION(...) \
116 static std::string type() \
118 return boost::typeindex::stl_type_index::type_id<__VA_ARGS__>().pretty_name(); \
121 std::string type() const override \
123 return detail::type(); \
139 #define FUSE_LOSS_DEFINITIONS(...) \
140 FUSE_SMART_PTR_DEFINITIONS(__VA_ARGS__) \
141 FUSE_LOSS_TYPE_DEFINITION(__VA_ARGS__) \
142 FUSE_LOSS_CLONE_DEFINITION(__VA_ARGS__) \
143 FUSE_LOSS_SERIALIZE_DEFINITION(__VA_ARGS__)
175 ceres::Ownership::TAKE_OWNERSHIP;
185 virtual ~Loss() =
default;
194 virtual void initialize(
const std::string& name) = 0;
202 virtual std::string
type()
const = 0;
209 virtual void print(std::ostream& stream = std::cout)
const = 0;
233 virtual Loss::UniquePtr
clone()
const = 0;
293 template<
class Archive>
302 std::ostream&
operator <<(std::ostream& stream,
const Loss& loss);
306 #endif // FUSE_CORE_LOSS_H
The Loss function interface definition.
virtual void initialize(const std::string &name)=0
Perform any required post-construction initialization, such as reading from the parameter server.
virtual Loss::UniquePtr clone() const =0
Perform a deep copy of the Loss and return a unique pointer to the copy.
boost::archive::text_iarchive TextInputArchive
Loss()=default
Default constructor.
virtual void print(std::ostream &stream=std::cout) const =0
Print a human-readable description of the loss function to the provided stream.
virtual std::string type() const =0
Returns a unique name for this loss function type.
boost::archive::binary_oarchive BinaryOutputArchive
std::ostream & operator<<(std::ostream &stream, const Constraint &constraint)
virtual ~Loss()=default
Destructor.
virtual void deserialize(fuse_core::BinaryInputArchive &)=0
Deserialize data from the provided binary archive into this Loss.
void serialize(Archive &, const unsigned int)
The Boost Serialize method that serializes all of the data members in to/out of the archive.
static constexpr ceres::Ownership Ownership
The ownership of the ceres::LossFunction* returned by lossFunction()
FUSE_SMART_PTR_ALIASES_ONLY(Loss)
boost::archive::text_oarchive TextOutputArchive
boost::archive::binary_iarchive BinaryInputArchive
virtual void serialize(fuse_core::BinaryOutputArchive &) const =0
Serialize this Loss into the provided binary archive.
friend class boost::serialization::access
virtual ceres::LossFunction * lossFunction() const =0
Return a raw pointer to a ceres::LossFunction that implements the loss function.
fuse_core
Author(s): Stephen Williams
autogenerated on Thu Apr 24 2025 02:18:55