[Liblas-commits] hg-main-tree: update comment about getName
liblas-commits at liblas.org
liblas-commits at liblas.org
Tue Apr 26 11:36:44 EDT 2011
details: http://hg.libpc.orghg-main-tree/rev/093224cac503
changeset: 652:093224cac503
user: Howard Butler <hobu.inc at gmail.com>
date: Tue Apr 26 10:20:08 2011 -0500
description:
update comment about getName
Subject: hg-main-tree: a little more work on Options
details: http://hg.libpc.orghg-main-tree/rev/5e725be08a10
changeset: 653:5e725be08a10
user: Howard Butler <hobu.inc at gmail.com>
date: Tue Apr 26 10:20:32 2011 -0500
description:
a little more work on Options
diffstat:
include/libpc/Options.hpp | 39 +++++++++++++++++++++++++++++++++++++--
include/libpc/Stage.hpp | 6 ++++--
2 files changed, 41 insertions(+), 4 deletions(-)
diffs (73 lines):
diff -r 22692e3985f2 -r 5e725be08a10 include/libpc/Options.hpp
--- a/include/libpc/Options.hpp Tue Apr 26 08:16:36 2011 -0500
+++ b/include/libpc/Options.hpp Tue Apr 26 10:20:32 2011 -0500
@@ -43,6 +43,38 @@
namespace libpc
{
+template <typename T>
+class LIBPC_DLL Option
+{
+
+
+private:
+ T m_value;
+ std::string m_description;
+ std::string m_name;
+
+public:
+
+ Option(std::string const& name, T value, std::string const& description)
+ : m_value(value), m_description(description), m_name(name) {}
+
+ std::string const& getName() const { return m_name; }
+ std::string const& getDescription() const { return m_description; }
+ T const& getValue() const { return m_value; }
+
+ boost::property_tree::ptree& getTree() const
+ {
+ boost::property_tree::ptree t;
+ t.put("description", getDescription());
+ t.put("value", getValue());
+ boost::property_tree::ptree output;
+ output.put_child(getName(), t);
+ return output;
+ }
+
+};
+
+
class LIBPC_DLL Options
{
@@ -52,9 +84,12 @@
public:
Options();
+ Options(boost::property_tree::ptree const& tree) { m_tree = tree; }
+ template<class T> void add(Option<T> const& option) { m_tree.put_child(option.getTree()); }
+ template<class T> Option<T> const& get(std::string const& name) { return m_tree.get<T>(name); }
- boost::property_tree::ptree& GetPTree() {return m_tree; }
- boost::property_tree::ptree const& GetPTree() const {return m_tree; }
+ boost::property_tree::ptree& GetPTree() { return m_tree; }
+ boost::property_tree::ptree const& GetPTree() const { return m_tree; }
};
diff -r 22692e3985f2 -r 5e725be08a10 include/libpc/Stage.hpp
--- a/include/libpc/Stage.hpp Tue Apr 26 08:16:36 2011 -0500
+++ b/include/libpc/Stage.hpp Tue Apr 26 10:20:32 2011 -0500
@@ -61,8 +61,10 @@
virtual ~Stage();
// Implement this in your concrete classes to return a constant string
- // as the name of the stage. Use upper camel case, with spaces between
- // words. The last word should generally be "Reader" or "Filter".
+ // as the name of the stage. Use a dotted, XPath-style name for your
+ // stage. For example, 'drivers.las.reader' or 'filters.crop'. This
+ // XPath-style name will also correspond to an entry in the libpc::Options
+ // tree for the given stage.
virtual const std::string& getName() const = 0;
virtual const std::string& getDescription() const = 0;
More information about the Liblas-commits
mailing list