summaryrefslogtreecommitdiff
path: root/property_store.h
diff options
context:
space:
mode:
authorChris Masone <cmasone@chromium.org>2011-07-02 13:10:14 -0700
committerChris Masone <cmasone@chromium.org>2011-07-03 10:58:05 -0700
commit27c4aa55b33d3a3836cf70c8f7094bce1c5ead8c (patch)
tree2df1c92826d2608bf8dd5b5f8cdb99c6ab443035 /property_store.h
parent43b48a1c94665d9f3c14694cf6a4429e5ab3fa30 (diff)
downloadshill-27c4aa55b33d3a3836cf70c8f7094bce1c5ead8c.tar.gz
[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>
Diffstat (limited to 'property_store.h')
-rw-r--r--property_store.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/property_store.h b/property_store.h
index 485f429c..fdea66a8 100644
--- a/property_store.h
+++ b/property_store.h
@@ -20,6 +20,7 @@ class Error;
class PropertyStore {
public:
+ PropertyStore();
virtual ~PropertyStore();
virtual bool Contains(const std::string& property);
@@ -78,9 +79,6 @@ class PropertyStore {
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 @@ class PropertyStore {
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 @@ class PropertyStore {
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);
};