[shill] Use composition instead of inheritance with PropertyStore
Instead of having Device, Manager, etc all inherit from PropertyStore
and have it be difficult to follow the getting/setting property code,
have each include a PropertyStore as a data member. Provide an
accessor so that RPC adaptor classes can get and set properties
directly and continue to handle any necessary type conversion
themselves.
BUG=None
TEST=unit tests
Change-Id: I34781bde4de0e152550ca636e28d472abde756af
Reviewed-on: http://gerrit.chromium.org/gerrit/3616
Tested-by: Chris Masone <cmasone@chromium.org>
Reviewed-by: Darin Petkov <petkov@chromium.org>
diff --git a/device.h b/device.h
index 4bc9ecc..2b19897 100644
--- a/device.h
+++ b/device.h
@@ -30,7 +30,7 @@
// Device superclass. Individual network interfaces types will inherit from
// this class.
-class Device : public base::RefCounted<Device>, public PropertyStore {
+class Device : public base::RefCounted<Device> {
public:
enum Technology {
kEthernet,
@@ -60,28 +60,16 @@
virtual void ConfigIP() {}
- // Implementation of PropertyStore
- virtual bool SetBoolProperty(const std::string& name,
- bool value,
- Error *error);
- virtual bool SetInt32Property(const std::string& name,
- int32 value,
- Error *error);
- virtual bool SetUint16Property(const std::string& name,
- uint16 value,
- Error *error);
- virtual bool SetStringProperty(const std::string &name,
- const std::string &value,
- Error *error);
+ std::string GetRpcIdentifier();
const std::string &link_name() const { return link_name_; }
+ PropertyStore *store() { return &store_; }
+
// Returns a string that is guaranteed to uniquely identify this Device
// instance.
const std::string &UniqueName() const;
- std::string GetRpcIdentifier();
-
protected:
FRIEND_TEST(DeviceTest, AcquireDHCPConfig);
FRIEND_TEST(DeviceTest, DestroyIPConfig);
@@ -98,10 +86,10 @@
// request was successfully sent.
bool AcquireDHCPConfig();
- void RegisterDerivedString(const std::string &name,
+ void HelpRegisterDerivedString(const std::string &name,
std::string(Device::*get)(void),
bool(Device::*set)(const std::string&));
- void RegisterDerivedStrings(const std::string &name,
+ void HelpRegisterDerivedStrings(const std::string &name,
Strings(Device::*get)(void),
bool(Device::*set)(const Strings&));
@@ -110,6 +98,8 @@
bool powered_; // TODO(pstew): Is this what |running_| is for?
bool reconnect_;
+ PropertyStore store_;
+
std::vector<ServiceRefPtr> services_;
int interface_index_;
bool running_;