[shill] Enable the getting of properties, and wire to dbus.
PropertyStore exposes getters for iterators pointing to the beginning
and end of its property maps, and a static utility method in DBusAdaptor
uses these to iterate through all the properties in the PropertyStore and build
up a map of property name -> DBus::Variant-wrapped value.
BUG=chromium-os:16343
TEST=unit tests
Change-Id: I85ebbaee167ab2feed0fcf8fe654274de352aca0
Reviewed-on: http://gerrit.chromium.org/gerrit/3359
Reviewed-by: Chris Masone <cmasone@chromium.org>
Tested-by: Chris Masone <cmasone@chromium.org>
diff --git a/property_iterator.h b/property_iterator.h
new file mode 100644
index 0000000..9c52d5a
--- /dev/null
+++ b/property_iterator.h
@@ -0,0 +1,50 @@
+// Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SHILL_PROPERTY_ITERATOR_
+#define SHILL_PROPERTY_ITERATOR_
+
+#include <map>
+#include <string>
+
+#include "shill/accessor_interface.h"
+
+namespace shill {
+
+// An iterator wrapper class to hide the details of what kind of data structure
+// we're using to store key/value pairs for properties.
+// Intended for use with PropertyStore.
+template <class V>
+class PropertyConstIterator {
+ public:
+ virtual ~PropertyConstIterator() {}
+
+ void Advance() { ++it_; }
+
+ bool AtEnd() { return it_ == collection_.end(); }
+
+ const std::string &Key() const { return it_->first; }
+
+ const V &Value() { return it_->second->Get(); }
+
+ private:
+ friend class PropertyStore;
+
+ typedef std::tr1::shared_ptr<AccessorInterface<V> > VAccessorPtr;
+
+ explicit PropertyConstIterator(
+ const typename std::map<std::string, VAccessorPtr> &collection)
+ : collection_(collection),
+ it_(collection_.begin()) {
+ }
+
+ const typename std::map<std::string, VAccessorPtr> &collection_;
+ typename std::map<std::string, VAccessorPtr>::const_iterator it_;
+};
+
+
+
+} // namespace shill
+
+#endif // SHILL_PROPERTY_ITERATOR_