gtsam  4.0.0
gtsam
Key.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
18 #pragma once
19 
20 #include <gtsam/base/FastList.h>
21 #include <gtsam/base/FastMap.h>
22 #include <gtsam/base/FastSet.h>
23 #include <gtsam/base/FastVector.h>
24 #include <gtsam/base/Testable.h>
25 #include <gtsam/base/types.h>
26 #include <gtsam/dllexport.h>
27 
28 #include <boost/function.hpp>
29 
30 namespace gtsam {
31 
33 typedef boost::function<std::string(Key)> KeyFormatter;
34 
35 // Helper function for DefaultKeyFormatter
36 GTSAM_EXPORT std::string _defaultKeyFormatter(Key key);
37 
41 static const KeyFormatter DefaultKeyFormatter = &_defaultKeyFormatter;
42 
43 // Helper function for Multi-robot Key Formatter
44 GTSAM_EXPORT std::string _multirobotKeyFormatter(gtsam::Key key);
45 
52 static const gtsam::KeyFormatter MultiRobotKeyFormatter =
53  &_multirobotKeyFormatter;
54 
56 typedef FastVector<Key> KeyVector;
57 
58 // TODO(frank): Nothing fast about these :-(
59 typedef FastList<Key> KeyList;
60 typedef FastSet<Key> KeySet;
62 
64 GTSAM_EXPORT void PrintKey(Key key, const std::string& s = "",
65  const KeyFormatter& keyFormatter = DefaultKeyFormatter);
66 
68 GTSAM_EXPORT void PrintKeyList(const KeyList& keys, const std::string& s = "",
69  const KeyFormatter& keyFormatter = DefaultKeyFormatter);
70 
72 GTSAM_EXPORT void PrintKeyVector(const KeyVector& keys, const std::string& s =
73  "", const KeyFormatter& keyFormatter = DefaultKeyFormatter);
74 
76 GTSAM_EXPORT void PrintKeySet(const KeySet& keys, const std::string& s = "",
77  const KeyFormatter& keyFormatter = DefaultKeyFormatter);
78 
79 // Define Key to be Testable by specializing gtsam::traits
80 template<typename T> struct traits;
81 
82 template <>
83 struct traits<Key> {
84  static void Print(const Key& val, const std::string& str = "") {
85  PrintKey(val, str);
86  }
87  static bool Equals(const Key& val1, const Key& val2, double tol = 1e-8) {
88  return val1 == val2;
89  }
90 };
91 
92 } // namespace gtsam
93 
94 
95 
96 
void PrintKeyList(const KeyList &keys, const string &s, const KeyFormatter &keyFormatter)
Utility function to print sets of keys with optional prefix.
Definition: Key.cpp:72
A thin wrapper around std::vector that uses a custom allocator.
A thin wrapper around std::list that uses boost's fast_pool_allocator.
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:57
Definition: FastMap.h:37
A thin wrapper around std::set that uses boost's fast_pool_allocator.
boost::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:33
Definition: FastList.h:38
A thin wrapper around std::map that uses boost's fast_pool_allocator.
void PrintKeySet(const KeySet &keys, const string &s, const KeyFormatter &keyFormatter)
Utility function to print sets of keys with optional prefix.
Definition: Key.cpp:82
FastVector< Key > KeyVector
Define collection type once and for all - also used in wrappers.
Definition: Key.h:56
A manifold defines a space in which there is a notion of a linear tangent space that can be centered ...
Definition: concepts.h:30
void PrintKeyVector(const KeyVector &keys, const string &s, const KeyFormatter &keyFormatter)
Utility function to print sets of keys with optional prefix.
Definition: Key.cpp:77
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
Concept check for values that can be used in unit tests.
void PrintKey(Key key, const string &s, const KeyFormatter &keyFormatter)
Utility function to print one key with optional prefix.
Definition: Key.cpp:40
Typedefs for easier changing of types.