24 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION 25 #include <boost/serialization/nvp.hpp> 51 c_(key.c_), j_(key.j_) {
55 Symbol(
unsigned char c, std::uint64_t j) :
66 operator Key()
const {
return key(); }
69 void print(
const std::string& s =
"")
const;
72 bool equals(
const Symbol& expected,
double tol = 0.0)
const;
75 unsigned char chr()
const {
85 operator std::string()
const;
88 std::string
string()
const {
return std::string(*
this); }
92 return c_ < comp.c_ || (comp.c_ == c_ && j_ < comp.j_);
97 return comp.c_ == c_ && comp.j_ == j_;
102 return comp == (
Key)(*
this);
107 return comp.c_ != c_ || comp.j_ != j_;
112 return comp != (
Key)(*
this);
120 static std::function<bool(Key)> ChrTest(
unsigned char c);
123 GTSAM_EXPORT
friend std::ostream &operator<<(std::ostream &,
const Symbol &);
127 #ifdef GTSAM_ENABLE_BOOST_SERIALIZATION 129 friend class boost::serialization::access;
130 template<
class ARCHIVE>
131 void serialize(ARCHIVE & ar,
const unsigned int ) {
132 ar & BOOST_SERIALIZATION_NVP(c_);
133 ar & BOOST_SERIALIZATION_NVP(j_);
147 namespace symbol_shorthand {
148 inline Key A(std::uint64_t j) {
return Symbol(
'a', j); }
149 inline Key B(std::uint64_t j) {
return Symbol(
'b', j); }
150 inline Key C(std::uint64_t j) {
return Symbol(
'c', j); }
151 inline Key D(std::uint64_t j) {
return Symbol(
'd', j); }
152 inline Key E(std::uint64_t j) {
return Symbol(
'e', j); }
153 inline Key F(std::uint64_t j) {
return Symbol(
'f', j); }
154 inline Key G(std::uint64_t j) {
return Symbol(
'g', j); }
155 inline Key H(std::uint64_t j) {
return Symbol(
'h', j); }
156 inline Key I(std::uint64_t j) {
return Symbol(
'i', j); }
157 inline Key J(std::uint64_t j) {
return Symbol(
'j', j); }
158 inline Key K(std::uint64_t j) {
return Symbol(
'k', j); }
159 inline Key L(std::uint64_t j) {
return Symbol(
'l', j); }
160 inline Key M(std::uint64_t j) {
return Symbol(
'm', j); }
161 inline Key N(std::uint64_t j) {
return Symbol(
'n', j); }
162 inline Key O(std::uint64_t j) {
return Symbol(
'o', j); }
163 inline Key P(std::uint64_t j) {
return Symbol(
'p', j); }
164 inline Key Q(std::uint64_t j) {
return Symbol(
'q', j); }
165 inline Key R(std::uint64_t j) {
return Symbol(
'r', j); }
166 inline Key S(std::uint64_t j) {
return Symbol(
's', j); }
167 inline Key T(std::uint64_t j) {
return Symbol(
't', j); }
168 inline Key U(std::uint64_t j) {
return Symbol(
'u', j); }
169 inline Key V(std::uint64_t j) {
return Symbol(
'v', j); }
170 inline Key W(std::uint64_t j) {
return Symbol(
'w', j); }
171 inline Key X(std::uint64_t j) {
return Symbol(
'x', j); }
172 inline Key Y(std::uint64_t j) {
return Symbol(
'y', j); }
173 inline Key Z(std::uint64_t j) {
return Symbol(
'z', j); }
179 const unsigned char c_;
182 Symbol operator()(
const std::uint64_t j)
const {
return Symbol(c_, j); }
183 constexpr
unsigned char chr()
const {
return c_; }
Concept check for values that can be used in unit tests.
std::string serialize(const T &input)
serializes to a string
Definition: serialization.h:113
Definition: Testable.h:152
Symbol(unsigned char c, std::uint64_t j)
Definition: Symbol.h:55
bool operator==(Key comp) const
Definition: Symbol.h:101
bool operator==(const Symbol &comp) const
Definition: Symbol.h:96
Definition: Testable.h:112
bool operator<(const Symbol &comp) const
Definition: Symbol.h:91
GTSAM_EXPORT void print(const Matrix &A, const std::string &s, std::ostream &stream)
std::string string() const
Return string representation of the key.
Definition: Symbol.h:88
Key symbol(unsigned char c, std::uint64_t j)
Definition: Symbol.h:139
std::uint64_t index() const
Definition: Symbol.h:80
Definition: chartTesting.h:28
bool operator!=(Key comp) const
Definition: Symbol.h:111
unsigned char chr() const
Definition: Symbol.h:75
Symbol(const Symbol &key)
Definition: Symbol.h:50
unsigned char symbolChr(Key key)
Definition: Symbol.h:142
bool operator!=(const Symbol &comp) const
Definition: Symbol.h:106
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:102
std::uint64_t symbolIndex(Key key)
Definition: Symbol.h:145
Symbol()
Definition: Symbol.h:45