From f0fcdfa902d52b5e86e8a36d3a2662c2281a7686 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Wed, 11 Oct 2023 14:21:59 -0400 Subject: [PATCH 1/3] make DefaultKeyFormatter an extern variable so it can be updated in downstream applications --- gtsam/inference/Key.cpp | 5 ++++- gtsam/inference/Key.h | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/gtsam/inference/Key.cpp b/gtsam/inference/Key.cpp index 8fcea0d05..b5196b73b 100644 --- a/gtsam/inference/Key.cpp +++ b/gtsam/inference/Key.cpp @@ -10,7 +10,7 @@ * -------------------------------------------------------------------------- */ /** - * @file Key.h + * @file Key.cpp * @brief * @author Richard Roberts * @author Alex Cunningham @@ -26,6 +26,9 @@ using namespace std; namespace gtsam { +// KeyFormatter DefaultKeyFormatter = &_dynamicsKeyFormatter; +KeyFormatter DefaultKeyFormatter = &_defaultKeyFormatter; + /* ************************************************************************* */ string _defaultKeyFormatter(Key key) { const Symbol asSymbol(key); diff --git a/gtsam/inference/Key.h b/gtsam/inference/Key.h index 31428a50e..defa47233 100644 --- a/gtsam/inference/Key.h +++ b/gtsam/inference/Key.h @@ -37,10 +37,16 @@ using KeyFormatter = std::function; // Helper function for DefaultKeyFormatter GTSAM_EXPORT std::string _defaultKeyFormatter(Key key); -/// The default KeyFormatter, which is used if no KeyFormatter is passed to -/// a nonlinear 'print' function. Automatically detects plain integer keys -/// and Symbol keys. -static const KeyFormatter DefaultKeyFormatter = &_defaultKeyFormatter; +/** + * The default KeyFormatter, which is used if no KeyFormatter is passed + * to a 'print' function. + * + * Automatically detects plain integer keys and Symbol keys. + * + * Marked as `extern` so that it can be updated by external libraries. + * + */ +extern KeyFormatter DefaultKeyFormatter; // Helper function for Multi-robot Key Formatter GTSAM_EXPORT std::string _multirobotKeyFormatter(gtsam::Key key); @@ -124,7 +130,3 @@ struct traits { }; } // namespace gtsam - - - - From ebf3672c8dc7166dd196e3391f6b43e87c332f60 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Wed, 11 Oct 2023 14:26:39 -0400 Subject: [PATCH 2/3] add comment --- gtsam/inference/Key.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtsam/inference/Key.cpp b/gtsam/inference/Key.cpp index b5196b73b..15d633eeb 100644 --- a/gtsam/inference/Key.cpp +++ b/gtsam/inference/Key.cpp @@ -26,7 +26,7 @@ using namespace std; namespace gtsam { -// KeyFormatter DefaultKeyFormatter = &_dynamicsKeyFormatter; +/// Assign default key formatter KeyFormatter DefaultKeyFormatter = &_defaultKeyFormatter; /* ************************************************************************* */ From 3c5c500aa5cbf31e5442cc61d32daaedc8440716 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Wed, 11 Oct 2023 18:00:45 -0400 Subject: [PATCH 3/3] mark DefaultKeyFormatter with GTSAM_EXPORT --- gtsam/inference/Key.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtsam/inference/Key.h b/gtsam/inference/Key.h index defa47233..a02d018f5 100644 --- a/gtsam/inference/Key.h +++ b/gtsam/inference/Key.h @@ -46,7 +46,7 @@ GTSAM_EXPORT std::string _defaultKeyFormatter(Key key); * Marked as `extern` so that it can be updated by external libraries. * */ -extern KeyFormatter DefaultKeyFormatter; +extern GTSAM_EXPORT KeyFormatter DefaultKeyFormatter; // Helper function for Multi-robot Key Formatter GTSAM_EXPORT std::string _multirobotKeyFormatter(gtsam::Key key);