[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/property_store.h b/property_store.h
index 485f429..fdea66a 100644
--- a/property_store.h
+++ b/property_store.h
@@ -20,6 +20,7 @@
class PropertyStore {
public:
+ PropertyStore();
virtual ~PropertyStore();
virtual bool Contains(const std::string& property);
@@ -78,9 +79,6 @@
PropertyConstIterator<uint16> GetUint16PropertiesIter();
PropertyConstIterator<uint32> GetUint32PropertiesIter();
- protected:
- PropertyStore();
-
void RegisterBool(const std::string &name, bool *prop);
void RegisterConstBool(const std::string &name, const bool *prop);
void RegisterInt16(const std::string &name, int16 *prop);
@@ -96,6 +94,14 @@
void RegisterUint16(const std::string &name, uint16 *prop);
void RegisterConstUint16(const std::string &name, const uint16 *prop);
+ void RegisterDerivedBool(const std::string &name,
+ const BoolAccessor &accessor);
+ void RegisterDerivedString(const std::string &name,
+ const StringAccessor &accessor);
+ void RegisterDerivedStrings(const std::string &name,
+ const StringsAccessor &accessor);
+
+ private:
// These are std::maps instead of something cooler because the common
// operation is iterating through them and returning all properties.
std::map<std::string, BoolAccessor> bool_properties_;
@@ -108,9 +114,6 @@
std::map<std::string, Uint16Accessor> uint16_properties_;
std::map<std::string, Uint32Accessor> uint32_properties_;
- private:
- bool ReturnError(const std::string& name, Error *error);
-
DISALLOW_COPY_AND_ASSIGN(PropertyStore);
};