diff --git a/g2o/core/abstract_graph.h b/g2o/core/abstract_graph.h index 557472096..96d026a60 100644 --- a/g2o/core/abstract_graph.h +++ b/g2o/core/abstract_graph.h @@ -109,30 +109,51 @@ class G2O_CORE_API AbstractGraph { AbstractGraph() = default; ~AbstractGraph() = default; + /** + * @brief Load from the input assuming given format + * + * @param input The input stream for reading data. + * @param format The output format. + * @return true iff loading was successful + */ bool load(std::istream& input, io::Format format); [[nodiscard]] bool save(std::ostream& output, io::Format format) const; + //! The ids of fixed vertices std::vector& fixed() { return fixed_; }; [[nodiscard]] const std::vector& fixed() const { return fixed_; }; + //! The parameters of the graph std::vector& parameters() { return parameters_; }; [[nodiscard]] const std::vector& parameters() const { return parameters_; }; + //! The vertices of the graph std::vector& vertices() { return vertices_; }; [[nodiscard]] const std::vector& vertices() const { return vertices_; }; + //! The edges of the graph std::vector& edges() { return edges_; }; [[nodiscard]] const std::vector& edges() const { return edges_; }; + /** + * @brief Clear all structures of the graph. + * + * Clear all vertices, edges, and parameters of the graph. + */ void clear(); + /** + * @brief Set a mapping for renaming tags. + * + * @param tag_mapping mapping from -> to for renaming types in the graph. + */ void renameTags( const std::unordered_map& tag_mapping); diff --git a/g2o/core/io/io_g2o.cpp b/g2o/core/io/io_g2o.cpp index b6d89f717..98eff3698 100644 --- a/g2o/core/io/io_g2o.cpp +++ b/g2o/core/io/io_g2o.cpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -39,15 +40,10 @@ #include "g2o/stuff/string_tools.h" namespace { -std::ostream& operator<<(std::ostream& os, const std::vector& v) { - for (size_t i = 0; i < v.size(); ++i) { - if (i > 0) os << " "; - os << v[i]; - } - return os; -} - -std::ostream& operator<<(std::ostream& os, const std::vector& v) { +template +std::ostream& operator<<(std::ostream& os, const std::vector& v) { + static_assert(std::is_integral_v || std::is_floating_point_v, + "Type has to be integral or floating point"); for (size_t i = 0; i < v.size(); ++i) { if (i > 0) os << " "; os << v[i];