shill: Config80211 Cleanup.
Just cleaning up a bunch of things that didn't fit anywhere else.
Added |ToString| methods to several classes to make them easier to debug
(changed some things from |AsString| to |ToString| to make it consistent
with the rest of the code base).
Put error-returning getters/setters in Nl80211Attribute to eliminate the
need for specific casts (and, removed the casts in other parts of the
code).
Converted AttributeList::attributes_ to use a smart pointer.
Removed AttributeList's dependency on Nl80211Attribute.
BUG=None.
TEST=Unit tests.
Change-Id: I630bf59a4f73bee71953fe8faeb1d8f6a168cb29
Reviewed-on: https://gerrit.chromium.org/gerrit/40144
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Reviewed-by: Wade Guthrie <wdg@chromium.org>
Tested-by: Wade Guthrie <wdg@chromium.org>
Commit-Queue: Wade Guthrie <wdg@chromium.org>
diff --git a/attribute_list.h b/attribute_list.h
index 04f95fb..e733d01 100644
--- a/attribute_list.h
+++ b/attribute_list.h
@@ -10,9 +10,9 @@
#include <map>
#include <string>
+#include <tr1/memory>
#include <base/memory/weak_ptr.h>
-#include "shill/nl80211_attribute.h"
struct nlattr;
namespace shill {
@@ -23,7 +23,7 @@
class AttributeList : public base::SupportsWeakPtr<AttributeList> {
public:
- virtual ~AttributeList();
+ typedef std::tr1::shared_ptr<Nl80211Attribute> AttributePointer;
// Instantiates an Nl80211Attribute of the appropriate type from |id|,
// and adds it to |attributes_|.
@@ -35,6 +35,8 @@
// their attributes as message templates.
bool CreateAndInitFromNlAttr(nl80211_attrs id, const nlattr *data);
+ std::string ToString() const;
+
bool GetU8AttributeValue(int id, uint8_t *value) const;
bool GetU16AttributeValue(int id, uint16_t *value) const;
bool GetU32AttributeValue(int id, uint32_t *value) const;
@@ -88,9 +90,11 @@
// Using this to get around issues with const and operator[].
Nl80211Attribute *GetAttribute(int id) const;
- bool HasAttribute(int name, Nl80211Attribute::Type type) const;
+ // TODO(wdg): This is only used to support |GetRawAttribute|. Delete this
+ // when that goes away.
+ bool HasRawAttribute(int id) const;
- std::map<int, Nl80211Attribute *> attributes_;
+ std::map<int, AttributePointer> attributes_;
};
} // namespace shill