Additional API

release/4.3a0
Frank Dellaert 2024-10-24 16:40:35 -07:00
parent bf47ef3432
commit 6f2b49d80d
2 changed files with 12 additions and 2 deletions

View File

@ -20,9 +20,12 @@
namespace gtsam {
// Output stream operator implementation
EdgeKey::operator std::string() const {
return "{" + std::to_string(i_) + ", " + std::to_string(j_) + "}";
}
GTSAM_EXPORT std::ostream& operator<<(std::ostream& os, const EdgeKey& key) {
os << "{" << key.i() << ", " << key.j() << "}";
os << (std::string)key;
return os;
}

View File

@ -37,6 +37,10 @@ class GTSAM_EXPORT EdgeKey {
/// Constructor
EdgeKey(std::uint32_t i, std::uint32_t j) : i_(i), j_(j) {}
EdgeKey(Key key)
: i_(static_cast<std::uint32_t>(key >> 32)),
j_(static_cast<std::uint32_t>(key)) {}
/// @}
/// @name API
/// @{
@ -50,6 +54,9 @@ class GTSAM_EXPORT EdgeKey {
/// Retrieve low 32 bits
inline std::uint32_t j() const { return j_; }
/** Create a string from the key */
operator std::string() const;
/// Output stream operator
friend GTSAM_EXPORT std::ostream& operator<<(std::ostream&, const EdgeKey&);