Make free versions and wrap

release/4.3a0
Frank Dellaert 2022-01-09 15:06:57 -05:00
parent c1561dba02
commit fd48028f24
3 changed files with 41 additions and 5 deletions

View File

@ -60,8 +60,8 @@ string DiscreteValues::markdown(const KeyFormatter& keyFormatter,
return ss.str();
}
std::string DiscreteValues::html(const KeyFormatter& keyFormatter,
const Names& names) const {
string DiscreteValues::html(const KeyFormatter& keyFormatter,
const Names& names) const {
stringstream ss;
// Print out preamble.
@ -83,4 +83,15 @@ std::string DiscreteValues::html(const KeyFormatter& keyFormatter,
ss << " </tbody>\n</table>\n</div>";
return ss.str();
}
string markdown(const DiscreteValues& values, const KeyFormatter& keyFormatter,
const DiscreteValues::Names& names) {
return values.markdown(keyFormatter, names);
}
string html(const DiscreteValues& values, const KeyFormatter& keyFormatter,
const DiscreteValues::Names& names) {
return values.html(keyFormatter, names);
}
} // namespace gtsam

View File

@ -21,7 +21,9 @@
#include <gtsam/discrete/DiscreteKey.h>
#include <gtsam/inference/Key.h>
#include <map>
#include <string>
#include <vector>
namespace gtsam {
@ -71,8 +73,8 @@ class DiscreteValues : public Assignment<Key> {
* @param names translation table for values.
* @return string markdown output.
*/
std::string markdown(const KeyFormatter& keyFormatter,
const Names& names) const;
std::string markdown(const KeyFormatter& keyFormatter = DefaultKeyFormatter,
const Names& names = {}) const;
/**
* @brief Output as a html table.
@ -81,11 +83,22 @@ class DiscreteValues : public Assignment<Key> {
* @param names translation table for values.
* @return string html output.
*/
std::string html(const KeyFormatter& keyFormatter, const Names& names) const;
std::string html(const KeyFormatter& keyFormatter = DefaultKeyFormatter,
const Names& names = {}) const;
/// @}
};
/// Free version of markdown.
std::string markdown(const DiscreteValues& values,
const KeyFormatter& keyFormatter = DefaultKeyFormatter,
const DiscreteValues::Names& names = {});
/// Free version of html.
std::string html(const DiscreteValues& values,
const KeyFormatter& keyFormatter = DefaultKeyFormatter,
const DiscreteValues::Names& names = {});
// traits
template <>
struct traits<DiscreteValues> : public Testable<DiscreteValues> {};

View File

@ -17,6 +17,18 @@ class DiscreteKeys {
};
// DiscreteValues is added in specializations/discrete.h as a std::map
string markdown(
const gtsam::DiscreteValues& values,
const gtsam::KeyFormatter& keyFormatter = gtsam::DefaultKeyFormatter);
string markdown(const gtsam::DiscreteValues& values,
const gtsam::KeyFormatter& keyFormatter,
std::map<gtsam::Key, std::vector<std::string>> names);
string html(
const gtsam::DiscreteValues& values,
const gtsam::KeyFormatter& keyFormatter = gtsam::DefaultKeyFormatter);
string html(const gtsam::DiscreteValues& values,
const gtsam::KeyFormatter& keyFormatter,
std::map<gtsam::Key, std::vector<std::string>> names);
#include <gtsam/discrete/DiscreteFactor.h>
class DiscreteFactor {